From edba48d35f93076c75eb85e2d5f502ec17832986 Mon Sep 17 00:00:00 2001 From: kashike 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 c7f4c6f2..411e534b 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -1545,6 +1545,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 f248400e..2778ce92 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -1353,4 +1353,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 30597d30..6206ff44 100644 --- a/src/main/java/org/bukkit/command/PluginCommand.java +++ b/src/main/java/org/bukkit/command/PluginCommand.java @@ -150,6 +150,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