3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-07 20:10:06 +01:00

Minor bug fixes

Dieser Commit ist enthalten in:
Kenzie Togami 2019-04-28 17:27:33 -07:00
Ursprung 32d4b36419
Commit 6255ccce38
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 5D200B325E157A81
6 geänderte Dateien mit 27 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -84,6 +84,7 @@ public class ApplyBrushCommands {
builder.addParts(REGION_FACTORY, RADIUS);
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
.required()
.build());
});
}

Datei anzeigen

@ -89,6 +89,7 @@ public class PaintBrushCommands {
builder.addParts(REGION_FACTORY, RADIUS, DENSITY);
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
.required()
.build());
});
}

Datei anzeigen

@ -36,6 +36,7 @@ import com.sk89q.worldedit.world.World;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ArgumentConverter;
import org.enginehub.piston.converter.ConversionResult;
import org.enginehub.piston.converter.FailedConversion;
import org.enginehub.piston.converter.SuccessfulConversion;
import org.enginehub.piston.inject.InjectedValueAccess;
import org.enginehub.piston.inject.Key;
@ -86,7 +87,7 @@ public class FactoryConverter<T> implements ArgumentConverter<T> {
factoryExtractor.apply(worldEdit).parseFromInput(argument, parserContext)
);
} catch (InputParseException e) {
throw new IllegalArgumentException(e);
return FailedConversion.from(e);
}
}

Datei anzeigen

@ -256,6 +256,7 @@ public final class PlatformCommandManager {
registration,
instance
);
additionalConfig.accept(manager);
cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"),
TextComponent.of("Sub-command to run."))
@ -443,7 +444,7 @@ public final class PlatformCommandManager {
Request.reset();
Actor actor = platformManager.createProxyActor(event.getActor());
String[] split = commandDetection(event.getArguments().split(" "));
String[] split = commandDetection(event.getArguments().substring(1).split(" "));
// No command found!
if (!commandManager.containsCommand(split[0])) {
@ -511,7 +512,7 @@ public final class PlatformCommandManager {
actor.print(TextComponent.builder("Usage: ")
.color(TextColor.RED)
.append(TextComponent.of("/", ColorConfig.getMainText()))
.append(HelpGenerator.create(cmd).getUsage())
.append(HelpGenerator.create(e.getCommandParseResult()).getUsage())
.build());
}
} catch (CommandExecutionException e) {

Datei anzeigen

@ -19,8 +19,6 @@
package com.sk89q.worldedit.internal.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.DisallowedItemException;
import com.sk89q.worldedit.EmptyClipboardException;
@ -35,7 +33,6 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.InsufficientArgumentsException;
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.regions.RegionOperationException;
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.InvalidFilenameException;
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.Pattern;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* converts WorldEdit exceptions and converts them into {@link CommandException}s.
*/
@ -173,4 +172,10 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
throw newCommandException(e.getMessage(), e);
}
// Prevent investigation into UsageExceptions
@ExceptionMatch
public void convert(UsageException e) throws CommandException {
throw e;
}
}

Datei anzeigen

@ -19,6 +19,7 @@
package com.sk89q.worldedit.util.command.parametric;
import com.google.common.collect.ImmutableList;
import com.sk89q.minecraft.util.commands.WrappedCommandException;
import org.enginehub.piston.exception.CommandException;
import org.enginehub.piston.exception.CommandExecutionException;
@ -32,24 +33,24 @@ import java.util.List;
/**
* An implementation of an {@link ExceptionConverter} that automatically calls
* the correct method defined on this object.
*
*
* <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
* different inheritance branches, the order between them is undefined.</p>
*/
public abstract class ExceptionConverterHelper implements ExceptionConverter {
private final List<ExceptionHandler> handlers;
@SuppressWarnings("unchecked")
public ExceptionConverterHelper() {
List<ExceptionHandler> handlers = new ArrayList<>();
for (Method method : this.getClass().getMethods()) {
if (method.getAnnotation(ExceptionMatch.class) == null) {
continue;
}
Class<?>[] parameters = method.getParameterTypes();
if (parameters.length == 1) {
Class<?> cls = parameters[0];
@ -59,9 +60,9 @@ public abstract class ExceptionConverterHelper implements ExceptionConverter {
}
}
}
Collections.sort(handlers);
this.handlers = handlers;
}
@ -76,18 +77,18 @@ public abstract class ExceptionConverterHelper implements ExceptionConverter {
if (e.getCause() instanceof CommandException) {
throw (CommandException) e.getCause();
}
throw new CommandExecutionException(e, null);
throw new CommandExecutionException(e, ImmutableList.of());
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new CommandExecutionException(e, null);
throw new CommandExecutionException(e, ImmutableList.of());
}
}
}
}
private static class ExceptionHandler implements Comparable<ExceptionHandler> {
final Class<? extends Throwable> cls;
final Method method;
private ExceptionHandler(Class<? extends Throwable> cls, Method method) {
this.cls = cls;
this.method = method;