mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Hidden config and use of NullChunkletManager
ChunkletManagerFactory now produces NullChunkletManagers if Chunklets are disabeld in the hidden.yml
This commit is contained in:
parent
2936823d03
commit
01006ed76d
44
src/main/java/com/gmail/nossr50/config/HiddenConfig.java
Normal file
44
src/main/java/com/gmail/nossr50/config/HiddenConfig.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
@ -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.
|
||||
HiddenConfig hConfig = HiddenConfig.getInstance();
|
||||
|
||||
if(hConfig.getChunkletsEnabled()) {
|
||||
return new HashChunkletManager();
|
||||
} else {
|
||||
return new NullChunkletManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
7
src/main/resources/hidden.yml
Normal file
7
src/main/resources/hidden.yml
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user