Print help on invalid arg

This commit is contained in:
Jesse Boyd 2019-11-14 17:24:10 +00:00
parent 8812e1b60c
commit 1071e7c226
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -107,6 +107,7 @@ import com.sk89q.worldedit.command.argument.ZonedDateTimeConverter;
import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandQueuedCondition; import com.sk89q.worldedit.command.util.CommandQueuedCondition;
import com.sk89q.worldedit.command.util.PermissionCondition; import com.sk89q.worldedit.command.util.PermissionCondition;
import com.sk89q.worldedit.command.util.PrintCommandHelp;
import com.sk89q.worldedit.command.util.SubCommandPermissionCondition; import com.sk89q.worldedit.command.util.SubCommandPermissionCondition;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
@ -704,7 +705,6 @@ public final class PlatformCommandManager {
exceptionConverter.convert(next); exceptionConverter.convert(next);
next = next.getCause(); next = next.getCause();
} while (next != null); } while (next != null);
throw t; throw t;
} }
} catch (ConditionFailedException e) { } catch (ConditionFailedException e) {
@ -734,6 +734,8 @@ public final class PlatformCommandManager {
.color(TextColor.RED) .color(TextColor.RED)
.append(e.getRichMessage()) .append(e.getRichMessage())
.build()); .build());
List<String> argList = parseArgs(event.getArguments()).map(Substring::getSubstring).collect(Collectors.toList());
printUsage(actor, argList);
} catch (Throwable t) { } catch (Throwable t) {
handleUnknownException(actor, t); handleUnknownException(actor, t);
} finally { } finally {
@ -775,6 +777,11 @@ public final class PlatformCommandManager {
event.setCancelled(true); event.setCancelled(true);
} }
private void printUsage(Actor actor, List<String> arguments) {
PrintCommandHelp.help(arguments, 0, false,
getCommandManager(), actor, "//help");
}
private MemoizingValueAccess initializeInjectedValues(Arguments arguments, Actor tmp) { private MemoizingValueAccess initializeInjectedValues(Arguments arguments, Actor tmp) {
InjectedValueStore store = MapBackedValueStore.create(); InjectedValueStore store = MapBackedValueStore.create();
Actor actor = wrapActor(tmp, store); Actor actor = wrapActor(tmp, store);