#816: Prevent duplicate slash removal for console / block commands

This commit is contained in:
md_5 2021-05-17 18:09:13 +10:00
parent 5b0e2d2d60
commit 1e8c432cd9
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
2 changed files with 16 additions and 11 deletions

View File

@ -22,7 +22,7 @@
CommandAdvancement.a(this.b);
CommandAttribute.a(this.b);
CommandExecute.a(this.b);
@@ -188,14 +197,57 @@
@@ -188,17 +197,61 @@
}
this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> {
@ -71,19 +71,24 @@
+ args[0] = "minecraft:" + args[0];
+ }
+
+ return this.a(sender, joiner.join(args));
+ String newCommand = joiner.join(args);
+ return this.a(sender, newCommand, newCommand, false);
+ }
+
public int a(CommandListenerWrapper commandlistenerwrapper, String s) {
+ return this.a(commandlistenerwrapper, s, s);
+ return this.a(commandlistenerwrapper, s, s, true);
+ }
+
+ public int a(CommandListenerWrapper commandlistenerwrapper, String s, String label) {
+ // CraftBukkit end
+ public int a(CommandListenerWrapper commandlistenerwrapper, String s, String label, boolean stripSlash) {
StringReader stringreader = new StringReader(s);
if (stringreader.canRead() && stringreader.peek() == '/') {
@@ -222,7 +274,7 @@
- if (stringreader.canRead() && stringreader.peek() == '/') {
+ if (stripSlash && stringreader.canRead() && stringreader.peek() == '/') {
+ // CraftBukkit end
stringreader.skip();
}
@@ -222,7 +275,7 @@
if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).format((chatmodifier) -> {
@ -92,7 +97,7 @@
});
if (j > 10) {
@@ -272,11 +324,36 @@
@@ -272,11 +325,36 @@
}
public void a(EntityPlayer entityplayer) {
@ -130,7 +135,7 @@
entityplayer.playerConnection.sendPacket(new PacketPlayOutCommands(rootcommandnode));
}
@@ -287,7 +364,7 @@
@@ -287,7 +365,7 @@
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
if (commandnode2.canUse(commandlistenerwrapper)) {
@ -139,7 +144,7 @@
argumentbuilder.requires((icompletionprovider) -> {
return true;
@@ -310,7 +387,7 @@
@@ -310,7 +388,7 @@
argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
}

View File

@ -42,7 +42,7 @@ public final class VanillaCommandWrapper extends BukkitCommand {
if (!testPermission(sender)) return true;
CommandListenerWrapper icommandlistener = getListener(sender);
dispatcher.a(icommandlistener, toDispatcher(args, getName()), toDispatcher(args, commandLabel));
dispatcher.a(icommandlistener, toDispatcher(args, getName()), toDispatcher(args, commandLabel), true);
return true;
}