mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Clean up old level values on load
This commit is contained in:
1 parent
6d40fbca9a
commit
34845dd6db
2 files changed
+18
-4
No files matched your search
@@ -38,6 +38,7 @@ public class ConfigurationFile {
|
||||
private AntiCheat plugin;
|
||||
|
||||
private boolean saveDefault;
|
||||
private boolean didSaveDefault;
|
||||
|
||||
protected boolean needsReload;
|
||||
|
||||
@@ -68,6 +69,7 @@ public class ConfigurationFile {
|
||||
if (!rawFile.exists()) {
|
||||
if (saveDefault) {
|
||||
plugin.saveResource(fileName, true);
|
||||
didSaveDefault = true;
|
||||
} else {
|
||||
if (!rawFile.getParentFile().exists()) {
|
||||
rawFile.getParentFile().mkdir();
|
||||
@@ -137,6 +139,8 @@ public class ConfigurationFile {
|
||||
|
||||
private Object value = null;
|
||||
|
||||
private boolean didLoadDefault;
|
||||
|
||||
public ConfigValue(String path) {
|
||||
this(path, true);
|
||||
}
|
||||
@@ -151,6 +155,7 @@ public class ConfigurationFile {
|
||||
value = getDefaultConfigFile().get(path);
|
||||
getConfigFile().set(path, value);
|
||||
save();
|
||||
didLoadDefault = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,5 +180,9 @@ public class ConfigurationFile {
|
||||
public boolean hasValue() {
|
||||
return value != null;
|
||||
}
|
||||
|
||||
public boolean didLoadDefault() {
|
||||
return didLoadDefault;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,9 @@ import net.h31ix.anticheat.config.Configuration;
|
||||
import net.h31ix.anticheat.config.ConfigurationFile;
|
||||
import net.h31ix.anticheat.config.providers.Events;
|
||||
import net.h31ix.anticheat.util.Level;
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class YamlEventsHolder extends ConfigurationFile implements Events {
|
||||
|
||||
@@ -55,6 +53,13 @@ public class YamlEventsHolder extends ConfigurationFile implements Events {
|
||||
public void open() {
|
||||
ConfigValue<List<String>> levels = new ConfigValue<List<String>>("events");
|
||||
|
||||
// Clean up old values
|
||||
if(levels.didLoadDefault()) {
|
||||
new ConfigValue<List<String>>("levels").setValue(null);
|
||||
new ConfigValue<List<String>>("actions").setValue(null);
|
||||
save();
|
||||
}
|
||||
|
||||
// Convert levels list to Levels
|
||||
this.levels = new ArrayList<Level>();
|
||||
for (String string : levels.getValue()) {
|
||||
|
||||
Reference in new issue
Block a user