mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Allow Disabling of Command TabComplete
By: md_5 <git@md-5.net>
This commit is contained in:
parent
0eed728812
commit
cabf908e4c
3 changed files with 49 additions and 17 deletions
|
@ -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<S> 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<CommandSourceStack> parseresults, String s, String label) { // CraftBukkit
|
||||
+ CommandSourceStack commandlistenerwrapper = (CommandSourceStack) parseresults.getContext().getSource();
|
||||
|
||||
Profiler.get().push(() -> {
|
||||
- return "/" + command;
|
||||
+
|
||||
+ Profiler.get().push(() -> {
|
||||
+ return "/" + s;
|
||||
});
|
||||
- ContextChain<CommandSourceStack> 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<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newHashMap();
|
||||
+ if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
|
||||
+ // CraftBukkit start
|
||||
+ // Register Vanilla commands into builtRoot as before
|
||||
+ Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> 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<CommandSourceStack> commandnode2 = (CommandNode) iterator.next();
|
||||
+ if ( !org.spigotmc.SpigotConfig.sendNamespaced && commandnode2.getName().contains( ":" ) ) continue; // Spigot
|
||||
|
||||
if (commandnode2.canUse(source)) {
|
||||
- ArgumentBuilder<SharedSuggestionProvider, ?> 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 <T> HolderLookup.RegistryLookup.Delegate<T> createLookup(final HolderLookup.RegistryLookup<T> original) {
|
||||
|
|
|
@ -2182,6 +2182,13 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
|
||||
public List<String> 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<String> completions = null;
|
||||
try {
|
||||
if (message.startsWith("/")) {
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue