mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
62 lines
2.4 KiB
Diff
62 lines
2.4 KiB
Diff
From 7070e4f10451715c06c1766937634f1b7f4ab98d 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 a0a8b540..b5b77b2d 100644
|
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
@@ -1532,6 +1532,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
|
|
|
|
@NotNull
|
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
|
index d20e044d..103897fb 100644
|
|
--- a/src/main/java/org/bukkit/Server.java
|
|
+++ b/src/main/java/org/bukkit/Server.java
|
|
@@ -1342,4 +1342,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 7f153000..1e126487 100644
|
|
--- a/src/main/java/org/bukkit/command/PluginCommand.java
|
|
+++ b/src/main/java/org/bukkit/command/PluginCommand.java
|
|
@@ -151,6 +151,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.21.0
|
|
|