diff --git a/src/main/java/net/knarcraft/stargate/config/EconomyConfig.java b/src/main/java/net/knarcraft/stargate/config/EconomyConfig.java index 10cf01b..22ae241 100644 --- a/src/main/java/net/knarcraft/stargate/config/EconomyConfig.java +++ b/src/main/java/net/knarcraft/stargate/config/EconomyConfig.java @@ -6,13 +6,13 @@ import net.knarcraft.stargate.portal.property.gate.Gate; import net.knarcraft.stargate.utility.PermissionHelper; import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; -import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.ServicesManager; +import java.util.Map; import java.util.UUID; /** @@ -33,10 +33,10 @@ public final class EconomyConfig { /** * Instantiates a new economy config * - * @param newConfig
The file configuration to read values from
+ * @param configOptionsThe loaded config options to read
*/ - public EconomyConfig(FileConfiguration newConfig) { - loadEconomyConfig(newConfig); + public EconomyConfig(MapThe configuration containing the values to read
+ * @param configOptionsThe loaded config options to get values from
*/ - private void loadEconomyConfig(FileConfiguration newConfig) { - economyEnabled = newConfig.getBoolean("economy.useEconomy"); - setDefaultCreateCost(newConfig.getInt("economy.createCost")); - setDefaultDestroyCost(newConfig.getInt("economy.destroyCost")); - setDefaultUseCost(newConfig.getInt("economy.useCost")); - toOwner = newConfig.getBoolean("economy.toOwner"); - chargeFreeDestination = newConfig.getBoolean("economy.chargeFreeDestination"); - freeGatesGreen = newConfig.getBoolean("economy.freeGatesGreen"); + private void loadEconomyConfig(MapThe file configuration to read values from
+ * @param configOptionsThe loaded config options to use
*/ - public StargateGateConfig(FileConfiguration newConfig) { - loadGateConfig(newConfig); + public StargateGateConfig(MapMaximum number of gates for each network
*/ public int maxGatesEachNetwork() { - return maxGatesEachNetwork; + return (int) configOptions.get(ConfigOption.MAX_GATES_EACH_NETWORK); } /** @@ -68,7 +57,7 @@ public final class StargateGateConfig { * @returnWhether a portal's lastly used destination should be remembered
*/ public boolean rememberDestination() { - return rememberDestination; + return (boolean) configOptions.get(ConfigOption.REMEMBER_DESTINATION); } /** @@ -77,7 +66,7 @@ public final class StargateGateConfig { * @returnWhether vehicle teleportation should be handled
*/ public boolean handleVehicles() { - return handleVehicles; + return (boolean) configOptions.get(ConfigOption.HANDLE_VEHICLES); } /** @@ -89,7 +78,7 @@ public final class StargateGateConfig { * @returnWhether vehicles without passengers should be handled
*/ public boolean handleEmptyVehicles() { - return handleEmptyVehicles; + return (boolean) configOptions.get(ConfigOption.HANDLE_EMPTY_VEHICLES); } /** @@ -101,7 +90,7 @@ public final class StargateGateConfig { * @returnWhether vehicles with creatures should be handled
*/ public boolean handleCreatureTransportation() { - return handleCreatureTransportation; + return (boolean) configOptions.get(ConfigOption.HANDLE_CREATURE_TRANSPORTATION); } /** @@ -118,7 +107,7 @@ public final class StargateGateConfig { * @returnWhether non-empty vehicles without a player should be handled
*/ public boolean handleNonPlayerVehicles() { - return handleNonPlayerVehicles; + return (boolean) configOptions.get(ConfigOption.HANDLE_NON_PLAYER_VEHICLES); } /** @@ -127,7 +116,7 @@ public final class StargateGateConfig { * @returnWhether leashed creatures should be handled
*/ public boolean handleLeashedCreatures() { - return handleLeashedCreatures; + return (boolean) configOptions.get(ConfigOption.HANDLE_LEASHED_CREATURES); } /** @@ -136,7 +125,7 @@ public final class StargateGateConfig { * @returnWhether network destinations should be sorted
*/ public boolean sortNetworkDestinations() { - return sortNetworkDestinations; + return (boolean) configOptions.get(ConfigOption.SORT_NETWORK_DESTINATIONS); } /** @@ -145,7 +134,7 @@ public final class StargateGateConfig { * @returnWhether portal entrances should be protected
*/ public boolean protectEntrance() { - return protectEntrance; + return (boolean) configOptions.get(ConfigOption.PROTECT_ENTRANCE); } /** @@ -154,7 +143,7 @@ public final class StargateGateConfig { * @returnWhether bungee support is enabled
*/ public boolean enableBungee() { - return enableBungee; + return (boolean) configOptions.get(ConfigOption.ENABLE_BUNGEE); } /** @@ -163,7 +152,7 @@ public final class StargateGateConfig { * @returnWhether portals need to be verified
*/ public boolean verifyPortals() { - return verifyPortals; + return (boolean) configOptions.get(ConfigOption.VERIFY_PORTALS); } /** @@ -172,7 +161,7 @@ public final class StargateGateConfig { * @returnWhether portals should be destroyed by explosions
*/ public boolean destroyedByExplosion() { - return destroyExplosion; + return (boolean) configOptions.get(ConfigOption.DESTROYED_BY_EXPLOSION); } /** @@ -181,37 +170,16 @@ public final class StargateGateConfig { * @returnThe default portal network
*/ public String getDefaultPortalNetwork() { - return defaultGateNetwork; + return (String) configOptions.get(ConfigOption.DEFAULT_GATE_NETWORK); } /** * Loads all config values related to gates - * - * @param newConfigThe configuration containing the values to read
*/ - private void loadGateConfig(FileConfiguration newConfig) { - String defaultNetwork = newConfig.getString("gates.defaultGateNetwork"); - defaultGateNetwork = defaultNetwork != null ? defaultNetwork.trim() : null; - maxGatesEachNetwork = newConfig.getInt("gates.maxGatesEachNetwork"); - - //Functionality - handleVehicles = newConfig.getBoolean("gates.functionality.handleVehicles"); - handleEmptyVehicles = newConfig.getBoolean("gates.functionality.handleEmptyVehicles"); - handleCreatureTransportation = newConfig.getBoolean("gates.functionality.handleCreatureTransportation"); - handleNonPlayerVehicles = newConfig.getBoolean("gates.functionality.handleNonPlayerVehicles"); - handleLeashedCreatures = newConfig.getBoolean("gates.functionality.handleLeashedCreatures"); - enableBungee = newConfig.getBoolean("gates.functionality.enableBungee"); - - //Integrity - protectEntrance = newConfig.getBoolean("gates.integrity.protectEntrance"); - verifyPortals = newConfig.getBoolean("gates.integrity.verifyPortals"); - destroyExplosion = newConfig.getBoolean("gates.integrity.destroyedByExplosion"); - - //Cosmetic - sortNetworkDestinations = newConfig.getBoolean("gates.cosmetic.sortNetworkDestinations"); - rememberDestination = newConfig.getBoolean("gates.cosmetic.rememberDestination"); - loadSignColor(newConfig.getString("gates.cosmetic.mainSignColor"), - newConfig.getString("gates.cosmetic.highlightSignColor")); + private void loadGateConfig() { + //Load the sign colors + loadSignColor((String) configOptions.get(ConfigOption.MAIN_SIGN_COLOR), + (String) configOptions.get(ConfigOption.HIGHLIGHT_SIGN_COLOR)); } /**