spigot/CraftBukkit-Patches/0018-Allow-Disabling-of-Command-TabComplete.patch

76 lines
3.2 KiB
Diff
Raw Normal View History

2021-10-05 12:35:38 +11:00
From 5957c8394840aaf48ca373e36731b000cf6efeb5 Mon Sep 17 00:00:00 2001
2014-04-12 14:18:37 +10:00
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 18:05:54 +1000
Subject: [PATCH] Allow Disabling of Command TabComplete
2021-03-16 09:00:00 +11:00
diff --git a/src/main/java/net/minecraft/commands/CommandDispatcher.java b/src/main/java/net/minecraft/commands/CommandDispatcher.java
2021-06-15 18:31:06 +10:00
index e159f7e82..b5de9459b 100644
2021-03-16 09:00:00 +11:00
--- a/src/main/java/net/minecraft/commands/CommandDispatcher.java
+++ b/src/main/java/net/minecraft/commands/CommandDispatcher.java
2021-06-11 15:00:00 +10:00
@@ -332,6 +332,7 @@ public class CommandDispatcher {
}
public void a(EntityPlayer entityplayer) {
2018-07-21 11:24:31 +10:00
+ if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
// CraftBukkit start
// Register Vanilla commands into builtRoot as before
2018-12-26 08:00:00 +11:00
Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
2021-06-11 15:00:00 +10:00
@@ -370,6 +371,7 @@ public class CommandDispatcher {
while (iterator.hasNext()) {
2018-12-26 08:00:00 +11:00
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
+ if ( !org.spigotmc.SpigotConfig.sendNamespaced && commandnode2.getName().contains( ":" ) ) continue; // Spigot
if (commandnode2.canUse(commandlistenerwrapper)) {
2018-12-26 08:00:00 +11:00
ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); // CraftBukkit - decompile error
2014-04-12 14:18:37 +10:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2021-10-05 12:35:38 +11:00
index e0aa4a2f0..3aa747c15 100644
2014-04-12 14:18:37 +10:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2021-10-05 12:35:38 +11:00
@@ -1897,6 +1897,13 @@ public final class CraftServer implements Server {
2014-04-12 14:18:37 +10:00
}
2018-07-15 10:00:00 +10:00
public List<String> tabCompleteCommand(Player player, String message, WorldServer world, Vec3D pos) {
2014-04-12 14:18:37 +10:00
+ // Spigot Start
+ if ( (org.spigotmc.SpigotConfig.tabComplete < 0 || message.length() <= org.spigotmc.SpigotConfig.tabComplete) && !message.contains( " " ) )
2014-04-12 14:18:37 +10:00
+ {
+ return ImmutableList.of();
+ }
+ // Spigot End
+
List<String> completions = null;
try {
2017-04-14 15:11:45 +10:00
if (message.startsWith("/")) {
2014-04-12 14:18:37 +10:00
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
2021-01-31 10:08:46 +11:00
index 1e393421c..fed02c9b1 100644
2014-04-12 14:18:37 +10:00
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -156,4 +156,23 @@ public class SpigotConfig
2014-04-12 14:18:37 +10:00
{
logCommands = getBoolean( "commands.log", true );
}
+
+ public static int tabComplete;
+ public static boolean sendNamespaced;
2014-04-12 14:18:37 +10:00
+ 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 );
2014-04-12 14:18:37 +10:00
+ }
}
--
2.25.1
2014-04-12 14:18:37 +10:00