mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-04 06:28:52 +00:00
Persist checks disabled with /anticheat check in the configuration
This commit is contained in:
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 net.gravitydevelopment.anticheat.util.Permission;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandCheck extends CommandBase {
|
public class CommandCheck extends CommandBase {
|
||||||
|
|
||||||
private static final String NAME = "AntiCheat Check Management";
|
private static final String NAME = "AntiCheat Check Management";
|
||||||
@@ -72,8 +74,16 @@ public class CommandCheck extends CommandBase {
|
|||||||
} else {
|
} else {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
CHECK_MANAGER.activateCheck(type, cs.getName());
|
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 {
|
} else {
|
||||||
CHECK_MANAGER.deactivateCheck(type, cs.getName());
|
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 + ".");
|
cs.sendMessage(GREEN + type.toString() + strValue + ".");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public class Config extends ConfigurationFile {
|
|||||||
public ConfigValue<Boolean> logToFile;
|
public ConfigValue<Boolean> logToFile;
|
||||||
|
|
||||||
public ConfigValue<List<String>> disabledWorlds;
|
public ConfigValue<List<String>> disabledWorlds;
|
||||||
|
public ConfigValue<List<String>> disabledChecks;
|
||||||
|
|
||||||
public Config(AntiCheat plugin, Configuration config) {
|
public Config(AntiCheat plugin, Configuration config) {
|
||||||
super(plugin, config, FILENAME);
|
super(plugin, config, FILENAME);
|
||||||
@@ -88,5 +89,6 @@ public class Config extends ConfigurationFile {
|
|||||||
logToFile = new ConfigValue<Boolean>("system.log-to-file");
|
logToFile = new ConfigValue<Boolean>("system.log-to-file");
|
||||||
|
|
||||||
disabledWorlds = new ConfigValue<List<String>>("disable-in");
|
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 Configuration config;
|
||||||
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
||||||
private static Map<String, List<CheckType>> exemptList = new HashMap<String, List<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) {
|
public CheckManager(AntiCheatManager manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.config = manager.getConfiguration();
|
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)) {
|
if (isActive(type)) {
|
||||||
manager.getLoggingManager().logFineInfo("The " + type.toString() + " check was deactivated by " + className + ".");
|
manager.getLoggingManager().logFineInfo("The " + type.toString() + " check was deactivated by " + className + ".");
|
||||||
checkIgnoreList.add(type);
|
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 + ".");
|
manager.getLoggingManager().logFineInfo(player.getName() + " was exempted from the " + type.toString() + " check by " + className + ".");
|
||||||
exemptList.get(player.getName()).add(type);
|
exemptList.get(player.getName()).add(type);
|
||||||
exempt++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,26 +192,4 @@ public class CheckManager {
|
|||||||
}
|
}
|
||||||
return false;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -42,6 +42,9 @@ system:
|
|||||||
event-chains: true
|
event-chains: true
|
||||||
# Should Enterprise options be enabled? Only set this to true if you're an advanced user.
|
# Should Enterprise options be enabled? Only set this to true if you're an advanced user.
|
||||||
enterprise: false
|
enterprise: false
|
||||||
|
# Use /anticheat check for a list of valid checks
|
||||||
|
disabled-checks:
|
||||||
|
- EXAMPLE_CHECK
|
||||||
disable-in:
|
disable-in:
|
||||||
- example-world
|
- example-world
|
||||||
- example-world-2
|
- example-world-2
|
||||||
Reference in new issue
Block a user