Added config version "control"
This commit is contained in:
@ -2,6 +2,8 @@ package wtf.hak.survivalfabric.config;
|
||||
|
||||
public class Config {
|
||||
|
||||
public String configVersion = "1.0";
|
||||
|
||||
public boolean joinMessageEnabled = true;
|
||||
public String joinMessage = "§8[§a+§8] §7%s";
|
||||
|
||||
|
@ -26,9 +26,15 @@ public class ConfigManager {
|
||||
public static Config load() {
|
||||
try(FileReader reader = new FileReader(CONFIG_FILE)) {
|
||||
INSTANCE = GSON.fromJson(reader, Config.class);
|
||||
if (INSTANCE.configVersion.equalsIgnoreCase(new Config().configVersion)) {
|
||||
return INSTANCE;
|
||||
}
|
||||
INSTANCE.configVersion = new Config().configVersion;
|
||||
save(INSTANCE);
|
||||
return INSTANCE;
|
||||
} catch (IOException e) {
|
||||
Config config = new Config();
|
||||
INSTANCE = config;
|
||||
save(config);
|
||||
return config;
|
||||
}
|
||||
@ -41,4 +47,4 @@ public class ConfigManager {
|
||||
System.out.println("Error saving config: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user