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