mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Minor bug fixes
This commit is contained in:
parent
32d4b36419
commit
6255ccce38
@ -84,6 +84,7 @@ public class ApplyBrushCommands {
|
|||||||
builder.addParts(REGION_FACTORY, RADIUS);
|
builder.addParts(REGION_FACTORY, RADIUS);
|
||||||
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
|
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
|
||||||
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
|
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
|
||||||
|
.required()
|
||||||
.build());
|
.build());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,7 @@ public class PaintBrushCommands {
|
|||||||
builder.addParts(REGION_FACTORY, RADIUS, DENSITY);
|
builder.addParts(REGION_FACTORY, RADIUS, DENSITY);
|
||||||
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
|
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
|
||||||
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
|
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
|
||||||
|
.required()
|
||||||
.build());
|
.build());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import com.sk89q.worldedit.world.World;
|
|||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
import org.enginehub.piston.converter.ArgumentConverter;
|
import org.enginehub.piston.converter.ArgumentConverter;
|
||||||
import org.enginehub.piston.converter.ConversionResult;
|
import org.enginehub.piston.converter.ConversionResult;
|
||||||
|
import org.enginehub.piston.converter.FailedConversion;
|
||||||
import org.enginehub.piston.converter.SuccessfulConversion;
|
import org.enginehub.piston.converter.SuccessfulConversion;
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||||
import org.enginehub.piston.inject.Key;
|
import org.enginehub.piston.inject.Key;
|
||||||
@ -86,7 +87,7 @@ public class FactoryConverter<T> implements ArgumentConverter<T> {
|
|||||||
factoryExtractor.apply(worldEdit).parseFromInput(argument, parserContext)
|
factoryExtractor.apply(worldEdit).parseFromInput(argument, parserContext)
|
||||||
);
|
);
|
||||||
} catch (InputParseException e) {
|
} catch (InputParseException e) {
|
||||||
throw new IllegalArgumentException(e);
|
return FailedConversion.from(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,6 +256,7 @@ public final class PlatformCommandManager {
|
|||||||
registration,
|
registration,
|
||||||
instance
|
instance
|
||||||
);
|
);
|
||||||
|
additionalConfig.accept(manager);
|
||||||
|
|
||||||
cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"),
|
cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"),
|
||||||
TextComponent.of("Sub-command to run."))
|
TextComponent.of("Sub-command to run."))
|
||||||
@ -443,7 +444,7 @@ public final class PlatformCommandManager {
|
|||||||
Request.reset();
|
Request.reset();
|
||||||
|
|
||||||
Actor actor = platformManager.createProxyActor(event.getActor());
|
Actor actor = platformManager.createProxyActor(event.getActor());
|
||||||
String[] split = commandDetection(event.getArguments().split(" "));
|
String[] split = commandDetection(event.getArguments().substring(1).split(" "));
|
||||||
|
|
||||||
// No command found!
|
// No command found!
|
||||||
if (!commandManager.containsCommand(split[0])) {
|
if (!commandManager.containsCommand(split[0])) {
|
||||||
@ -511,7 +512,7 @@ public final class PlatformCommandManager {
|
|||||||
actor.print(TextComponent.builder("Usage: ")
|
actor.print(TextComponent.builder("Usage: ")
|
||||||
.color(TextColor.RED)
|
.color(TextColor.RED)
|
||||||
.append(TextComponent.of("/", ColorConfig.getMainText()))
|
.append(TextComponent.of("/", ColorConfig.getMainText()))
|
||||||
.append(HelpGenerator.create(cmd).getUsage())
|
.append(HelpGenerator.create(e.getCommandParseResult()).getUsage())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
} catch (CommandExecutionException e) {
|
} catch (CommandExecutionException e) {
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.command;
|
package com.sk89q.worldedit.internal.command;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.sk89q.worldedit.DisallowedItemException;
|
import com.sk89q.worldedit.DisallowedItemException;
|
||||||
import com.sk89q.worldedit.EmptyClipboardException;
|
import com.sk89q.worldedit.EmptyClipboardException;
|
||||||
@ -35,7 +33,6 @@ import com.sk89q.worldedit.WorldEdit;
|
|||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.command.InsufficientArgumentsException;
|
import com.sk89q.worldedit.command.InsufficientArgumentsException;
|
||||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
||||||
import com.sk89q.worldedit.command.util.PermissionCondition;
|
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||||
import com.sk89q.worldedit.util.command.parametric.ExceptionConverterHelper;
|
import com.sk89q.worldedit.util.command.parametric.ExceptionConverterHelper;
|
||||||
@ -45,11 +42,13 @@ import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
|
|||||||
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
|
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
|
||||||
import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
|
import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
|
||||||
import org.enginehub.piston.exception.CommandException;
|
import org.enginehub.piston.exception.CommandException;
|
||||||
import org.enginehub.piston.exception.ConditionFailedException;
|
import org.enginehub.piston.exception.UsageException;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* converts WorldEdit exceptions and converts them into {@link CommandException}s.
|
* converts WorldEdit exceptions and converts them into {@link CommandException}s.
|
||||||
*/
|
*/
|
||||||
@ -173,4 +172,10 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
|
|||||||
throw newCommandException(e.getMessage(), e);
|
throw newCommandException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevent investigation into UsageExceptions
|
||||||
|
@ExceptionMatch
|
||||||
|
public void convert(UsageException e) throws CommandException {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.util.command.parametric;
|
package com.sk89q.worldedit.util.command.parametric;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.sk89q.minecraft.util.commands.WrappedCommandException;
|
import com.sk89q.minecraft.util.commands.WrappedCommandException;
|
||||||
import org.enginehub.piston.exception.CommandException;
|
import org.enginehub.piston.exception.CommandException;
|
||||||
import org.enginehub.piston.exception.CommandExecutionException;
|
import org.enginehub.piston.exception.CommandExecutionException;
|
||||||
@ -32,24 +33,24 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* An implementation of an {@link ExceptionConverter} that automatically calls
|
* An implementation of an {@link ExceptionConverter} that automatically calls
|
||||||
* the correct method defined on this object.
|
* the correct method defined on this object.
|
||||||
*
|
*
|
||||||
* <p>Only public methods will be used. Methods will be called in order of decreasing
|
* <p>Only public methods will be used. Methods will be called in order of decreasing
|
||||||
* levels of inheritance (between classes where one inherits the other). For two
|
* levels of inheritance (between classes where one inherits the other). For two
|
||||||
* different inheritance branches, the order between them is undefined.</p>
|
* different inheritance branches, the order between them is undefined.</p>
|
||||||
*/
|
*/
|
||||||
public abstract class ExceptionConverterHelper implements ExceptionConverter {
|
public abstract class ExceptionConverterHelper implements ExceptionConverter {
|
||||||
|
|
||||||
private final List<ExceptionHandler> handlers;
|
private final List<ExceptionHandler> handlers;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ExceptionConverterHelper() {
|
public ExceptionConverterHelper() {
|
||||||
List<ExceptionHandler> handlers = new ArrayList<>();
|
List<ExceptionHandler> handlers = new ArrayList<>();
|
||||||
|
|
||||||
for (Method method : this.getClass().getMethods()) {
|
for (Method method : this.getClass().getMethods()) {
|
||||||
if (method.getAnnotation(ExceptionMatch.class) == null) {
|
if (method.getAnnotation(ExceptionMatch.class) == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<?>[] parameters = method.getParameterTypes();
|
Class<?>[] parameters = method.getParameterTypes();
|
||||||
if (parameters.length == 1) {
|
if (parameters.length == 1) {
|
||||||
Class<?> cls = parameters[0];
|
Class<?> cls = parameters[0];
|
||||||
@ -59,9 +60,9 @@ public abstract class ExceptionConverterHelper implements ExceptionConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(handlers);
|
Collections.sort(handlers);
|
||||||
|
|
||||||
this.handlers = handlers;
|
this.handlers = handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,18 +77,18 @@ public abstract class ExceptionConverterHelper implements ExceptionConverter {
|
|||||||
if (e.getCause() instanceof CommandException) {
|
if (e.getCause() instanceof CommandException) {
|
||||||
throw (CommandException) e.getCause();
|
throw (CommandException) e.getCause();
|
||||||
}
|
}
|
||||||
throw new CommandExecutionException(e, null);
|
throw new CommandExecutionException(e, ImmutableList.of());
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
throw new CommandExecutionException(e, null);
|
throw new CommandExecutionException(e, ImmutableList.of());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ExceptionHandler implements Comparable<ExceptionHandler> {
|
private static class ExceptionHandler implements Comparable<ExceptionHandler> {
|
||||||
final Class<? extends Throwable> cls;
|
final Class<? extends Throwable> cls;
|
||||||
final Method method;
|
final Method method;
|
||||||
|
|
||||||
private ExceptionHandler(Class<? extends Throwable> cls, Method method) {
|
private ExceptionHandler(Class<? extends Throwable> cls, Method method) {
|
||||||
this.cls = cls;
|
this.cls = cls;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
|
Loading…
Reference in New Issue
Block a user