diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 855d166a..f5d5f770 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: variables: name: "SongodaCore" path: "/builds/$CI_PROJECT_PATH" - version: "2.0.3" + version: "2.0.4" build: stage: build diff --git a/src/main/java/com/songoda/core/SongodaCore.java b/src/main/java/com/songoda/core/SongodaCore.java index eb4ed37d..e5ff5fae 100644 --- a/src/main/java/com/songoda/core/SongodaCore.java +++ b/src/main/java/com/songoda/core/SongodaCore.java @@ -276,7 +276,7 @@ public class SongodaCore { final String er = e.getMessage(); System.out.println("Connection with Songoda servers failed: " + (er.contains("URL") ? er.substring(0, er.indexOf("URL") + 3) : er)); } catch (ParseException e) { - System.out.println("Failed to parse json."); + System.out.println("Failed to parse json for " + plugin.getJavaPlugin().getName() + " update check"); } } diff --git a/src/main/java/com/songoda/core/configuration/Config.java b/src/main/java/com/songoda/core/configuration/Config.java index de48ac56..c17a56f8 100644 --- a/src/main/java/com/songoda/core/configuration/Config.java +++ b/src/main/java/com/songoda/core/configuration/Config.java @@ -409,7 +409,7 @@ public class Config extends ConfigSection { public void delaySave() { // save async even if no plugin or if plugin disabled - if (changed && saveTask == null) { + if (saveTask == null && (changed || hasNewDefaults())) { autosaveTimer = new Timer((plugin != null ? plugin.getName() + "-ConfigSave-" : "ConfigSave-") + getFile().getName()); autosaveTimer.schedule(saveTask = new SaveTask(), autosaveInterval * 1000L); } @@ -417,7 +417,7 @@ public class Config extends ConfigSection { public boolean saveChanges() { boolean saved = true; - if (changed) { + if (changed || hasNewDefaults()) { saved = save(); } if(saveTask != null) { @@ -430,6 +430,14 @@ public class Config extends ConfigSection { return saved; } + boolean hasNewDefaults() { + if (file != null && !file.exists()) return true; + for (String def : defaults.keySet()) { + if (!values.containsKey(def)) return true; + } + return false; + } + public boolean save() { if(saveTask != null) { //Close Threads