diff --git a/src/fr/neatmonster/nocheatplus/NoCheatPlus.java b/src/fr/neatmonster/nocheatplus/NoCheatPlus.java index aaa85a1a..d5cf9193 100644 --- a/src/fr/neatmonster/nocheatplus/NoCheatPlus.java +++ b/src/fr/neatmonster/nocheatplus/NoCheatPlus.java @@ -2,7 +2,6 @@ package fr.neatmonster.nocheatplus; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; @@ -174,7 +173,7 @@ public class NoCheatPlus extends JavaPlugin implements Listener, NoCheatPlusAPI * Commands that were changed for protecting them against tab complete or * use. */ - protected Collection changedCommands = null; + protected List changedCommands = null; @Override public void addComponent(final Object obj) { @@ -242,18 +241,20 @@ public class NoCheatPlus extends JavaPlugin implements Listener, NoCheatPlusAPI } /** - * Does not undo 100%, but restore old permission, permission-message, label (unliekly to be changed), permission default. + * Does not undo 100%, but restore old permission, permission-message, label (unlikely to be changed), permission default. */ public void undoCommandChanges() { if (changedCommands != null){ - for (final CommandProtectionEntry entry : changedCommands){ + while (!changedCommands.isEmpty()){ + final CommandProtectionEntry entry = changedCommands.remove(changedCommands.size() - 1); entry.restore(); } + changedCommands = null; } } private void setupCommandProtection() { - final Collection changedCommands = PermissionUtil.protectCommands( + final List changedCommands = PermissionUtil.protectCommands( Arrays.asList("plugins", "version", "icanhasbukkit"), "nocheatplus.feature.command", false); if (this.changedCommands == null) this.changedCommands = changedCommands; else this.changedCommands.addAll(changedCommands); diff --git a/src/fr/neatmonster/nocheatplus/permissions/PermissionUtil.java b/src/fr/neatmonster/nocheatplus/permissions/PermissionUtil.java index 537bbb52..005ecd64 100644 --- a/src/fr/neatmonster/nocheatplus/permissions/PermissionUtil.java +++ b/src/fr/neatmonster/nocheatplus/permissions/PermissionUtil.java @@ -64,7 +64,7 @@ public class PermissionUtil { * @param ops * @return */ - public static Collection protectCommands(Collection commands, String permissionBase, boolean ops){ + public static List protectCommands(Collection commands, String permissionBase, boolean ops){ return protectCommands(permissionBase, commands, true, ops); } @@ -76,7 +76,7 @@ public class PermissionUtil { * @param ops * @return */ - public static Collection protectCommands(String permissionBase, Collection ignoredCommands, boolean invertIgnored, boolean ops){ + public static List protectCommands(String permissionBase, Collection ignoredCommands, boolean invertIgnored, boolean ops){ Set checked = new HashSet(); for (String label : ignoredCommands){ checked.add(CommandUtil.getCommandLabel(label, false));