Empty commands shall not be dispatched

This commit is contained in:
Mariell Hoversholm 2021-01-06 23:38:43 +01:00
parent 36020d6749
commit 6ba5436a48

View file

@ -23,20 +23,19 @@
AdvancementCommands.register(this.dispatcher);
AttributeCommand.register(this.dispatcher, commandRegistryAccess);
ExecuteCommand.register(this.dispatcher, commandRegistryAccess);
@@ -251,7 +260,12 @@
if (environment.includeIntegrated) {
@@ -252,6 +261,11 @@
PublishCommand.register(this.dispatcher);
}
+
+ // CraftBukkit start
+ }
+
+ public Commands() {
+ // CraftBukkkit end
this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer());
}
@@ -262,30 +276,77 @@
@@ -262,30 +276,78 @@
return new ParseResults(commandcontextbuilder1, parseResults.getReader(), parseResults.getExceptions());
}
@ -58,6 +57,7 @@
+ command = event.getCommand();
+
+ String[] args = command.split(" ");
+ if (args.length == 0) return; // Paper - empty commands shall not be dispatched
+
+ String cmd = args[0];
+ if (cmd.startsWith("minecraft:")) cmd = cmd.substring("minecraft:".length());
@ -123,7 +123,7 @@
StackTraceElement[] astacktraceelement = exception.getStackTrace();
for (int i = 0; i < Math.min(astacktraceelement.length, 3); ++i) {
@@ -298,7 +359,7 @@
@@ -298,7 +360,7 @@
}));
if (SharedConstants.IS_RUNNING_IN_IDE) {
commandlistenerwrapper.sendFailure(Component.literal(Util.describeError(exception)));
@ -132,7 +132,7 @@
}
} finally {
Profiler.get().pop();
@@ -307,18 +368,22 @@
@@ -307,18 +369,22 @@
}
@Nullable
@ -161,7 +161,7 @@
});
if (i > 10) {
@@ -333,8 +398,18 @@
@@ -333,8 +399,18 @@
}
ichatmutablecomponent.append((Component) Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC));
@ -181,7 +181,7 @@
return null;
}
@@ -368,7 +443,7 @@
@@ -368,7 +444,7 @@
executioncontext1.close();
} finally {
@ -190,7 +190,7 @@
}
} else {
callback.accept(executioncontext);
@@ -377,22 +452,84 @@
@@ -377,22 +453,84 @@
}
public void sendCommands(ServerPlayer player) {
@ -280,7 +280,7 @@
argumentbuilder.requires((icompletionprovider) -> {
return true;
@@ -415,12 +552,12 @@
@@ -415,12 +553,12 @@
argumentbuilder.redirect((CommandNode) resultNodes.get(argumentbuilder.getRedirect()));
}
@ -295,7 +295,7 @@
}
}
}
@@ -481,7 +618,7 @@
@@ -481,7 +619,7 @@
}
private <T> HolderLookup.RegistryLookup.Delegate<T> createLookup(final HolderLookup.RegistryLookup<T> original) {