mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-11 22:16:57 +00:00
special case for velocity because it's special
This commit is contained in:
+1
-1
@@ -73,6 +73,6 @@ public class MainCommandExecutor implements TabExecutor {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
List<String> serverCommands = new ArrayList<>(Bukkit.getCommandMap().getKnownCommands().keySet());
|
||||
return CWCommand.commandSuggestions(CommandWhitelistBukkit.getConfigCache(), serverCommands, args, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission()));
|
||||
return CWCommand.commandSuggestions(CommandWhitelistBukkit.getConfigCache(), serverCommands, args, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission()), CWCommand.ImplementationType.BUKKIT);
|
||||
}
|
||||
}
|
||||
|
||||
+25
-1
@@ -61,10 +61,34 @@ public class CWCommand {
|
||||
ADD, REMOVE, HELP, RELOAD
|
||||
}
|
||||
|
||||
public static List<String> commandSuggestions(ConfigCache config, Collection<String> serverCommands, String[] args, boolean reloadPerm, boolean adminPerm) {
|
||||
public enum ImplementationType {
|
||||
BUKKIT, WATERFALL, VELOCITY
|
||||
}
|
||||
|
||||
public static List<String> commandSuggestions(
|
||||
ConfigCache config,
|
||||
Collection<String> serverCommands,
|
||||
String[] args, boolean reloadPerm,
|
||||
boolean adminPerm,
|
||||
ImplementationType implementationType
|
||||
) {
|
||||
List<String> list = new ArrayList<>();
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
// thanks velocity for handling completions entirely different from everything else
|
||||
if (implementationType.equals(ImplementationType.VELOCITY)) {
|
||||
list.add("help");
|
||||
if (reloadPerm)
|
||||
list.add("reload");
|
||||
if (adminPerm) {
|
||||
list.add("add");
|
||||
list.add("remove");
|
||||
}
|
||||
}
|
||||
return list;
|
||||
case 1:
|
||||
if ("help".startsWith(args[0]))
|
||||
list.add("help");
|
||||
if ("reload".startsWith(args[0]) && reloadPerm)
|
||||
list.add("reload");
|
||||
if ("add".startsWith(args[0]) && adminPerm)
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public class VelocityMainCommand implements SimpleCommand {
|
||||
String[] args = invocation.arguments();
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
List<String> serverCommands = new ArrayList<>();
|
||||
return CWCommand.commandSuggestions(CommandWhitelistVelocity.getConfigCache(), serverCommands, args, source.hasPermission(CWPermission.RELOAD.permission()), source.hasPermission(CWPermission.ADMIN.permission()));
|
||||
return CWCommand.commandSuggestions(CommandWhitelistVelocity.getConfigCache(), serverCommands, args, source.hasPermission(CWPermission.RELOAD.permission()), source.hasPermission(CWPermission.ADMIN.permission()), CWCommand.ImplementationType.VELOCITY);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -84,6 +84,6 @@ public class BungeeMainCommand extends Command implements TabExecutor {
|
||||
for (Map.Entry<String, Command> command : CommandWhitelistWaterfall.getPlugin().getProxy().getPluginManager().getCommands()) {
|
||||
serverCommands.add(command.getValue().getName());
|
||||
}
|
||||
return CWCommand.commandSuggestions(CommandWhitelistWaterfall.getConfigCache(), serverCommands, args, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission()));
|
||||
return CWCommand.commandSuggestions(CommandWhitelistWaterfall.getConfigCache(), serverCommands, args, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission()), CWCommand.ImplementationType.WATERFALL);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user