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 3acdbc697a..cddc3854da 100644 --- a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch @@ -35,13 +35,12 @@ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); } -@@ -262,30 +276,77 @@ - return new ParseResults(commandcontextbuilder1, parseResults.getReader(), parseResults.getExceptions()); - } +@@ -260,32 +274,79 @@ + CommandContextBuilder commandcontextbuilder1 = commandcontextbuilder.withSource(sourceMapper.apply(commandcontextbuilder.getSource())); -- public void performPrefixedCommand(CommandSourceStack source, String command) { -- command = command.startsWith("/") ? command.substring(1) : command; -- this.performCommand(this.dispatcher.parse(command, source), command); + return new ParseResults(commandcontextbuilder1, parseResults.getReader(), parseResults.getExceptions()); ++ } ++ + // CraftBukkit start + public void dispatchServerCommand(CommandSourceStack sender, String command) { + Joiner joiner = Joiner.on(" "); @@ -79,11 +78,13 @@ } + // CraftBukkit end -+ public void performPrefixedCommand(CommandSourceStack source, String command) { + public void performPrefixedCommand(CommandSourceStack source, String command) { +- command = command.startsWith("/") ? command.substring(1) : command; +- this.performCommand(this.dispatcher.parse(command, source), command); + // CraftBukkit start + this.performPrefixedCommand(source, command, command); -+ } -+ + } + + public void performPrefixedCommand(CommandSourceStack commandlistenerwrapper, String s, String label) { + s = s.startsWith("/") ? s.substring(1) : s; + this.performCommand(this.dispatcher.parse(s, commandlistenerwrapper), s, label); @@ -94,12 +95,13 @@ - CommandSourceStack commandlistenerwrapper = (CommandSourceStack) parseResults.getContext().getSource(); + this.performCommand(parseResults, command, command); + } -+ + +- Profiler.get().push(() -> { +- return "/" + command; + public void performCommand(ParseResults parseresults, String s, String label) { // CraftBukkit + CommandSourceStack commandlistenerwrapper = (CommandSourceStack) parseresults.getContext().getSource(); - - Profiler.get().push(() -> { -- return "/" + command; ++ ++ Profiler.get().push(() -> { + return "/" + s; }); - ContextChain contextchain = Commands.finishParsing(parseResults, command, commandlistenerwrapper); @@ -173,11 +175,12 @@ } } else { callback.accept(executioncontext); -@@ -377,11 +438,36 @@ +@@ -377,11 +438,37 @@ } public void sendCommands(ServerPlayer player) { - Map, CommandNode> map = Maps.newHashMap(); ++ if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot + // CraftBukkit start + // Register Vanilla commands into builtRoot as before + Map, CommandNode> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues @@ -211,8 +214,11 @@ player.connection.send(new ClientboundCommandsPacket(rootcommandnode)); } -@@ -392,7 +478,7 @@ +@@ -390,9 +477,10 @@ + + while (iterator.hasNext()) { CommandNode commandnode2 = (CommandNode) iterator.next(); ++ if ( !org.spigotmc.SpigotConfig.sendNamespaced && commandnode2.getName().contains( ":" ) ) continue; // Spigot if (commandnode2.canUse(source)) { - ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); @@ -220,7 +226,7 @@ argumentbuilder.requires((icompletionprovider) -> { return true; -@@ -415,7 +501,7 @@ +@@ -415,7 +503,7 @@ argumentbuilder.redirect((CommandNode) resultNodes.get(argumentbuilder.getRedirect())); } @@ -229,7 +235,7 @@ resultNodes.put(commandnode2, commandnode3); result.addChild(commandnode3); -@@ -481,7 +567,7 @@ +@@ -481,7 +569,7 @@ } private HolderLookup.RegistryLookup.Delegate createLookup(final HolderLookup.RegistryLookup original) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index cb043b6da8..d9168614b6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -2182,6 +2182,13 @@ public final class CraftServer implements Server { } public List tabCompleteCommand(Player player, String message, ServerLevel world, Vec3 pos) { + // Spigot Start + if ( (org.spigotmc.SpigotConfig.tabComplete < 0 || message.length() <= org.spigotmc.SpigotConfig.tabComplete) && !message.contains( " " ) ) + { + return ImmutableList.of(); + } + // Spigot End + List completions = null; try { if (message.startsWith("/")) { diff --git a/paper-server/src/main/java/org/spigotmc/SpigotConfig.java b/paper-server/src/main/java/org/spigotmc/SpigotConfig.java index 37171fb707..b3890bea66 100644 --- a/paper-server/src/main/java/org/spigotmc/SpigotConfig.java +++ b/paper-server/src/main/java/org/spigotmc/SpigotConfig.java @@ -156,4 +156,23 @@ public class SpigotConfig { SpigotConfig.logCommands = SpigotConfig.getBoolean( "commands.log", true ); } + + public static int tabComplete; + public static boolean sendNamespaced; + private static void tabComplete() + { + if ( SpigotConfig.version < 6 ) + { + boolean oldValue = SpigotConfig.getBoolean( "commands.tab-complete", true ); + if ( oldValue ) + { + SpigotConfig.set( "commands.tab-complete", 0 ); + } else + { + SpigotConfig.set( "commands.tab-complete", -1 ); + } + } + SpigotConfig.tabComplete = SpigotConfig.getInt( "commands.tab-complete", 0 ); + SpigotConfig.sendNamespaced = SpigotConfig.getBoolean( "commands.send-namespaced", true ); + } }