From acf2bf362fccdcc73cba1a00ec17c443fbb95016 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 16 Feb 2019 16:11:55 -0800 Subject: [PATCH] Refactoring the oopsies --- .../nossr50/commands/skills/FishingCommand.java | 14 +++++++------- .../datatypes/skills/alchemy/AlchemyPotion.java | 2 +- .../com/gmail/nossr50/listeners/BlockListener.java | 2 +- src/main/java/com/gmail/nossr50/mcMMO.java | 8 ++++---- .../runnables/database/UUIDUpdateAsyncTask.java | 6 +++--- .../nossr50/skills/alchemy/AlchemyManager.java | 2 +- .../skills/alchemy/AlchemyPotionBrewer.java | 8 ++++---- .../nossr50/skills/excavation/Excavation.java | 4 ++-- .../com/gmail/nossr50/skills/fishing/Fishing.java | 4 ++-- .../nossr50/skills/fishing/FishingManager.java | 12 ++++++------ .../nossr50/skills/herbalism/HerbalismManager.java | 4 ++-- .../util/blockmeta/ChunkletManagerFactory.java | 2 +- .../blockmeta/chunkmeta/ChunkManagerFactory.java | 2 +- .../conversion/BlockStoreConversionMain.java | 4 ++-- .../conversion/BlockStoreConversionXDirectory.java | 4 ++-- .../com/gmail/nossr50/util/skills/SkillUtils.java | 4 ++-- .../gmail/nossr50/util/sounds/SoundManager.java | 12 ++++++------ 17 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index bd69b458c..b69a0faf4 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -56,19 +56,19 @@ public class FishingCommand extends SkillCommand { lootTier = fishingManager.getLootTier(); // Item drop rates - commonTreasure = percent.format(TreasureMainConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0); - uncommonTreasure = percent.format(TreasureMainConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0); - rareTreasure = percent.format(TreasureMainConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0); - epicTreasure = percent.format(TreasureMainConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0); - legendaryTreasure = percent.format(TreasureMainConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0); - recordTreasure = percent.format(TreasureMainConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0); + commonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0); + uncommonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0); + rareTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0); + epicTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0); + legendaryTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0); + recordTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0); // Magic hunter drop rates double totalEnchantChance = 0; for (Rarity rarity : Rarity.values()) { if (rarity != Rarity.RECORD) { - totalEnchantChance += TreasureMainConfig.getInstance().getEnchantmentDropRate(lootTier, rarity); + totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java b/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java index cea784b81..7f49c9db3 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java @@ -122,7 +122,7 @@ public class AlchemyPotion { if (!children.isEmpty()) { for (Entry child : children.entrySet()) { if (ingredient.isSimilar(child.getKey())) { - return PotionMainConfig.getInstance().getPotion(child.getValue()); + return PotionConfig.getInstance().getPotion(child.getValue()); } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index ada3f0e30..61af32fd4 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -611,7 +611,7 @@ public class BlockListener implements Listener { } public void cleanupAbilityTools(Player player, McMMOPlayer mcMMOPlayer, BlockState blockState, ItemStack heldItem) { - if (HiddenMainConfig.getInstance().useEnchantmentBuffs()) { + if (HiddenConfig.getInstance().useEnchantmentBuffs()) { if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) { SkillUtils.removeAbilityBuff(heldItem); } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 4890e01f4..4443c49c2 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -420,12 +420,12 @@ public class mcMMO extends JavaPlugin { // Force the loading of config files - TreasureMainConfig.getInstance(); - HiddenMainConfig.getInstance(); + TreasureConfig.getInstance(); + HiddenConfig.getInstance(); AdvancedConfig.getInstance(); - PotionMainConfig.getInstance(); + PotionConfig.getInstance(); CoreSkillsMainConfig.getInstance(); - SoundMainConfig.getInstance(); + SoundConfig.getInstance(); RankConfig.getInstance(); new ChildConfig(); diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java index dd266ca56..10c87bb7b 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java @@ -15,9 +15,9 @@ import java.util.logging.Level; public class UUIDUpdateAsyncTask extends BukkitRunnable { private mcMMO plugin; - private static final int MAX_LOOKUP = Math.max(HiddenMainConfig.getInstance().getUUIDConvertAmount(), 100); - private static final int RATE_LIMIT = HiddenMainConfig.getInstance().getMojangRateLimit(); - private static final long LIMIT_PERIOD = HiddenMainConfig.getInstance().getMojangLimitPeriod(); + private static final int MAX_LOOKUP = Math.max(HiddenConfig.getInstance().getUUIDConvertAmount(), 100); + private static final int RATE_LIMIT = HiddenConfig.getInstance().getMojangRateLimit(); + private static final long LIMIT_PERIOD = HiddenConfig.getInstance().getMojangLimitPeriod(); private static final int BATCH_SIZE = MAX_LOOKUP * 3; private List userNames; diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java index c4ce49206..17e7731d6 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java @@ -25,7 +25,7 @@ public class AlchemyManager extends SkillManager { } public List getIngredients() { - return PotionMainConfig.getInstance().getIngredients(getTier()); + return PotionConfig.getInstance().getIngredients(getTier()); } public String getIngredientList() { diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java index e9ac85e36..ea78c6dc5 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -34,7 +34,7 @@ public final class AlchemyPotionBrewer { continue; } - if (getChildPotion(PotionMainConfig.getInstance().getPotion(contents[i]), contents[Alchemy.INGREDIENT_SLOT]) != null) { + if (getChildPotion(PotionConfig.getInstance().getPotion(contents[i]), contents[Alchemy.INGREDIENT_SLOT]) != null) { return true; } } @@ -92,7 +92,7 @@ public final class AlchemyPotionBrewer { } private static List getValidIngredients(Player player) { - return PotionMainConfig.getInstance().getIngredients((player == null || !Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier()); + return PotionConfig.getInstance().getIngredients((player == null || !Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS)) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier()); } public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) { @@ -112,11 +112,11 @@ public final class AlchemyPotionBrewer { for (int i = 0; i < 3; i++) { ItemStack item = inventory.getItem(i); - if (isEmpty(item) || item.getType() == Material.GLASS_BOTTLE || !PotionMainConfig.getInstance().isValidPotion(item)) { + if (isEmpty(item) || item.getType() == Material.GLASS_BOTTLE || !PotionConfig.getInstance().isValidPotion(item)) { continue; } - AlchemyPotion input = PotionMainConfig.getInstance().getPotion(item); + AlchemyPotion input = PotionConfig.getInstance().getPotion(item); AlchemyPotion output = input.getChild(ingredient); inputList.add(input); diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java index 06848715e..83572f678 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java @@ -18,8 +18,8 @@ public class Excavation { */ protected static List getTreasures(BlockState blockState) { String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData()); - if (TreasureMainConfig.getInstance().excavationMap.containsKey(friendly)) - return TreasureMainConfig.getInstance().excavationMap.get(friendly); + if (TreasureConfig.getInstance().excavationMap.containsKey(friendly)) + return TreasureConfig.getInstance().excavationMap.get(friendly); return new ArrayList(); } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index be9896fc1..24c092aef 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -30,8 +30,8 @@ public final class Fishing { * @return possibleDrops List of ItemStack that can be dropped */ protected static List findPossibleDrops(LivingEntity target) { - if (TreasureMainConfig.getInstance().shakeMap.containsKey(target.getType())) - return TreasureMainConfig.getInstance().shakeMap.get(target.getType()); + if (TreasureConfig.getInstance().shakeMap.containsKey(target.getType())) + return TreasureConfig.getInstance().shakeMap.get(target.getType()); return null; } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 1c00b9d7c..a8cc64d28 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -367,7 +367,7 @@ public class FishingManager extends SkillManager { break; case BEDROCK: - if (TreasureMainConfig.getInstance().getInventoryStealEnabled()) { + if (TreasureConfig.getInstance().getInventoryStealEnabled()) { PlayerInventory inventory = targetPlayer.getInventory(); int length = inventory.getContents().length; int slot = Misc.getRandom().nextInt(length); @@ -377,7 +377,7 @@ public class FishingManager extends SkillManager { break; } - if (TreasureMainConfig.getInstance().getInventoryStealStacks()) { + if (TreasureConfig.getInstance().getInventoryStealStacks()) { inventory.setItem(slot, null); } else { @@ -445,7 +445,7 @@ public class FishingManager extends SkillManager { FishingTreasure treasure = null; for (Rarity rarity : Rarity.values()) { - double dropRate = TreasureMainConfig.getInstance().getItemDropRate(getLootTier(), rarity); + double dropRate = TreasureConfig.getInstance().getItemDropRate(getLootTier(), rarity); if (diceRoll <= dropRate) { /*if (rarity == Rarity.TRAP) { @@ -453,7 +453,7 @@ public class FishingManager extends SkillManager { break; }*/ - List fishingTreasures = TreasureMainConfig.getInstance().fishingRewards.get(rarity); + List fishingTreasures = TreasureConfig.getInstance().fishingRewards.get(rarity); if (fishingTreasures.isEmpty()) { return null; @@ -504,7 +504,7 @@ public class FishingManager extends SkillManager { continue; } - double dropRate = TreasureMainConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity); + double dropRate = TreasureConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity); if (diceRoll <= dropRate) { // Make sure enchanted books always get some kind of enchantment. --hoorigan @@ -512,7 +512,7 @@ public class FishingManager extends SkillManager { diceRoll = dropRate + 1; continue; } - fishingEnchantments = TreasureMainConfig.getInstance().fishingEnchantments.get(rarity); + fishingEnchantments = TreasureConfig.getInstance().fishingEnchantments.get(rarity); break; } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 33a2cb223..cd695e21b 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -212,9 +212,9 @@ public class HerbalismManager extends SkillManager { } String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData()); - if (!TreasureMainConfig.getInstance().hylianMap.containsKey(friendly)) + if (!TreasureConfig.getInstance().hylianMap.containsKey(friendly)) return false; - List treasures = TreasureMainConfig.getInstance().hylianMap.get(friendly); + List treasures = TreasureConfig.getInstance().hylianMap.get(friendly); Player player = getPlayer(); 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 b167dc1c1..39f8732d3 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManagerFactory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManagerFactory.java @@ -4,7 +4,7 @@ import com.gmail.nossr50.config.HiddenConfig; public class ChunkletManagerFactory { public static ChunkletManager getChunkletManager() { - HiddenConfig hConfig = HiddenMainConfig.getInstance(); + HiddenConfig hConfig = HiddenConfig.getInstance(); if (hConfig.getChunkletsEnabled()) { return new HashChunkletManager(); diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManagerFactory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManagerFactory.java index fc93853cf..2b4d90349 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManagerFactory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManagerFactory.java @@ -4,7 +4,7 @@ import com.gmail.nossr50.config.HiddenConfig; public class ChunkManagerFactory { public static ChunkManager getChunkManager() { - HiddenConfig hConfig = HiddenMainConfig.getInstance(); + HiddenConfig hConfig = HiddenConfig.getInstance(); if (hConfig.getChunkletsEnabled()) { return new HashChunkManager(); diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java index be8e7cfb9..523f6c45a 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java @@ -18,7 +18,7 @@ public class BlockStoreConversionMain implements Runnable { this.world = world; this.scheduler = mcMMO.p.getServer().getScheduler(); this.dataDir = new File(this.world.getWorldFolder(), "mcmmo_data"); - this.converters = new BlockStoreConversionXDirectory[HiddenMainConfig.getInstance().getConversionRate()]; + this.converters = new BlockStoreConversionXDirectory[HiddenConfig.getInstance().getConversionRate()]; } public void start() { @@ -51,7 +51,7 @@ public class BlockStoreConversionMain implements Runnable { this.xDirs = this.dataDir.listFiles(); - for (this.i = 0; (this.i < HiddenMainConfig.getInstance().getConversionRate()) && (this.i < this.xDirs.length); this.i++) { + for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.xDirs.length); this.i++) { if (this.converters[this.i] == null) { this.converters[this.i] = new BlockStoreConversionXDirectory(); } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java index 5be0d1fa3..266785d64 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java @@ -20,7 +20,7 @@ public class BlockStoreConversionXDirectory implements Runnable { public void start(org.bukkit.World world, File dataDir) { this.world = world; this.scheduler = mcMMO.p.getServer().getScheduler(); - this.converters = new BlockStoreConversionZDirectory[HiddenMainConfig.getInstance().getConversionRate()]; + this.converters = new BlockStoreConversionZDirectory[HiddenConfig.getInstance().getConversionRate()]; this.dataDir = dataDir; if (this.taskID >= 0) { @@ -52,7 +52,7 @@ public class BlockStoreConversionXDirectory implements Runnable { this.zDirs = this.dataDir.listFiles(); - for (this.i = 0; (this.i < HiddenMainConfig.getInstance().getConversionRate()) && (this.i < this.zDirs.length); this.i++) { + for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.zDirs.length); this.i++) { if (this.converters[this.i] == null) { this.converters[this.i] = new BlockStoreConversionZDirectory(); } diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index b4cccb87e..2fbf00146 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -129,7 +129,7 @@ public class SkillUtils { } public static void handleAbilitySpeedIncrease(Player player) { - if (HiddenMainConfig.getInstance().useEnchantmentBuffs()) { + if (HiddenConfig.getInstance().useEnchantmentBuffs()) { ItemStack heldItem = player.getInventory().getItemInMainHand(); if (heldItem == null || heldItem.getType() == Material.AIR) { @@ -187,7 +187,7 @@ public class SkillUtils { } public static void handleAbilitySpeedDecrease(Player player) { - if (!HiddenMainConfig.getInstance().useEnchantmentBuffs()) { + if (!HiddenConfig.getInstance().useEnchantmentBuffs()) { return; } diff --git a/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java b/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java index 73a8d6147..a8c512a52 100644 --- a/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java +++ b/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java @@ -14,13 +14,13 @@ public class SoundManager { */ public static void sendSound(Player player, Location location, SoundType soundType) { - if(SoundMainConfig.getInstance().getIsEnabled(soundType)) + if(SoundConfig.getInstance().getIsEnabled(soundType)) player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType)); } public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory) { - if(SoundMainConfig.getInstance().getIsEnabled(soundType)) + if(SoundConfig.getInstance().getIsEnabled(soundType)) player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType)); } @@ -28,13 +28,13 @@ public class SoundManager { { float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier)); - if(SoundMainConfig.getInstance().getIsEnabled(soundType)) + if(SoundConfig.getInstance().getIsEnabled(soundType)) player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch); } public static void worldSendSound(World world, Location location, SoundType soundType) { - if(SoundMainConfig.getInstance().getIsEnabled(soundType)) + if(SoundConfig.getInstance().getIsEnabled(soundType)) world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType)); } @@ -45,7 +45,7 @@ public class SoundManager { */ private static float getVolume(SoundType soundType) { - return SoundMainConfig.getInstance().getVolume(soundType) * SoundMainConfig.getInstance().getMasterVolume(); + return SoundConfig.getInstance().getVolume(soundType) * SoundConfig.getInstance().getMasterVolume(); } private static float getPitch(SoundType soundType) @@ -55,7 +55,7 @@ public class SoundManager { else if (soundType == SoundType.POP) return getPopPitch(); else - return SoundMainConfig.getInstance().getPitch(soundType); + return SoundConfig.getInstance().getPitch(soundType); } private static Sound getSound(SoundType soundType)