diff options
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java')
-rw-r--r-- | src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java | 169 |
1 files changed, 93 insertions, 76 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java index 83b6ceb..ee9d88d 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Config.java @@ -1,15 +1,10 @@ package net.tylermurphy.hideAndSeek.configuration; -import java.util.Map; -import java.util.Map.Entry; - -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.util.Vector; -import net.tylermurphy.hideAndSeek.Main; - public class Config { + + private static ConfigManager manager; public static String messagePrefix, @@ -21,7 +16,8 @@ public class Config { warningPrefix, spawnWorld, exitWorld, - lobbyWorld; + lobbyWorld, + local; public static Vector spawnPosition, @@ -33,94 +29,115 @@ public class Config { nametagsVisible, permissionsRequired, announceMessagesToNonPlayers, - worldborderEnabled; + worldborderEnabled, + tauntEnabled, + tauntCountdown, + tauntLast, + glowEnabled, + glowStackable, + pvpEnabled, + autoJoin, + teleportToExit; public static int minPlayers, worldborderSize, worldborderDelay, currentWorldborderSize, - gameLength; - - public static FileConfiguration getConfig() { - return Main.plugin.getConfig(); - } - - public static void saveConfig() { - Main.plugin.saveConfig(); - } + gameLength, + saveMinX, + saveMinZ, + saveMaxX, + saveMaxZ, + tauntDelay, + glowLength; public static void loadConfig() { - - Main.plugin.reloadConfig(); - + + manager = new ConfigManager("config.yml"); + manager.saveConfig(); + //Spawn spawnPosition = new Vector( - getConfig().getDouble("spawns.game.x"), - Math.max(0,Math.min(255,getConfig().getDouble("spawns.game.y"))), - getConfig().getDouble("spawns.game.z") - ); - spawnWorld = getConfig().getString("spawns.game.world"); - + manager.getDouble("spawns.game.x"), + Math.max(0, Math.min(255, manager.getDouble("spawns.game.y"))), + manager.getDouble("spawns.game.z") + ); + spawnWorld = manager.getString("spawns.game.world"); + ///Lobby lobbyPosition = new Vector( - getConfig().getDouble("spawns.lobby.x"), - Math.max(0,Math.min(255,getConfig().getDouble("spawns.lobby.y"))), - getConfig().getDouble("spawns.lobby.z") - ); - lobbyWorld = getConfig().getString("spawns.lobby.world"); - - announceMessagesToNonPlayers = getConfig().getBoolean("announceMessagesToNonPlayers"); - + manager.getDouble("spawns.lobby.x"), + Math.max(0, Math.min(255, manager.getDouble("spawns.lobby.y"))), + manager.getDouble("spawns.lobby.z") + ); + lobbyWorld = manager.getString("spawns.lobby.world"); + + announceMessagesToNonPlayers = manager.getBoolean("announceMessagesToNonPlayers"); + exitPosition = new Vector( - getConfig().getDouble("spawns.exit.x"), - Math.max(0,Math.min(255,getConfig().getDouble("spawns.exit.y"))), - getConfig().getDouble("spawns.exit.z") - ); - exitWorld = getConfig().getString("spawns.exit.world"); - + manager.getDouble("spawns.exit.x"), + Math.max(0, Math.min(255, manager.getDouble("spawns.exit.y"))), + manager.getDouble("spawns.exit.z") + ); + exitWorld = manager.getString("spawns.exit.world"); + //World border worldborderPosition = new Vector( - getConfig().getInt("worldBorder.x"), - 0, - getConfig().getInt("worldBorder.z") - ); - worldborderSize = Math.max(100,getConfig().getInt("worldBorder.size")); - worldborderDelay = Math.max(1,getConfig().getInt("worldBorder.delay")); - worldborderEnabled = getConfig().getBoolean("worldBorder.enabled"); - + manager.getInt("worldBorder.x"), + 0, + manager.getInt("worldBorder.z") + ); + worldborderSize = Math.max(100, manager.getInt("worldBorder.size")); + worldborderDelay = Math.max(1, manager.getInt("worldBorder.delay")); + worldborderEnabled = manager.getBoolean("worldBorder.enabled"); + //Prefix char SYMBOLE = '\u00A7'; - String SYMBOLE_STRING = new String(new char[] {SYMBOLE}); - - messagePrefix = getConfig().getString("prefix.default").replace("&", SYMBOLE_STRING); - errorPrefix = getConfig().getString("prefix.error").replace("&", SYMBOLE_STRING); - tauntPrefix = getConfig().getString("prefix.taunt").replace("&", SYMBOLE_STRING); - worldborderPrefix = getConfig().getString("prefix.border").replace("&", SYMBOLE_STRING); - abortPrefix = getConfig().getString("prefix.abort").replace("&", SYMBOLE_STRING); - gameoverPrefix = getConfig().getString("prefix.gameover").replace("&", SYMBOLE_STRING); - warningPrefix = getConfig().getString("prefix.warning").replace("&", SYMBOLE_STRING); - + String SYMBOLE_STRING = String.valueOf(SYMBOLE); + + messagePrefix = manager.getString("prefix.default").replace("&", SYMBOLE_STRING); + errorPrefix = manager.getString("prefix.error").replace("&", SYMBOLE_STRING); + tauntPrefix = manager.getString("prefix.taunt").replace("&", SYMBOLE_STRING); + worldborderPrefix = manager.getString("prefix.border").replace("&", SYMBOLE_STRING); + abortPrefix = manager.getString("prefix.abort").replace("&", SYMBOLE_STRING); + gameoverPrefix = manager.getString("prefix.gameover").replace("&", SYMBOLE_STRING); + warningPrefix = manager.getString("prefix.warning").replace("&", SYMBOLE_STRING); + + //Map Bounds + saveMinX = manager.getInt("bounds.min.x"); + saveMinZ = manager.getInt("bounds.min.z"); + saveMaxX = manager.getInt("bounds.max.x"); + saveMaxZ = manager.getInt("bounds.max.z"); + + //Taunt + tauntEnabled = manager.getBoolean("taunt.enabled"); + tauntCountdown = manager.getBoolean("taunt.showCountdown"); + tauntDelay = Math.max(60,manager.getInt("taunt.delay")); + tauntLast = manager.getBoolean("taunt.whenLastPerson"); + + //Glow + glowLength = Math.max(1,manager.getInt("glow.time")); + glowStackable = manager.getBoolean("glow.stackable"); + glowEnabled = manager.getBoolean("glow.enabled"); + //Other - nametagsVisible = getConfig().getBoolean("nametagsVisible"); - permissionsRequired = getConfig().getBoolean("permissionsRequired"); - minPlayers = Math.max(2,getConfig().getInt("minPlayers")); - gameLength = getConfig().getInt("gameLength"); - - getConfig().options().copyDefaults(true); - saveConfig(); - + nametagsVisible = manager.getBoolean("nametagsVisible"); + permissionsRequired = manager.getBoolean("permissionsRequired"); + minPlayers = Math.max(2, manager.getInt("minPlayers")); + gameLength = manager.getInt("gameLength"); + pvpEnabled = manager.getBoolean("pvp"); + autoJoin = manager.getBoolean("autoJoin"); + teleportToExit = manager.getBoolean("teleportToExit"); + local = manager.getString("local"); } - public static void addToSection(String sectionName, Map<String,Object> values) { - ConfigurationSection section = getConfig().getConfigurationSection(sectionName); - if(section == null) section = getConfig().createSection(sectionName); - Map<String,Object> sectionValues = section.getValues(true); - for(Entry<String, Object> entry : values.entrySet()) { - sectionValues.put(entry.getKey(), entry.getValue()); - } - getConfig().createSection(sectionName, sectionValues); - saveConfig(); + public static void addToConfig(String path, Object value) { + manager.set(path, value); + } + + public static void saveConfig() { + manager.saveConfig(); } }
\ No newline at end of file |