2020-05-06 11:48:49 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2017-06-09 16:29:59 +02: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
2020-05-06 11:48:49 +02:00
index 0ec517701677a844c72b065e0ce453a0408102a5..ded9df9a31fb9ac847a60b4eba182ac487252aca 100644
2017-06-09 16:29:59 +02:00
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
2020-03-10 12:01:15 +01:00
@@ -1590,6 +1590,16 @@ public final class Bukkit {
2017-06-09 16:29:59 +02: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
2019-03-20 01:28:15 +01:00
@NotNull
2017-06-09 16:29:59 +02:00
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
2020-05-06 11:48:49 +02:00
index 93bb91fad3a27632f2d6d02f1e08ddbca6152a43..112098f9bab1b091538d74f558113830c8cdce90 100644
2017-06-09 16:29:59 +02:00
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
2020-03-10 12:01:15 +01:00
@@ -1392,4 +1392,14 @@ public interface Server extends PluginMessageRecipient {
2017-06-09 16:29:59 +02: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
2020-05-06 11:48:49 +02:00
index 7f153000eee0f563ee4f1e3c218aadb5b6a33a97..1e126487de534ddd634d9a87b9c816d6d09fd467 100644
2017-06-09 16:29:59 +02:00
--- a/src/main/java/org/bukkit/command/PluginCommand.java
+++ b/src/main/java/org/bukkit/command/PluginCommand.java
2019-05-06 04:58:04 +02:00
@@ -151,6 +151,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo
2017-06-09 16:29:59 +02:00
}
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;