mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-23 08:31:34 +01:00
Uses a single config object instead of a new one every save.
Required to avoid concurrent async saves clashing.
This commit is contained in:
parent
38248bad29
commit
0f16d58ee7
@ -86,6 +86,8 @@ public class BentoBox extends JavaPlugin {
|
||||
@Nullable
|
||||
private BStats metrics;
|
||||
|
||||
private Config<Settings> configObject;
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
if (!ServerCompatibility.getInstance().checkCompatibility().isCanLaunch()) {
|
||||
@ -338,7 +340,8 @@ public class BentoBox extends JavaPlugin {
|
||||
public boolean loadSettings() {
|
||||
log("Loading Settings from config.yml...");
|
||||
// Load settings from config.yml. This will check if there are any issues with it too.
|
||||
settings = new Config<>(this, Settings.class).loadConfigObject();
|
||||
if (configObject == null) configObject = new Config<>(this, Settings.class);
|
||||
settings = configObject.loadConfigObject();
|
||||
if (settings == null) {
|
||||
// Settings did not load correctly. Disable plugin.
|
||||
logError("Settings did not load correctly - disabling plugin - please check config.yml");
|
||||
@ -350,7 +353,7 @@ public class BentoBox extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void saveConfig() {
|
||||
if (settings != null) new Config<>(this, Settings.class).saveConfigObject(settings);
|
||||
if (settings != null) configObject.saveConfigObject(settings);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user