From 6ba5436a482009a09709899828b8a8ba1fe5dcfe Mon Sep 17 00:00:00 2001 From: Mariell Hoversholm Date: Wed, 6 Jan 2021 23:38:43 +0100 Subject: [PATCH] Empty commands shall not be dispatched --- .../minecraft/commands/Commands.java.patch | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch index 29d319525c..1488986921 100644 --- a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch @@ -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 HolderLookup.RegistryLookup.Delegate createLookup(final HolderLookup.RegistryLookup original) {