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-12-13 01:42:05 +01:00
index 84ac91aa533f9c3e5c1e9107404fda5ec519ca02..777352a820b21bc013b671b62f89ae4c6418e3cb 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-12-13 01:42:05 +01:00
@@ -1642,6 +1642,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-12-13 01:42:05 +01:00
index 75800dc49b66c240da92430f1defc9f63966e0b6..02c1d054744cb0564c6593938af278e6388adfb4 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-12-13 01:42:05 +01:00
@@ -1436,4 +1436,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
}
2020-07-05 09:11:54 +02:00
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
index 03bdc1622791e1206406c87065978688d602e39e..7c80dc54776d0d66f7816b77136f6dbd9b801704 100644
--- a/src/main/java/org/bukkit/command/Command.java
+++ b/src/main/java/org/bukkit/command/Command.java
@@ -99,7 +99,7 @@ public abstract class Command {
Validate.notNull(args, "Arguments cannot be null");
Validate.notNull(alias, "Alias cannot be null");
2017-06-09 16:29:59 +02:00
2020-07-05 09:11:54 +02:00
- if (args.length == 0) {
+ if (args.length == 0 || !sender.getServer().suggestPlayerNamesWhenNullTabCompletions()) { // Paper - allow preventing player name suggestions by default) {
return ImmutableList.of();
2017-06-09 16:29:59 +02:00
}
2020-07-05 09:11:54 +02:00