From 2b285dd96e54c63d18efacb949944ed33ab6a7c3 Mon Sep 17 00:00:00 2001 From: Aleksi Lassila Date: Wed, 21 Oct 2020 16:58:18 +0300 Subject: [PATCH] Changed tab complete behavior: Only commands that the player has access to are shown --- .../islands/commands/IslandManagmentCommands.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/me/aleksilassila/islands/commands/IslandManagmentCommands.java b/src/me/aleksilassila/islands/commands/IslandManagmentCommands.java index efb8d36..9ee4567 100644 --- a/src/me/aleksilassila/islands/commands/IslandManagmentCommands.java +++ b/src/me/aleksilassila/islands/commands/IslandManagmentCommands.java @@ -119,20 +119,22 @@ public List onTabComplete(CommandSender sender, Command command, String Player player = (Player) sender; - List avalableArgs = new ArrayList<>(); + List availableArgs = new ArrayList<>(); if (args.length == 1) { for (Subcommand subcommand : subcommands) { - avalableArgs.add(subcommand.getName()); + if (subcommand.getPermission() == null || player.hasPermission(subcommand.getPermission())) + availableArgs.add(subcommand.getName()); } } else if (args.length > 1) { Subcommand currentSubcommand = getSubcommand(args[0]); if (currentSubcommand == null) return null; - avalableArgs = currentSubcommand.onTabComplete(player, Arrays.copyOfRange(args, 1, args.length)); + if (currentSubcommand.getPermission() == null || player.hasPermission(currentSubcommand.getPermission())) + availableArgs = currentSubcommand.onTabComplete(player, Arrays.copyOfRange(args, 1, args.length)); } - return avalableArgs; + return availableArgs; } public static class Utils {