Persist checks disabled with /anticheat check in the configuration

This commit is contained in:
gravitylow committed 2014-01-25 02:38:39 -05:00
1 parent bc9f52760d
commit 9154ef3370
4 files changed
+24 -26

No files matched your search

@@ -23,6 +23,8 @@ import net.gravitydevelopment.anticheat.command.CommandBase;
import net.gravitydevelopment.anticheat.util.Permission;
import org.bukkit.command.CommandSender;
import java.util.List;
public class CommandCheck extends CommandBase {
private static final String NAME = "AntiCheat Check Management";
@@ -72,8 +74,16 @@ public class CommandCheck extends CommandBase {
} else {
if (newValue) {
CHECK_MANAGER.activateCheck(type, cs.getName());
List<String> checks = CONFIG.getConfig().disabledChecks.getValue();
if (checks.contains(type.toString())) {
checks.remove(type.toString());
CONFIG.getConfig().disabledChecks.setValue(checks);
}
} else {
CHECK_MANAGER.deactivateCheck(type, cs.getName());
List<String> checks = CONFIG.getConfig().disabledChecks.getValue();
checks.add(type.toString());
CONFIG.getConfig().disabledChecks.setValue(checks);
}
cs.sendMessage(GREEN + type.toString() + strValue + ".");
}
@@ -54,6 +54,7 @@ public class Config extends ConfigurationFile {
public ConfigValue<Boolean> logToFile;
public ConfigValue<List<String>> disabledWorlds;
public ConfigValue<List<String>> disabledChecks;
public Config(AntiCheat plugin, Configuration config) {
super(plugin, config, FILENAME);
@@ -88,5 +89,6 @@ public class Config extends ConfigurationFile {
logToFile = new ConfigValue<Boolean>("system.log-to-file");
disabledWorlds = new ConfigValue<List<String>>("disable-in");
disabledChecks = new ConfigValue<List<String>>("disabled-checks");
}
}
@@ -39,12 +39,19 @@ public class CheckManager {
private Configuration config;
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
private static Map<String, List<CheckType>> exemptList = new HashMap<String, List<CheckType>>();
private static int disabled = 0;
private static int exempt = 0;
public CheckManager(AntiCheatManager manager) {
this.manager = manager;
this.config = manager.getConfiguration();
for (String string : config.getConfig().disabledChecks.getValue()) {
for (CheckType type : CheckType.values()) {
if (type.toString().equalsIgnoreCase(string)) {
checkIgnoreList.add(type);
break;
}
}
}
}
/**
@@ -68,7 +75,6 @@ public class CheckManager {
if (isActive(type)) {
manager.getLoggingManager().logFineInfo("The " + type.toString() + " check was deactivated by " + className + ".");
checkIgnoreList.add(type);
disabled++;
}
}
@@ -95,7 +101,6 @@ public class CheckManager {
}
manager.getLoggingManager().logFineInfo(player.getName() + " was exempted from the " + type.toString() + " check by " + className + ".");
exemptList.get(player.getName()).add(type);
exempt++;
}
}
@@ -187,26 +192,4 @@ public class CheckManager {
}
return false;
}
/**
* Get the number of exempt players
*
* @return exempt players
*/
public int getExempt() {
int x = exempt;
exempt = 0;
return x;
}
/**
* Get the number of disabled checks
*
* @return disabled checks
*/
public int getDisabled() {
int x = disabled;
disabled = 0;
return x;
}
}