Minor bug fixes

This commit is contained in:
Kenzie Togami 2019-04-28 17:27:33 -07:00
parent 32d4b36419
commit 6255ccce38
No known key found for this signature in database
GPG Key ID: 5D200B325E157A81
6 changed files with 27 additions and 17 deletions

View File

@ -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());
}); });
} }

View File

@ -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());
}); });
} }

View File

@ -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);
} }
} }

View File

@ -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) {

View File

@ -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;
}
} }

View File

@ -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;
@ -76,9 +77,9 @@ 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());
} }
} }
} }