mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-27 12:35:12 +01:00
Merge branch 'development' into 'master'
2.0.4 See merge request Songoda/songodaupdater!7
This commit is contained in:
commit
8ba1fce011
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "SongodaCore"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "2.0.3"
|
||||
version: "2.0.4"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user