mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-29 11:57:59 +01:00
Fix undoCommandChanges.
Remove entries after undoing them. change type of change history to List, remove in reverse order to avoid potential problems with overriding of multiple changes.
This commit is contained in:
parent
28afa77c74
commit
b64beac0b4
@ -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<CommandProtectionEntry> changedCommands = null;
|
||||
protected List<CommandProtectionEntry> 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<CommandProtectionEntry> changedCommands = PermissionUtil.protectCommands(
|
||||
final List<CommandProtectionEntry> changedCommands = PermissionUtil.protectCommands(
|
||||
Arrays.asList("plugins", "version", "icanhasbukkit"), "nocheatplus.feature.command", false);
|
||||
if (this.changedCommands == null) this.changedCommands = changedCommands;
|
||||
else this.changedCommands.addAll(changedCommands);
|
||||
|
@ -64,7 +64,7 @@ public class PermissionUtil {
|
||||
* @param ops
|
||||
* @return
|
||||
*/
|
||||
public static Collection<CommandProtectionEntry> protectCommands(Collection<String> commands, String permissionBase, boolean ops){
|
||||
public static List<CommandProtectionEntry> protectCommands(Collection<String> commands, String permissionBase, boolean ops){
|
||||
return protectCommands(permissionBase, commands, true, ops);
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ public class PermissionUtil {
|
||||
* @param ops
|
||||
* @return
|
||||
*/
|
||||
public static Collection<CommandProtectionEntry> protectCommands(String permissionBase, Collection<String> ignoredCommands, boolean invertIgnored, boolean ops){
|
||||
public static List<CommandProtectionEntry> protectCommands(String permissionBase, Collection<String> ignoredCommands, boolean invertIgnored, boolean ops){
|
||||
Set<String> checked = new HashSet<String>();
|
||||
for (String label : ignoredCommands){
|
||||
checked.add(CommandUtil.getCommandLabel(label, false));
|
||||
|
Loading…
Reference in New Issue
Block a user