0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/spigot.git synced 2024-11-21 20:56:14 +00:00
spigot/CraftBukkit-Patches/0016-Allow-Disabling-of-Command-TabComplete.patch
2024-10-23 02:15:00 +11:00

76 lines
3.2 KiB
Diff

From b876521b92c970540450bbe547909f3419d19e11 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Fri, 21 Jun 2013 18:05:54 +1000
Subject: [PATCH] Allow Disabling of Command TabComplete
diff --git a/src/main/java/net/minecraft/commands/CommandDispatcher.java b/src/main/java/net/minecraft/commands/CommandDispatcher.java
index 1a2acacd3d..3ffa30754c 100644
--- a/src/main/java/net/minecraft/commands/CommandDispatcher.java
+++ b/src/main/java/net/minecraft/commands/CommandDispatcher.java
@@ -438,6 +438,7 @@ public class CommandDispatcher {
}
public void sendCommands(EntityPlayer entityplayer) {
+ if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
// CraftBukkit start
// Register Vanilla commands into builtRoot as before
Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
@@ -476,6 +477,7 @@ public class CommandDispatcher {
while (iterator.hasNext()) {
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
+ if ( !org.spigotmc.SpigotConfig.sendNamespaced && commandnode2.getName().contains( ":" ) ) continue; // Spigot
if (commandnode2.canUse(commandlistenerwrapper)) {
ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); // CraftBukkit - decompile error
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index a6a2f235ae..832bf0d4e4 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2184,6 +2184,13 @@ public final class CraftServer implements Server {
}
public List<String> tabCompleteCommand(Player player, String message, WorldServer world, Vec3D 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("/")) {
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index bc9fbcc584..fc352ecf10 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -156,4 +156,23 @@ public class SpigotConfig
{
logCommands = getBoolean( "commands.log", true );
}
+
+ public static int tabComplete;
+ public static boolean sendNamespaced;
+ private static void tabComplete()
+ {
+ if ( version < 6 )
+ {
+ boolean oldValue = getBoolean( "commands.tab-complete", true );
+ if ( oldValue )
+ {
+ set( "commands.tab-complete", 0 );
+ } else
+ {
+ set( "commands.tab-complete", -1 );
+ }
+ }
+ tabComplete = getInt( "commands.tab-complete", 0 );
+ sendNamespaced = getBoolean( "commands.send-namespaced", true );
+ }
}
--
2.47.0