cleanup&fixup

This commit is contained in:
YouHaveTrouble
2021-07-17 17:41:44 +02:00
parent 017011fad0
commit 14f15aa754
5 changed files with 13 additions and 16 deletions
@@ -105,10 +105,11 @@ public class CommandWhitelistVelocity {
HashMap<String, CWGroup> groups = configCache.getGroupList();
HashSet<String> commandList = new HashSet<>();
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
CWGroup group = s.getValue();
if (s.getKey().equalsIgnoreCase("default"))
commandList.addAll(s.getValue().getCommands());
else if (player.hasPermission(s.getValue().getPermission()))
commandList.addAll(s.getValue().getCommands());
commandList.addAll(group.getCommands());
else if (player.hasPermission(group.getPermission()))
commandList.addAll(group.getCommands());
}
return commandList;
}
@@ -42,11 +42,11 @@ public class VelocityMainCommand implements SimpleCommand {
}
if (args.length == 3) {
if (CWCommand.addToWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1]))
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().added_to_whitelist));
sender.sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().added_to_whitelist, args[2], args[1])));
else
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist));
sender.sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist, args[1])));
} else
sender.sendMessage(Component.text("/"+label+" add <group> <command>"));
sender.sendMessage(Component.text("/" + label + " add <group> <command>"));
return;
case REMOVE:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
@@ -55,11 +55,11 @@ public class VelocityMainCommand implements SimpleCommand {
}
if (args.length == 3) {
if (CWCommand.removeFromWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1]))
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().removed_from_whitelist));
sender.sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().removed_from_whitelist, args[2], args[1])));
else
sender.sendMessage(MiniMessage.markdown().parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist));
sender.sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist, args[1])));
} else
sender.sendMessage(Component.text("/"+label+" remove <group> <command>"));
sender.sendMessage(Component.text("/" + label + " remove <group> <command>"));
return;
case HELP:
default:
@@ -78,9 +78,6 @@ public class VelocityMainCommand implements SimpleCommand {
String[] args = invocation.arguments();
return CompletableFuture.supplyAsync(() -> {
List<String> serverCommands = new ArrayList<>();
//TODO find out how to get all registered commands
// This is probably very broken now
return CWCommand.commandSuggestions(CommandWhitelistVelocity.getConfigCache(), serverCommands, args, source.hasPermission(CWPermission.RELOAD.permission()), source.hasPermission(CWPermission.ADMIN.permission()));
});
}