From d70f99b489891c3cf43cc4283a4aca4725c6306b Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Mon, 4 Oct 2021 17:10:36 +0200 Subject: [PATCH] fix: Respect tab-complete aliases (Fixes #3266) (#3268) * Fixes #3250 * ListFlag#merge should not allow duplicates (Fixes #3157) (#3265) * feat: Respect non-visible players in tab completion (Closes #3263) (#3264) * Respect non-visible players in tab completion (Closes #3263) * Deprecate old Tab-Complete methods instead of hard-replacing them * wtf git * Mark for removal, useless new-lines * Pass ConsolePlayer.getConsole() instead of Nullable param * Respect tab-complete aliases (Fixes #3266) * Useless import Co-authored-by: NotMyFault Co-authored-by: dordsor21 --- .../main/java/com/plotsquared/bukkit/BukkitCommand.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitCommand.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitCommand.java index e1c55d9c5..50cca3ecf 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitCommand.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitCommand.java @@ -27,6 +27,7 @@ package com.plotsquared.bukkit; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.core.command.MainCommand; +import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.player.ConsolePlayer; import com.plotsquared.core.player.PlotPlayer; import org.bukkit.command.Command; @@ -42,6 +43,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Locale; public class BukkitCommand implements CommandExecutor, TabCompleter { @@ -63,7 +65,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter { @Override public List onTabComplete( - CommandSender commandSender, Command command, String s, + CommandSender commandSender, Command command, String label, String[] args ) { if (!(commandSender instanceof Player)) { @@ -73,8 +75,11 @@ public class BukkitCommand implements CommandExecutor, TabCompleter { if (args.length == 0) { return Collections.singletonList("plots"); } + if (!Settings.Enabled_Components.TAB_COMPLETED_ALIASES.contains(label.toLowerCase(Locale.ENGLISH))) { + return List.of(); + } Collection objects = - MainCommand.getInstance().tab(player, args, s.endsWith(" ")); + MainCommand.getInstance().tab(player, args, label.endsWith(" ")); if (objects == null) { return null; }