aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-API-Patches/0051-Add-configuration-option-to-prevent-player-names-fro.patch
blob: 20836a8ac39c0109636c445dadf9ec6e7ea1537d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From 03b558d1228782283c1c47a75c174c19791f974d Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc>
Date: Fri, 9 Jun 2017 07:24:24 -0700
Subject: [PATCH] Add configuration option to prevent player names from being
 suggested


diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 5431b17b..ed403c33 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1206,6 +1206,16 @@ public final class Bukkit {
     public static boolean reloadCommandAliases() {
         return server.reloadCommandAliases();
     }
+
+    /**
+     * Checks if player names should be suggested when a command returns {@code null} as
+     * their tab completion result.
+     *
+     * @return true if player names should be suggested
+     */
+    public static boolean suggestPlayerNamesWhenNullTabCompletions() {
+        return server.suggestPlayerNamesWhenNullTabCompletions();
+    }
     // Paper end
 
     public static Server.Spigot spigot()
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 83b370e5..87ab9d2b 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1032,4 +1032,14 @@ public interface Server extends PluginMessageRecipient {
     void reloadPermissions(); // Paper
 
     boolean reloadCommandAliases(); // Paper
+
+    // Paper start - allow preventing player name suggestions by default
+    /**
+     * Checks if player names should be suggested when a command returns {@code null} as
+     * their tab completion result.
+     *
+     * @return true if player names should be suggested
+     */
+    boolean suggestPlayerNamesWhenNullTabCompletions();
+    // Paper end
 }
diff --git a/src/main/java/org/bukkit/command/PluginCommand.java b/src/main/java/org/bukkit/command/PluginCommand.java
index 2abe1208..c660c178 100644
--- a/src/main/java/org/bukkit/command/PluginCommand.java
+++ b/src/main/java/org/bukkit/command/PluginCommand.java
@@ -145,6 +145,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
         }
 
         if (completions == null) {
+            if (!sender.getServer().suggestPlayerNamesWhenNullTabCompletions()) return com.google.common.collect.ImmutableList.of(); // Paper - allow preventing player name suggestions by default
             return super.tabComplete(sender, alias, args);
         }
         return completions;
-- 
2.17.0 (Apple Git-106)