mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-11 22:16:57 +00:00
cleanup&fixup
This commit is contained in:
-1
@@ -26,7 +26,6 @@ public class MainCommandExecutor implements TabExecutor {
|
||||
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
CWCommand.CommandType commandType = CWCommand.CommandType.valueOf(args[0].toUpperCase());
|
||||
switch (commandType) {
|
||||
|
||||
+2
-2
@@ -16,8 +16,7 @@ public class CWCommand {
|
||||
|
||||
public static boolean addToWhitelist(ConfigCache configCache, String command, String group) {
|
||||
CWGroup cwGroup = configCache.getGroupList().get(group);
|
||||
if (cwGroup == null)
|
||||
return false;
|
||||
if (cwGroup == null) return false;
|
||||
cwGroup.addCommand(command);
|
||||
configCache.saveCWGroup(group, cwGroup);
|
||||
return true;
|
||||
@@ -57,6 +56,7 @@ public class CWCommand {
|
||||
public static List<String> commandSuggestions(ConfigCache config, Collection<String> serverCommands, String[] args, boolean reloadPerm, boolean adminPerm) {
|
||||
List<String> list = new ArrayList<>();
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
case 1:
|
||||
if ("reload".startsWith(args[0]) && reloadPerm)
|
||||
list.add("reload");
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<version>3.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
+4
-3
@@ -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;
|
||||
}
|
||||
|
||||
+4
-7
@@ -42,9 +42,9 @@ 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>"));
|
||||
return;
|
||||
@@ -55,9 +55,9 @@ 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>"));
|
||||
return;
|
||||
@@ -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()));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user