mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-11 22:16:57 +00:00
prevented saving duplicate command entries
This commit is contained in:
@@ -52,6 +52,9 @@ public class ConfigCache {
|
|||||||
}
|
}
|
||||||
public boolean addCommand(String command, String group) {
|
public boolean addCommand(String command, String group) {
|
||||||
try {
|
try {
|
||||||
|
if (this.permList.get(group).contains(command)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
this.permList.get(group).add(command);
|
this.permList.get(group).add(command);
|
||||||
this.config.set("commands."+group, permList.get(group));
|
this.config.set("commands."+group, permList.get(group));
|
||||||
config.save(CommandWhitelist.getPlugin().getDataFolder()+"/config.yml");
|
config.save(CommandWhitelist.getPlugin().getDataFolder()+"/config.yml");
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ public class PlayerCommandPreProcessListener implements Listener {
|
|||||||
String rawCmd = event.getMessage();
|
String rawCmd = event.getMessage();
|
||||||
List<String> bannedSubCommands = CommandsList.getSuggestions(player);
|
List<String> bannedSubCommands = CommandsList.getSuggestions(player);
|
||||||
for (String bannedSubCommand : bannedSubCommands) {
|
for (String bannedSubCommand : bannedSubCommands) {
|
||||||
if (rawCmd.equalsIgnoreCase("/"+bannedSubCommand) || rawCmd.equalsIgnoreCase("/"+bannedSubCommand+" ")) {
|
if (rawCmd.startsWith("/"+bannedSubCommand)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
ConfigCache config = CommandWhitelist.getConfigCache();
|
ConfigCache config = CommandWhitelist.getConfigCache();
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getPrefix() + RandomStuff.getMessage(config.getCommandDeniedList(), config.getSubCommandDenied())));
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getPrefix() + RandomStuff.getMessage(config.getCommandDeniedList(), config.getSubCommandDenied())));
|
||||||
|
|||||||
Reference in New Issue
Block a user