From 0000000000000000000000000000000000000000 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 622aaf0786140059b81704763175773d8ea41952..c4be0ad6f4ddcceb4505a4bbe185605cf3d9e016 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -1888,6 +1888,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 861ec80f86ffcb4625e89887e2b752ea02716596..12e4b491ec9abfa16b304423942d9ecdee30f5c9 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -1660,4 +1660,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 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"); - if (args.length == 0) { + if (args.length == 0 || !sender.getServer().suggestPlayerNamesWhenNullTabCompletions()) { // Paper - allow preventing player name suggestions by default) { return ImmutableList.of(); }