Added holograms to config and fixed storage system.

This commit is contained in:
songoda 2019-09-20 11:25:25 -04:00
parent 604f4c1e6e
commit c18eddac22
4 changed files with 16 additions and 5 deletions

View File

@ -49,6 +49,7 @@ public class EpicFurnaces extends SongodaPlugin {
private final Config furnaceRecipeFile = new Config(this, "Furnace Recipes.yml");
private final Config levelsFile = new Config(this, "levels.yml");
private final Config dataFile = new Config(this, "data.yml");
private final GuiManager guiManager = new GuiManager(this);
private LevelManager levelManager;
@ -90,8 +91,10 @@ public class EpicFurnaces extends SongodaPlugin {
Settings.setupConfig();
this.setLocale(Settings.LANGUGE_MODE.getString(), false);
// Set economy preference
// Set Economy & Hologram preference
EconomyManager.getManager().setPreferredHook(Settings.ECONOMY_PLUGIN.getString());
HologramManager.getManager().setPreferredHook(Settings.HOLOGRAM_PLUGIN.getString());
// Register commands
this.commandManager = new CommandManager(this);
@ -111,6 +114,7 @@ public class EpicFurnaces extends SongodaPlugin {
this.blacklistHandler = new BlacklistHandler();
// Load from file
dataFile.load();
this.storage = new StorageYaml(this);
loadFromFile();

View File

@ -4,6 +4,7 @@ import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.configuration.Config;
import com.songoda.core.configuration.ConfigSetting;
import com.songoda.core.hooks.EconomyManager;
import com.songoda.core.hooks.HologramManager;
import com.songoda.epicfurnaces.EpicFurnaces;
import java.util.stream.Collectors;
@ -31,6 +32,12 @@ public class Settings {
public static final ConfigSetting FURNACE_ITEM = new ConfigSetting(config, "Main.Remember Furnace Item Levels", true,
"Should furnace levels be remembered when broken?");
public static final ConfigSetting HOLOGRAM_PLUGIN = new ConfigSetting(config, "Main.Hologram",
HologramManager.getHolograms() == null ? "HolographicDisplays" : HologramManager.getHolograms().getName(),
"Which hologram plugin should be used?",
"You can choose from \"" + HologramManager.getManager().getRegisteredPlugins().stream().collect(Collectors.joining(", ")) + "\".");
public static final ConfigSetting HOLOGRAMS = new ConfigSetting(config, "Main.Furnaces Have Holograms", true);
public static final ConfigSetting REDSTONE_DEACTIVATES = new ConfigSetting(config, "Main.Redstone Deactivates Furnaces", true);

View File

@ -11,9 +11,13 @@ 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);

View File

@ -13,14 +13,11 @@ 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
@ -66,7 +63,6 @@ public class StorageYaml extends Storage {
@Override
public void doSave() {
toSave.clear();
this.updateData(plugin);
if (lastSave == null)