Use common object for settings load/save

Config saving is now async so concurrent config objects should not be
used.
This commit is contained in:
tastybento 2019-08-30 13:08:44 -07:00
parent 07574dadfd
commit 6b51620028
2 changed files with 9 additions and 3 deletions

View File

@ -50,7 +50,7 @@
<!-- Revision variable removes warning about dynamic version --> <!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision> <revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. --> <!-- This allows to change between versions and snapshots. -->
<build.version>1.6.0</build.version> <build.version>1.6.1</build.version>
<build.number>-LOCAL</build.number> <build.number>-LOCAL</build.number>
</properties> </properties>

View File

@ -20,6 +20,7 @@ import world.bentobox.caveblock.listeners.CustomHeightLimitations;
public class CaveBlock extends GameModeAddon public class CaveBlock extends GameModeAddon
{ {
/** /**
* Executes code when loading the addon. This is called before {@link #onEnable()}. This should preferably * Executes code when loading the addon. This is called before {@link #onEnable()}. This should preferably
* be used to setup configuration and worlds. * be used to setup configuration and worlds.
@ -84,7 +85,7 @@ public class CaveBlock extends GameModeAddon
*/ */
private void loadSettings() private void loadSettings()
{ {
this.settings = new Config<>(this, Settings.class).loadConfigObject(); this.settings = settingsConfig.loadConfigObject();
if (this.settings == null) if (this.settings == null)
{ {
@ -217,7 +218,7 @@ public class CaveBlock extends GameModeAddon
{ {
if (this.settings != null) if (this.settings != null)
{ {
new Config<>(this, Settings.class).saveConfigObject(this.settings); settingsConfig.saveConfigObject(this.settings);
} }
} }
@ -226,6 +227,10 @@ public class CaveBlock extends GameModeAddon
// Section: Variables // Section: Variables
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
/**
* Config object
*/
private final Config<Settings> settingsConfig = new Config<>(this, Settings.class);
/** /**
* This stores CaveBlock addon settings. * This stores CaveBlock addon settings.
@ -264,4 +269,5 @@ public class CaveBlock extends GameModeAddon
*/ */
private static final String THE_END = "_the_end"; private static final String THE_END = "_the_end";
} }