Merge branch 'development' into 'master'

2.0.4

See merge request Songoda/songodaupdater!7
This commit is contained in:
Jacob Scott 2019-09-03 23:30:16 +00:00
commit 8ba1fce011
3 changed files with 12 additions and 4 deletions

View File

@ -4,7 +4,7 @@ stages:
variables:
name: "SongodaCore"
path: "/builds/$CI_PROJECT_PATH"
version: "2.0.3"
version: "2.0.4"
build:
stage: build

View File

@ -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");
}
}

View File

@ -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