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