Skip to content

Commit 292cac7

Browse files
prevented saving duplicate command entries
1 parent 6487255 commit 292cac7

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/main/java/eu/endermite/commandwhitelist/spigot/config/ConfigCache.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public HashMap<String, List<String>> getPermSubList() {
5252
}
5353
public boolean addCommand(String command, String group) {
5454
try {
55+
if (this.permList.get(group).contains(command)) {
56+
return true;
57+
}
5558
this.permList.get(group).add(command);
5659
this.config.set("commands."+group, permList.get(group));
5760
config.save(CommandWhitelist.getPlugin().getDataFolder()+"/config.yml");

src/main/java/eu/endermite/commandwhitelist/spigot/listeners/PlayerCommandPreProcessListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreproce
3030
String rawCmd = event.getMessage();
3131
List<String> bannedSubCommands = CommandsList.getSuggestions(player);
3232
for (String bannedSubCommand : bannedSubCommands) {
33-
if (rawCmd.equalsIgnoreCase("/"+bannedSubCommand) || rawCmd.equalsIgnoreCase("/"+bannedSubCommand+" ")) {
33+
if (rawCmd.startsWith("/"+bannedSubCommand)) {
3434
event.setCancelled(true);
3535
ConfigCache config = CommandWhitelist.getConfigCache();
3636
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getPrefix() + RandomStuff.getMessage(config.getCommandDeniedList(), config.getSubCommandDenied())));

0 commit comments

Comments
 (0)