mirror of
https://github.com/songoda/EpicFurnaces.git
synced 2024-12-03 15:23:22 +01:00
fix overwriting data with previous state
This commit is contained in:
parent
09216ac604
commit
fd03365d97
@ -47,7 +47,6 @@ public class EpicFurnaces extends SongodaPlugin {
|
||||
|
||||
private static EpicFurnaces INSTANCE;
|
||||
|
||||
private final Config dataConfig = new Config(this, "data.yml");
|
||||
private final Config furnaceRecipeFile = new Config(this, "Furnace Recipes.yml");
|
||||
private final Config levelsFile = new Config(this, "levels.yml");
|
||||
|
||||
@ -105,8 +104,6 @@ public class EpicFurnaces extends SongodaPlugin {
|
||||
new CommandSettings(this, guiManager)
|
||||
);
|
||||
|
||||
dataConfig.load();
|
||||
|
||||
loadLevelManager();
|
||||
|
||||
this.furnaceManager = new FurnaceManager();
|
||||
@ -114,9 +111,8 @@ public class EpicFurnaces extends SongodaPlugin {
|
||||
this.boostManager = new BoostManager();
|
||||
this.blacklistHandler = new BlacklistHandler();
|
||||
|
||||
this.checkStorage();
|
||||
|
||||
// Load from file
|
||||
this.storage = new StorageYaml(this);
|
||||
loadFromFile();
|
||||
|
||||
setupRecipies();
|
||||
@ -300,16 +296,10 @@ public class EpicFurnaces extends SongodaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkStorage() {
|
||||
this.storage = new StorageYaml(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Saves registered furnaces to file.
|
||||
*/
|
||||
private void saveToFile() {
|
||||
checkStorage();
|
||||
|
||||
storage.doSave();
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,9 @@ import java.util.List;
|
||||
public abstract class Storage {
|
||||
|
||||
protected final EpicFurnaces plugin;
|
||||
protected final Config dataFile;
|
||||
|
||||
public Storage(EpicFurnaces plugin) {
|
||||
this.plugin = plugin;
|
||||
this.dataFile = new Config(plugin, "data.yml");
|
||||
this.dataFile.load();
|
||||
}
|
||||
|
||||
public abstract boolean containsGroup(String group);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.epicfurnaces.storage.types;
|
||||
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.storage.Storage;
|
||||
import com.songoda.epicfurnaces.storage.StorageItem;
|
||||
@ -12,11 +13,14 @@ import java.util.*;
|
||||
|
||||
public class StorageYaml extends Storage {
|
||||
|
||||
protected final Config dataFile;
|
||||
private final Map<String, Object> toSave = new HashMap<>();
|
||||
private Map<String, Object> lastSave = null;
|
||||
|
||||
public StorageYaml(EpicFurnaces plugin) {
|
||||
super(plugin);
|
||||
this.dataFile = new Config(plugin, "data.yml");
|
||||
this.dataFile.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,6 +66,7 @@ public class StorageYaml extends Storage {
|
||||
|
||||
@Override
|
||||
public void doSave() {
|
||||
toSave.clear();
|
||||
this.updateData(plugin);
|
||||
|
||||
if (lastSave == null)
|
||||
|
Loading…
Reference in New Issue
Block a user