diff --git a/src/main/java/com/gmail/nossr50/config/HiddenConfig.java b/src/main/java/com/gmail/nossr50/config/HiddenConfig.java new file mode 100644 index 000000000..661e11711 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/HiddenConfig.java @@ -0,0 +1,44 @@ +package com.gmail.nossr50.config; + +import org.bukkit.configuration.file.YamlConfiguration; + +import com.gmail.nossr50.mcMMO; + +public class HiddenConfig extends ConfigLoader { + private static String fileName; + private static HiddenConfig instance; + private static YamlConfiguration config; + + private static boolean chunkletsEnabled; + + public HiddenConfig(mcMMO plugin, String fileName) { + super(plugin, fileName); + HiddenConfig.fileName = fileName; + } + + + public static HiddenConfig getInstance() { + if (instance == null) { + instance = new HiddenConfig(mcMMO.p, "hidden.yml"); + instance.load(); + } + + return instance; + } + + @Override + protected void load() { + if(plugin.isInJar(fileName)) loadKeys(); + } + + @Override + protected void loadKeys() { + config = YamlConfiguration.loadConfiguration(plugin.getResource(fileName)); + + chunkletsEnabled = config.getBoolean("Options.Chunklets", true); + } + + public boolean getChunkletsEnabled() { + return chunkletsEnabled; + } +} diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index d05a30b3d..9fa76b7bb 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -7,6 +7,7 @@ import com.gmail.nossr50.commands.mc.*; import com.gmail.nossr50.commands.party.*; import com.gmail.nossr50.commands.general.*; import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.config.TreasuresConfig; import com.gmail.nossr50.config.mods.CustomBlocksConfig; import com.gmail.nossr50.config.mods.CustomArmorConfig; @@ -74,6 +75,7 @@ public class mcMMO extends JavaPlugin { //Force the loading of config files Config configInstance = Config.getInstance(); TreasuresConfig.getInstance(); + HiddenConfig.getInstance(); if (configInstance.getToolModsEnabled()) { CustomToolsConfig.getInstance().load(); diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManagerFactory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManagerFactory.java index f3351831c..efe719d13 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManagerFactory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManagerFactory.java @@ -1,8 +1,15 @@ package com.gmail.nossr50.util.blockmeta; +import com.gmail.nossr50.config.HiddenConfig; + public class ChunkletManagerFactory { public static ChunkletManager getChunkletManager() { - // TODO: Add in loading from config what type of manager we want. - return new HashChunkletManager(); + HiddenConfig hConfig = HiddenConfig.getInstance(); + + if(hConfig.getChunkletsEnabled()) { + return new HashChunkletManager(); + } else { + return new NullChunkletManager(); + } } } diff --git a/src/main/resources/hidden.yml b/src/main/resources/hidden.yml new file mode 100644 index 000000000..55f954b8c --- /dev/null +++ b/src/main/resources/hidden.yml @@ -0,0 +1,7 @@ +# +# WARNING: THIS CONFIG IS FOR ADVANCED USERS ONLY. +# You will need to reset any values in this config every time you update mcMMO +### +Options: + # true to use Chunklets metadata store system, false to disable + Chunklets: true \ No newline at end of file