mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 04:26:42 +00:00
Stop using IAE to communicate parameter mis-use
This commit is contained in:
@ -19,10 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.internal.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.internal.util.Substring;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import org.enginehub.piston.Command;
|
||||
import org.enginehub.piston.exception.CommandException;
|
||||
import org.enginehub.piston.part.SubCommandPart;
|
||||
|
||||
import java.util.Comparator;
|
||||
@ -92,6 +96,30 @@ public class CommandUtil {
|
||||
return Optional.of(builder.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Require {@code condition} to be {@code true}, otherwise throw a {@link CommandException}
|
||||
* with the given message.
|
||||
*
|
||||
* @param condition the condition to check
|
||||
* @param message the message for failure
|
||||
*/
|
||||
public static void checkCommandArgument(boolean condition, String message) {
|
||||
checkCommandArgument(condition, TextComponent.of(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Require {@code condition} to be {@code true}, otherwise throw a {@link CommandException}
|
||||
* with the given message.
|
||||
*
|
||||
* @param condition the condition to check
|
||||
* @param message the message for failure
|
||||
*/
|
||||
public static void checkCommandArgument(boolean condition, Component message) {
|
||||
if (!condition) {
|
||||
throw new CommandException(message, ImmutableList.of());
|
||||
}
|
||||
}
|
||||
|
||||
private CommandUtil() {
|
||||
}
|
||||
}
|
||||
|
@ -165,11 +165,6 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
|
||||
throw newCommandException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
@ExceptionMatch
|
||||
public void convert(IllegalArgumentException e) throws CommandException {
|
||||
throw newCommandException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
// Prevent investigation into UsageExceptions
|
||||
@ExceptionMatch
|
||||
public void convert(UsageException e) throws CommandException {
|
||||
|
Reference in New Issue
Block a user