mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 06:28:52 +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 AntiCheat plugin;
|
||||||
|
|
||||||
private boolean saveDefault;
|
private boolean saveDefault;
|
||||||
|
private boolean didSaveDefault;
|
||||||
|
|
||||||
protected boolean needsReload;
|
protected boolean needsReload;
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ public class ConfigurationFile {
|
|||||||
if (!rawFile.exists()) {
|
if (!rawFile.exists()) {
|
||||||
if (saveDefault) {
|
if (saveDefault) {
|
||||||
plugin.saveResource(fileName, true);
|
plugin.saveResource(fileName, true);
|
||||||
|
didSaveDefault = true;
|
||||||
} else {
|
} else {
|
||||||
if (!rawFile.getParentFile().exists()) {
|
if (!rawFile.getParentFile().exists()) {
|
||||||
rawFile.getParentFile().mkdir();
|
rawFile.getParentFile().mkdir();
|
||||||
@@ -137,6 +139,8 @@ public class ConfigurationFile {
|
|||||||
|
|
||||||
private Object value = null;
|
private Object value = null;
|
||||||
|
|
||||||
|
private boolean didLoadDefault;
|
||||||
|
|
||||||
public ConfigValue(String path) {
|
public ConfigValue(String path) {
|
||||||
this(path, true);
|
this(path, true);
|
||||||
}
|
}
|
||||||
@@ -151,6 +155,7 @@ public class ConfigurationFile {
|
|||||||
value = getDefaultConfigFile().get(path);
|
value = getDefaultConfigFile().get(path);
|
||||||
getConfigFile().set(path, value);
|
getConfigFile().set(path, value);
|
||||||
save();
|
save();
|
||||||
|
didLoadDefault = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,5 +180,9 @@ public class ConfigurationFile {
|
|||||||
public boolean hasValue() {
|
public boolean hasValue() {
|
||||||
return value != null;
|
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.ConfigurationFile;
|
||||||
import net.h31ix.anticheat.config.providers.Events;
|
import net.h31ix.anticheat.config.providers.Events;
|
||||||
import net.h31ix.anticheat.util.Level;
|
import net.h31ix.anticheat.util.Level;
|
||||||
|
import net.h31ix.anticheat.util.Utilities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class YamlEventsHolder extends ConfigurationFile implements Events {
|
public class YamlEventsHolder extends ConfigurationFile implements Events {
|
||||||
|
|
||||||
@@ -55,6 +53,13 @@ public class YamlEventsHolder extends ConfigurationFile implements Events {
|
|||||||
public void open() {
|
public void open() {
|
||||||
ConfigValue<List<String>> levels = new ConfigValue<List<String>>("events");
|
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
|
// Convert levels list to Levels
|
||||||
this.levels = new ArrayList<Level>();
|
this.levels = new ArrayList<Level>();
|
||||||
for (String string : levels.getValue()) {
|
for (String string : levels.getValue()) {
|
||||||
|
|||||||
Reference in new issue
Block a user