waterfall impl

This commit is contained in:
2021-10-26 14:06:36 +02:00
parent 87fc3d7da3
commit c5fdaa95f8
2 changed files with 17 additions and 1 deletions
@@ -106,4 +106,20 @@ public final class CommandWhitelistWaterfall extends Plugin {
}
return suggestionList;
}
/**
* @return Command denied message. Will use custom if command exists in any group.
*/
public static String getCommandDeniedMessage(String command) {
String commandDeniedMessage = configCache.command_denied;
HashMap<String, CWGroup> groups = configCache.getGroupList();
for (CWGroup group : groups.values()) {
if (group.getCommands().contains(command)) {
if (group.getCommandDeniedMessage() == null) continue;
commandDeniedMessage = group.getCommandDeniedMessage();
break; // get first message we find
}
}
return commandDeniedMessage;
}
}
@@ -32,7 +32,7 @@ public class BungeeChatEventListener implements Listener {
HashSet<String> commands = CommandWhitelistWaterfall.getCommands(player);
if (!commands.contains(label)) {
event.setCancelled(true);
CommandWhitelistWaterfall.getAudiences().player(player).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.command_denied));
CommandWhitelistWaterfall.getAudiences().player(player).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + CommandWhitelistWaterfall.getCommandDeniedMessage(label)));
return;
}