From 0afc0d59a4a545d6ab5787188ccfc17419033528 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 17 May 2012 10:26:21 -0400 Subject: [PATCH] Config refactoring. --- ...oadTreasures.java => TreasuresConfig.java} | 10 +++---- ...ustomArmor.java => CustomArmorConfig.java} | 10 +++---- ...ustomTools.java => CustomToolsConfig.java} | 10 +++---- src/main/java/com/gmail/nossr50/mcMMO.java | 12 ++++----- .../nossr50/skills/gathering/Excavation.java | 16 ++++++------ .../nossr50/skills/gathering/Fishing.java | 12 ++++----- .../com/gmail/nossr50/skills/misc/Repair.java | 12 ++++----- .../com/gmail/nossr50/util/ItemChecks.java | 26 +++++++++---------- .../com/gmail/nossr50/util/ModChecks.java | 8 +++--- 9 files changed, 58 insertions(+), 58 deletions(-) rename src/main/java/com/gmail/nossr50/config/{LoadTreasures.java => TreasuresConfig.java} (95%) rename src/main/java/com/gmail/nossr50/config/mods/{LoadCustomArmor.java => CustomArmorConfig.java} (90%) rename src/main/java/com/gmail/nossr50/config/mods/{LoadCustomTools.java => CustomToolsConfig.java} (91%) diff --git a/src/main/java/com/gmail/nossr50/config/LoadTreasures.java b/src/main/java/com/gmail/nossr50/config/TreasuresConfig.java similarity index 95% rename from src/main/java/com/gmail/nossr50/config/LoadTreasures.java rename to src/main/java/com/gmail/nossr50/config/TreasuresConfig.java index 4777794c1..0dc758a89 100644 --- a/src/main/java/com/gmail/nossr50/config/LoadTreasures.java +++ b/src/main/java/com/gmail/nossr50/config/TreasuresConfig.java @@ -16,12 +16,12 @@ import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; import com.gmail.nossr50.datatypes.treasure.FishingTreasure; import com.gmail.nossr50.datatypes.treasure.Treasure; -public class LoadTreasures extends ConfigLoader{ - private static LoadTreasures instance; +public class TreasuresConfig extends ConfigLoader{ + private static TreasuresConfig instance; - public static LoadTreasures getInstance() { + public static TreasuresConfig getInstance() { if (instance == null) { - instance = new LoadTreasures(mcMMO.p); + instance = new TreasuresConfig(mcMMO.p); instance.load(); } @@ -41,7 +41,7 @@ public class LoadTreasures extends ConfigLoader{ public List fishingRewardsTier4 = new ArrayList(); public List fishingRewardsTier5 = new ArrayList(); - private LoadTreasures(mcMMO plugin) { + private TreasuresConfig(mcMMO plugin) { super(plugin, "treasures.yml"); config = plugin.getTreasuresConfig(); } diff --git a/src/main/java/com/gmail/nossr50/config/mods/LoadCustomArmor.java b/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java similarity index 90% rename from src/main/java/com/gmail/nossr50/config/mods/LoadCustomArmor.java rename to src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java index b72fa04fc..cb7600384 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/LoadCustomArmor.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java @@ -11,12 +11,12 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.mods.CustomItem; -public class LoadCustomArmor extends ModConfigLoader{ - private static LoadCustomArmor instance; +public class CustomArmorConfig extends ModConfigLoader{ + private static CustomArmorConfig instance; - public static LoadCustomArmor getInstance() { + public static CustomArmorConfig getInstance() { if (instance == null) { - instance = new LoadCustomArmor(mcMMO.p); + instance = new CustomArmorConfig(mcMMO.p); } return instance; @@ -30,7 +30,7 @@ public class LoadCustomArmor extends ModConfigLoader{ public List customIDs = new ArrayList(); public List customItems = new ArrayList(); - public LoadCustomArmor(mcMMO plugin) { + public CustomArmorConfig(mcMMO plugin) { super(plugin, "armor.yml"); config = plugin.getArmorConfig(); } diff --git a/src/main/java/com/gmail/nossr50/config/mods/LoadCustomTools.java b/src/main/java/com/gmail/nossr50/config/mods/CustomToolsConfig.java similarity index 91% rename from src/main/java/com/gmail/nossr50/config/mods/LoadCustomTools.java rename to src/main/java/com/gmail/nossr50/config/mods/CustomToolsConfig.java index cf423011c..35a1fc803 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/LoadCustomTools.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomToolsConfig.java @@ -12,12 +12,12 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.mods.CustomItem; import com.gmail.nossr50.datatypes.mods.CustomTool; -public class LoadCustomTools extends ModConfigLoader { - private static LoadCustomTools instance; +public class CustomToolsConfig extends ModConfigLoader { + private static CustomToolsConfig instance; - public static LoadCustomTools getInstance() { + public static CustomToolsConfig getInstance() { if (instance == null) { - instance = new LoadCustomTools(mcMMO.p); + instance = new CustomToolsConfig(mcMMO.p); } return instance; @@ -33,7 +33,7 @@ public class LoadCustomTools extends ModConfigLoader { public List customIDs = new ArrayList(); public List customItems = new ArrayList(); - private LoadCustomTools(mcMMO plugin) { + private CustomToolsConfig(mcMMO plugin) { super(plugin, "tools.yml"); config = plugin.getToolsConfig(); } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 29a49f67a..250ec12c9 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -7,10 +7,10 @@ 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.LoadTreasures; +import com.gmail.nossr50.config.TreasuresConfig; import com.gmail.nossr50.config.mods.CustomBlocksConfig; -import com.gmail.nossr50.config.mods.LoadCustomArmor; -import com.gmail.nossr50.config.mods.LoadCustomTools; +import com.gmail.nossr50.config.mods.CustomArmorConfig; +import com.gmail.nossr50.config.mods.CustomToolsConfig; import com.gmail.nossr50.runnables.*; import com.gmail.nossr50.util.Database; import com.gmail.nossr50.util.Leaderboard; @@ -73,14 +73,14 @@ public class mcMMO extends JavaPlugin { //Force the loading of config files Config configInstance = Config.getInstance(); - LoadTreasures.getInstance(); + TreasuresConfig.getInstance(); if (configInstance.getToolModsEnabled()) { - LoadCustomTools.getInstance().load(); + CustomToolsConfig.getInstance().load(); } if (configInstance.getArmorModsEnabled()) { - LoadCustomArmor.getInstance().load(); + CustomArmorConfig.getInstance().load(); } if (configInstance.getBlockModsEnabled()) { diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java b/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java index 29ea8341c..0e5fb465b 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java @@ -18,7 +18,7 @@ import com.gmail.nossr50.util.Skills; import com.gmail.nossr50.util.Users; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.LoadTreasures; +import com.gmail.nossr50.config.TreasuresConfig; import com.gmail.nossr50.config.mods.CustomBlocksConfig; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; @@ -59,31 +59,31 @@ public class Excavation { if (Permissions.getInstance().excavationTreasures(player)) { switch (type) { case DIRT: - treasures = LoadTreasures.getInstance().excavationFromDirt; + treasures = TreasuresConfig.getInstance().excavationFromDirt; break; case GRASS: - treasures = LoadTreasures.getInstance().excavationFromGrass; + treasures = TreasuresConfig.getInstance().excavationFromGrass; break; case SAND: - treasures = LoadTreasures.getInstance().excavationFromSand; + treasures = TreasuresConfig.getInstance().excavationFromSand; break; case GRAVEL: - treasures = LoadTreasures.getInstance().excavationFromGravel; + treasures = TreasuresConfig.getInstance().excavationFromGravel; break; case CLAY: - treasures = LoadTreasures.getInstance().excavationFromClay; + treasures = TreasuresConfig.getInstance().excavationFromClay; break; case MYCEL: - treasures = LoadTreasures.getInstance().excavationFromMycel; + treasures = TreasuresConfig.getInstance().excavationFromMycel; break; case SOUL_SAND: - treasures = LoadTreasures.getInstance().excavationFromSoulSand; + treasures = TreasuresConfig.getInstance().excavationFromSoulSand; break; default: diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java index dc2a5746c..6868f5fb9 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -18,7 +18,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.material.Wool; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.LoadTreasures; +import com.gmail.nossr50.config.TreasuresConfig; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.treasure.FishingTreasure; @@ -76,23 +76,23 @@ public class Fishing { switch (getFishingLootTier(PP)) { case 1: - rewards = LoadTreasures.getInstance().fishingRewardsTier1; + rewards = TreasuresConfig.getInstance().fishingRewardsTier1; break; case 2: - rewards = LoadTreasures.getInstance().fishingRewardsTier2; + rewards = TreasuresConfig.getInstance().fishingRewardsTier2; break; case 3: - rewards = LoadTreasures.getInstance().fishingRewardsTier3; + rewards = TreasuresConfig.getInstance().fishingRewardsTier3; break; case 4: - rewards = LoadTreasures.getInstance().fishingRewardsTier4; + rewards = TreasuresConfig.getInstance().fishingRewardsTier4; break; case 5: - rewards = LoadTreasures.getInstance().fishingRewardsTier5; + rewards = TreasuresConfig.getInstance().fishingRewardsTier5; break; default: diff --git a/src/main/java/com/gmail/nossr50/skills/misc/Repair.java b/src/main/java/com/gmail/nossr50/skills/misc/Repair.java index 908f48ed4..7e1018835 100644 --- a/src/main/java/com/gmail/nossr50/skills/misc/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/misc/Repair.java @@ -16,8 +16,8 @@ import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.mods.LoadCustomArmor; -import com.gmail.nossr50.config.mods.LoadCustomTools; +import com.gmail.nossr50.config.mods.CustomArmorConfig; +import com.gmail.nossr50.config.mods.CustomToolsConfig; import com.gmail.nossr50.spout.SpoutSounds; import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Misc; @@ -113,7 +113,7 @@ public class Repair { * REPAIR CUSTOM TOOLS */ else if (ItemChecks.isCustomTool(is) && permInstance.toolRepair(player)) { - LoadCustomTools toolsInstance = LoadCustomTools.getInstance(); + CustomToolsConfig toolsInstance = CustomToolsConfig.getInstance(); for (CustomItem tool : toolsInstance.customItems) { if (tool.getItemID() == is.getTypeId()) { @@ -136,7 +136,7 @@ public class Repair { * REPAIR CUSTOM ARMOR */ else if (ItemChecks.isCustomArmor(is) && permInstance.armorRepair(player)) { - LoadCustomArmor armorInstance = LoadCustomArmor.getInstance(); + CustomArmorConfig armorInstance = CustomArmorConfig.getInstance(); for (CustomItem armor : armorInstance.customItems) { if (armor.getItemID() == is.getTypeId()) { @@ -406,8 +406,8 @@ public class Repair { int materialsRequired = 0; int repairAmount = 0; - LoadCustomTools toolInstance = LoadCustomTools.getInstance(); - LoadCustomArmor armorInstance = LoadCustomArmor.getInstance(); + CustomToolsConfig toolInstance = CustomToolsConfig.getInstance(); + CustomArmorConfig armorInstance = CustomArmorConfig.getInstance(); if (ModChecks.getToolFromItemStack(is) != null) { for (CustomItem tool : toolInstance.customItems) { diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java index 4294ca505..228cfdeba 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ItemChecks.java @@ -3,8 +3,8 @@ package com.gmail.nossr50.util; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.config.mods.LoadCustomArmor; -import com.gmail.nossr50.config.mods.LoadCustomTools; +import com.gmail.nossr50.config.mods.CustomArmorConfig; +import com.gmail.nossr50.config.mods.CustomToolsConfig; public class ItemChecks { private static Config configInstance = Config.getInstance(); @@ -27,7 +27,7 @@ public class ItemChecks { return true; default: - if (customToolsEnabled && LoadCustomTools.getInstance().customSwordIDs.contains(is.getTypeId())) { + if (customToolsEnabled && CustomToolsConfig.getInstance().customSwordIDs.contains(is.getTypeId())) { return true; } else { @@ -52,7 +52,7 @@ public class ItemChecks { return true; default: - if (customToolsEnabled && LoadCustomTools.getInstance().customHoeIDs.contains(is.getTypeId())) { + if (customToolsEnabled && CustomToolsConfig.getInstance().customHoeIDs.contains(is.getTypeId())) { return true; } else { @@ -77,7 +77,7 @@ public class ItemChecks { return true; default: - if (customToolsEnabled && LoadCustomTools.getInstance().customShovelIDs.contains(is.getTypeId())) { + if (customToolsEnabled && CustomToolsConfig.getInstance().customShovelIDs.contains(is.getTypeId())) { return true; } else { @@ -102,7 +102,7 @@ public class ItemChecks { return true; default: - if (customToolsEnabled && LoadCustomTools.getInstance().customAxeIDs.contains(is.getTypeId())) { + if (customToolsEnabled && CustomToolsConfig.getInstance().customAxeIDs.contains(is.getTypeId())) { return true; } else { @@ -127,7 +127,7 @@ public class ItemChecks { return true; default: - if (customToolsEnabled && LoadCustomTools.getInstance().customPickaxeIDs.contains(is.getTypeId())) { + if (customToolsEnabled && CustomToolsConfig.getInstance().customPickaxeIDs.contains(is.getTypeId())) { return true; } else { @@ -151,7 +151,7 @@ public class ItemChecks { return true; default: - if (customArmorEnabled && LoadCustomArmor.getInstance().customHelmetIDs.contains(is.getTypeId())) { + if (customArmorEnabled && CustomArmorConfig.getInstance().customHelmetIDs.contains(is.getTypeId())) { return true; } else { @@ -175,7 +175,7 @@ public class ItemChecks { return true; default: - if (customArmorEnabled && LoadCustomArmor.getInstance().customChestplateIDs.contains(is.getTypeId())) { + if (customArmorEnabled && CustomArmorConfig.getInstance().customChestplateIDs.contains(is.getTypeId())) { return true; } else { @@ -199,7 +199,7 @@ public class ItemChecks { return true; default: - if (customArmorEnabled && LoadCustomArmor.getInstance().customLeggingIDs.contains(is.getTypeId())) { + if (customArmorEnabled && CustomArmorConfig.getInstance().customLeggingIDs.contains(is.getTypeId())) { return true; } else { @@ -223,7 +223,7 @@ public class ItemChecks { return true; default: - if (customArmorEnabled && LoadCustomArmor.getInstance().customBootIDs.contains(is.getTypeId())) { + if (customArmorEnabled && CustomArmorConfig.getInstance().customBootIDs.contains(is.getTypeId())) { return true; } else { @@ -249,7 +249,7 @@ public class ItemChecks { * @return true if the item is a custom tool, false otherwise */ public static boolean isCustomArmor(ItemStack is) { - if (customArmorEnabled && LoadCustomArmor.getInstance().customIDs.contains(is.getTypeId())) { + if (customArmorEnabled && CustomArmorConfig.getInstance().customIDs.contains(is.getTypeId())) { return true; } else { @@ -350,7 +350,7 @@ public class ItemChecks { * @return true if the item is a custom tool, false otherwise */ public static boolean isCustomTool(ItemStack is) { - if (customToolsEnabled && LoadCustomTools.getInstance().customIDs.contains(is.getTypeId())) { + if (customToolsEnabled && CustomToolsConfig.getInstance().customIDs.contains(is.getTypeId())) { return true; } else { diff --git a/src/main/java/com/gmail/nossr50/util/ModChecks.java b/src/main/java/com/gmail/nossr50/util/ModChecks.java index 0337d925c..9c2534e21 100644 --- a/src/main/java/com/gmail/nossr50/util/ModChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ModChecks.java @@ -4,15 +4,15 @@ import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.mods.CustomBlocksConfig; -import com.gmail.nossr50.config.mods.LoadCustomArmor; -import com.gmail.nossr50.config.mods.LoadCustomTools; +import com.gmail.nossr50.config.mods.CustomArmorConfig; +import com.gmail.nossr50.config.mods.CustomToolsConfig; import com.gmail.nossr50.datatypes.mods.CustomBlock; import com.gmail.nossr50.datatypes.mods.CustomItem; import com.gmail.nossr50.datatypes.mods.CustomTool; public class ModChecks { - private static LoadCustomTools toolInstance = LoadCustomTools.getInstance(); - private static LoadCustomArmor armorInstance = LoadCustomArmor.getInstance(); + private static CustomToolsConfig toolInstance = CustomToolsConfig.getInstance(); + private static CustomArmorConfig armorInstance = CustomArmorConfig.getInstance(); private static CustomBlocksConfig blocksInstance = CustomBlocksConfig.getInstance(); /**