2018-07-23 08:39:55 +00:00
From 6f46820d7b4ee0f41a22f79597a5371439d6521d Mon Sep 17 00:00:00 2001
2017-06-09 14:29:59 +00:00
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
2018-07-14 01:44:35 +00:00
index 70495c15..c918d67c 100644
2017-06-09 14:29:59 +00:00
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
2018-07-14 01:44:35 +00:00
@@ -1279,6 +1279,16 @@ public final class Bukkit {
2017-06-09 14:29:59 +00:00
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
2018-07-20 19:57:43 +00:00
index 94d709f4..96044f4b 100644
2017-06-09 14:29:59 +00:00
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
2018-07-20 19:57:43 +00:00
@@ -1098,4 +1098,14 @@ public interface Server extends PluginMessageRecipient {
2017-06-09 14:29:59 +00:00
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
2018-06-18 21:03:09 +00:00
index 2abe1208..c660c178 100644
2017-06-09 14:29:59 +00:00
--- 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;
--
2018-07-14 01:44:35 +00:00
2.18.0
2017-06-09 14:29:59 +00:00