mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-26 02:19:48 -05:00
Tab-Complete fix
Former-commit-id: 023cc7eacdc61a5325cbc8e36cdb4c3140599681 [formerly fc9d3487ffac849738e8c833c7e2ba13adc1d0d1] Former-commit-id: 04bf4acba93fdd535feab59b9d4614a00de3e28e
This commit is contained in:
1 parent
53ac79a345
commit
503fd1ee91
2 files changed
+31
-14
No files matched your search
@@ -14,7 +14,6 @@ import org.jetbrains.annotations.*;
|
||||
import org.maxgamer.quickshop.Command.SubCommands.*;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Util.MsgUtil;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
@Data
|
||||
public class CommandManager implements TabCompleter, CommandExecutor {
|
||||
@@ -88,21 +87,21 @@ public class CommandManager implements TabCompleter, CommandExecutor {
|
||||
((Player) sender).playSound(player.getLocation(), Sound.BLOCK_DISPENSER_FAIL, 80.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
if (cmdArg.length == 0)
|
||||
return rootContainer.getExecutor().onTabComplete(sender, commandLabel, new String[]{});
|
||||
if (cmdArg.length == 1)
|
||||
return rootContainer.getExecutor().onTabComplete(sender, commandLabel, cmdArg);
|
||||
ArrayList<String> candidate = new ArrayList<>();
|
||||
if (cmdArg.length == 0 || cmdArg.length == 1) {
|
||||
//No args
|
||||
return getRootContainer().getExecutor().onTabComplete(sender, commandLabel, cmdArg);
|
||||
}
|
||||
//Main args/more args
|
||||
String[] passthroughArgs;
|
||||
passthroughArgs = new String[cmdArg.length - 1];
|
||||
System.arraycopy(cmdArg, 1, passthroughArgs, 0, passthroughArgs.length);
|
||||
for (CommandContainer container : cmds) {
|
||||
if (container.getPrefix().startsWith(cmdArg[0].toLowerCase()) || container.getPrefix().equals(cmdArg[0]
|
||||
.toLowerCase()))
|
||||
if (container.getPrefix().equals(cmdArg[0].toLowerCase()))
|
||||
if (container.getPermission() == null || container.getPermission().isEmpty() || sender.hasPermission(container
|
||||
.getPermission()))
|
||||
if (!container.isHidden())
|
||||
candidate.add(container.getPrefix());
|
||||
return container.getExecutor().onTabComplete(sender, commandLabel, passthroughArgs);
|
||||
}
|
||||
return candidate;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,10 +122,8 @@ public class CommandManager implements TabCompleter, CommandExecutor {
|
||||
if (cmdArg.length != 0) {
|
||||
passthroughArgs = new String[cmdArg.length - 1];
|
||||
System.arraycopy(cmdArg, 1, passthroughArgs, 0, passthroughArgs.length);
|
||||
Util.debugLog(Util.array2String(passthroughArgs));
|
||||
} else {
|
||||
passthroughArgs = new String[0];
|
||||
Util.debugLog(Util.array2String(passthroughArgs));
|
||||
return rootContainer.getExecutor().onCommand(sender, commandLabel, passthroughArgs);
|
||||
}
|
||||
// if (cmdArg.length == 0)
|
||||
|
||||
@@ -96,6 +96,26 @@ public class SubCommand_Staff implements CommandProcesser {
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
ArrayList<String> tabList = new ArrayList<>();
|
||||
if (cmdArg.length < 2) {
|
||||
if (cmdArg.length == 1) {
|
||||
String prefix = cmdArg[0].toLowerCase();
|
||||
if ("add".startsWith(prefix) || "add".equals(prefix))
|
||||
tabList.add("add");
|
||||
if ("del".startsWith(prefix) || "del".equals(prefix))
|
||||
tabList.add("del");
|
||||
if ("list".startsWith(prefix) || "list".equals(prefix))
|
||||
tabList.add("list");
|
||||
if ("clear".startsWith(prefix) || "clear".equals(prefix))
|
||||
tabList.add("clear");
|
||||
} else {
|
||||
tabList.add("add");
|
||||
tabList.add("del");
|
||||
tabList.add("list");
|
||||
tabList.add("clear");
|
||||
}
|
||||
|
||||
return tabList;
|
||||
}
|
||||
if (cmdArg[0].equals("add") || cmdArg[0].equals("del")) {
|
||||
if (plugin.getConfig().getBoolean("include-offlineplayer-list")) {
|
||||
//Include
|
||||
|
||||
Reference in new issue
Block a user