Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
61 Zeilen
2.6 KiB
Diff
61 Zeilen
2.6 KiB
Diff
From 0000000000000000000000000000000000000000 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 a314ff1363cb527fa7e1b366f9191939e9c7ca6e..d3d8c5ac59cee2ec24e91223e0c994016a4f9752 100644
|
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
@@ -2143,6 +2143,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 610475aff60b7f19c4bedb932985c736fb890684..a8d3addae5b0ed261d6a27052ad4e54970de597c 100644
|
|
--- a/src/main/java/org/bukkit/Server.java
|
|
+++ b/src/main/java/org/bukkit/Server.java
|
|
@@ -1880,4 +1880,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
|
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/Command.java b/src/main/java/org/bukkit/command/Command.java
|
|
index 6fd341482d5250ad814e870360e40b52427f799a..a26df5f6341d22ecd5e71da59b8f091848e627ad 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 {
|
|
Preconditions.checkArgument(args != null, "Arguments cannot be null");
|
|
Preconditions.checkArgument(alias != null, "Alias cannot be null");
|
|
|
|
- if (args.length == 0) {
|
|
+ if (args.length == 0 || !sender.getServer().suggestPlayerNamesWhenNullTabCompletions()) { // Paper - allow preventing player name suggestions by default) {
|
|
return ImmutableList.of();
|
|
}
|
|
|