From da5fab855886a02fe4f94364e8a437f9d0d601a2 Mon Sep 17 00:00:00 2001 From: BONNe Date: Fri, 8 May 2020 10:20:44 +0300 Subject: [PATCH] Remove settings saving on addon disabling. Settings are saved on each Settings GUI building. --- .../java/world/bentobox/challenges/ChallengesAddon.java | 7 +++++++ .../bentobox/challenges/panel/admin/EditSettingsGUI.java | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/world/bentobox/challenges/ChallengesAddon.java b/src/main/java/world/bentobox/challenges/ChallengesAddon.java index fa38084..69daafa 100644 --- a/src/main/java/world/bentobox/challenges/ChallengesAddon.java +++ b/src/main/java/world/bentobox/challenges/ChallengesAddon.java @@ -286,7 +286,14 @@ public class ChallengesAddon extends Addon { if (this.hooked) { this.challengesManager.save(); } + } + + /** + * This method saves addon settings into file. + */ + public void saveSettings() + { if (this.settings != null) { new Config<>(this, Settings.class).saveConfigObject(this.settings); diff --git a/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java index 40abf68..c808dac 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/EditSettingsGUI.java @@ -124,6 +124,10 @@ public class EditSettingsGUI extends CommonGUI // Return Button panelBuilder.item(44, this.returnButton); + // Save Settings every time this GUI is created. It will avoid issues with + // Overwritten setting after server stop. + this.addon.saveSettings(); + panelBuilder.build(); }