From 295b7a0701db8af0a33ba428e6edc85123ea7e17 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 26 Apr 2012 11:03:11 -0700 Subject: [PATCH] Config overhaul part 7 --- src/main/java/com/gmail/nossr50/Item.java | 14 ++--- .../java/com/gmail/nossr50/config/Config.java | 55 ++++++++----------- .../gmail/nossr50/datatypes/AbilityType.java | 16 +++--- .../nossr50/listeners/BlockListener.java | 24 ++++---- .../nossr50/listeners/PlayerListener.java | 4 +- .../com/gmail/nossr50/skills/Excavation.java | 2 +- .../java/com/gmail/nossr50/skills/Mining.java | 2 +- .../java/com/gmail/nossr50/skills/Skills.java | 6 +- .../com/gmail/nossr50/skills/WoodCutting.java | 6 +- 9 files changed, 59 insertions(+), 70 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/Item.java b/src/main/java/com/gmail/nossr50/Item.java index dc501983a..025abf45f 100644 --- a/src/main/java/com/gmail/nossr50/Item.java +++ b/src/main/java/com/gmail/nossr50/Item.java @@ -21,7 +21,7 @@ public class Item { public static void itemchecks(Player player) { ItemStack inhand = player.getItemInHand(); - if (Config.chimaeraWingEnable && inhand.getTypeId() == Config.chimaeraId) { + if (Config.getChimaeraEnabled() && inhand.getTypeId() == Config.getChimaeraItemId()) { chimaerawing(player); } } @@ -32,9 +32,9 @@ public class Item { Block block = player.getLocation().getBlock(); int amount = is.getAmount(); - if (mcPermissions.getInstance().chimaeraWing(player) && is.getTypeId() == Config.chimaeraId) { - if (Skills.cooldownOver(PP.getRecentlyHurt(), 60) && amount >= Config.feathersConsumedByChimaeraWing) { - player.setItemInHand(new ItemStack(Config.chimaeraId, amount - Config.feathersConsumedByChimaeraWing)); + if (mcPermissions.getInstance().chimaeraWing(player) && is.getTypeId() == Config.getChimaeraItemId()) { + if (Skills.cooldownOver(PP.getRecentlyHurt(), 60) && amount >= Config.getChimaeraCost()) { + player.setItemInHand(new ItemStack(Config.getChimaeraItemId(), amount - Config.getChimaeraCost())); for (int y = 0; block.getY() + y < player.getWorld().getMaxHeight(); y++) { if (!block.getRelative(0, y, 0).getType().equals(Material.AIR)) { @@ -53,11 +53,11 @@ public class Item { player.sendMessage(mcLocale.getString("Item.ChimaeraWing.Pass")); } - else if (!Skills.cooldownOver(PP.getRecentlyHurt(), 60) && is.getAmount() >= Config.feathersConsumedByChimaeraWing) { + else if (!Skills.cooldownOver(PP.getRecentlyHurt(), 60) && is.getAmount() >= Config.getChimaeraCost()) { player.sendMessage(mcLocale.getString("Item.Injured.Wait", new Object[] {Skills.calculateTimeLeft(PP.getRecentlyHurt(), 60)})); } - else if (is.getAmount() <= Config.feathersConsumedByChimaeraWing) { - player.sendMessage(mcLocale.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + m.prettyItemString(Config.chimaeraId)); + else if (is.getAmount() <= Config.getChimaeraCost()) { + player.sendMessage(mcLocale.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + m.prettyItemString(Config.getChimaeraItemId())); } } } diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 841b378ce..16af03464 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -56,24 +56,32 @@ public class Config extends ConfigLoader{ public static Boolean donateMessage; /* Items */ - public static Boolean chimaeraWingEnable; - public static int chimaeraId, feathersConsumedByChimaeraWing; + public static int getChimaeraCost() { return config.getInt("Items.Chimaera_Wing.Feather_Cost", 10); } + public static int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); } + public static boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); } /* * ABILITY SETTINGS */ /* General Settings */ - public static Boolean enableOnlyActivateWhenSneaking, enableAbilityMessages, enableAbilities; + public static boolean getAbilityMessagesEnabled() { return config.getBoolean("Abilities.Messages", true); } + public static boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); } + public static boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); } /* Durability Settings */ - public static Boolean toolsLoseDurabilityFromAbilities; - public static int abilityDurabilityLoss; + public static boolean getAbilitiesDamageTools() { return config.getBoolean("Abilities.Tools.Durability_Loss_Enabled", true); } + public static int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); } /* Cooldowns */ - public static int superBreakerCooldown, blastMiningCooldown, greenTerraCooldown, - gigaDrillBreakerCooldown, treeFellerCooldown, berserkCooldown, - serratedStrikeCooldown, skullSplitterCooldown; + public static int getAbilityCooldownGreenTerra() { return config.getInt("Abilities.Cooldowns.Green_Terra", 240); } + public static int getAbilityCooldownSuperBreaker() { return config.getInt("Abilities.Cooldowns.Super_Breaker", 240); } + public static int getAbilityCooldownGigaDrillBreaker() { return config.getInt("Abilities.Cooldowns.Giga_Drill_Breaker", 240); } + public static int getAbilityCooldownTreeFeller() { return config.getInt("Abilities.Cooldowns.Tree_Feller", 240); } + public static int getAbilityCooldownBerserk() { return config.getInt("Abilities.Cooldowns.Berserk", 240); } + public static int getAbilityCooldownSerratedStrikes() { return config.getInt("Abilities.Cooldowns.Serrated_Strikes", 240); } + public static int getAbilityCooldownSkullSplitter() { return config.getInt("Abilities.Cooldowns.Skull_Splitter", 240); } + public static int getAbilityCooldownBlastMining() { return config.getInt("Abilities.Cooldowns.Blast_Mining", 60); } /* Thresholds */ public static int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); } @@ -83,7 +91,9 @@ public class Config extends ConfigLoader{ */ /* Tool Requirements */ - public static Boolean miningrequirespickaxe, excavationRequiresShovel, woodcuttingrequiresaxe; + public static boolean getMiningRequiresTool() { return config.getBoolean("Skills.Mining.Requires_Pickaxe", true); } + public static boolean getExcavationRequiresTool() { return config.getBoolean("Skills.Excavation.Requires_Shovel", true); } + public static boolean getWoodcuttingRequiresTool() { return config.getBoolean("Skills.Woodcutting.Requires_Axe", true); } /* Excavation */ public static int getExcavationBaseXP() { return config.getInt("Experience.Excavation.Base", 40); } @@ -307,9 +317,6 @@ public class Config extends ConfigLoader{ } } - enableAbilityMessages = config.getBoolean("Abilities.Messages", true); - enableAbilities = config.getBoolean("Abilities.Enabled", true); - donateMessage = config.getBoolean("Commands.mcmmo.Donate_Message", true); xpGainsMobSpawners = config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); @@ -324,17 +331,6 @@ public class Config extends ConfigLoader{ showDisplayName = config.getBoolean("Spout.Party.HUD.Show_Display_Name", false); partybar = config.getBoolean("Spout.Party.HUD.Enabled", true); - enableOnlyActivateWhenSneaking = config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); - - greenTerraCooldown = config.getInt("Abilities.Cooldowns.Green_Terra", 240); - superBreakerCooldown = config.getInt("Abilities.Cooldowns.Super_Breaker", 240); - gigaDrillBreakerCooldown = config.getInt("Abilities.Cooldowns.Giga_Drill_Breaker", 240); - treeFellerCooldown = config.getInt("Abilities.Cooldowns.Tree_Feller", 240); - berserkCooldown = config.getInt("Abilities.Cooldowns.Berserk", 240); - serratedStrikeCooldown = config.getInt("Abilities.Cooldowns.Serrated_Strikes", 240); - skullSplitterCooldown = config.getInt("Abilities.Cooldowns.Skull_Splitter", 240); - blastMiningCooldown = config.getInt("Abilities.Cooldowns.Blast_Mining", 60); - locale = config.getString("General.Locale", "en_us"); enableMotd = config.getBoolean("General.MOTD_Enabled", true); saveInterval = config.getInt("General.Save_Interval", 10); @@ -346,18 +342,11 @@ public class Config extends ConfigLoader{ enableDirtToGrass = config.getBoolean("Skills.Herbalism.Green_Thumb.Dirt_To_Grass", true); xpGainMultiplier = config.getInt("Experience.Gains.Multiplier.Global", 1); - toolsLoseDurabilityFromAbilities = config.getBoolean("Abilities.Tools.Durability_Loss_Enabled", true); - abilityDurabilityLoss = config.getInt("Abilities.Tools.Durability_Loss", 2); - - feathersConsumedByChimaeraWing = config.getInt("Items.Chimaera_Wing.Feather_Cost", 10); - chimaeraId = config.getInt("Items.Chimaera_Wing.Item_ID", 288); - chimaeraWingEnable = config.getBoolean("Items.Chimaera_Wing.Enabled", true); - + + pvpxp = config.getBoolean("Experience.PVP.Rewards", true); - miningrequirespickaxe = config.getBoolean("Skills.Mining.Requires_Pickaxe", true); - excavationRequiresShovel = config.getBoolean("Skills.Excavation.Requires_Shovel", true); - woodcuttingrequiresaxe = config.getBoolean("Skills.Woodcutting.Requires_Axe", true); + repairArmor = config.getBoolean("Skills.Repair.Can_Repair_Armor", true); repairTools = config.getBoolean("Skills.Repair.Can_Repair_Tools", true); repairDiamondLevel = config.getInt("Skills.Repair.Diamond.Level_Required", 50); diff --git a/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java b/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java index b65e30479..7c081628b 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java @@ -12,7 +12,7 @@ import com.gmail.nossr50.skills.Mining; public enum AbilityType { BERSERK( - Config.berserkCooldown, + Config.getAbilityCooldownBerserk(), "Unarmed.Skills.Berserk.On", "Unarmed.Skills.Berserk.Off", "Unarmed.Skills.Berserk.Other.On", @@ -20,7 +20,7 @@ public enum AbilityType { "Unarmed.Skills.Berserk.Other.Off"), SUPER_BREAKER( - Config.superBreakerCooldown, + Config.getAbilityCooldownSuperBreaker(), "Mining.Skills.SuperBreaker.On", "Mining.Skills.SuperBreaker.Off", "Mining.Skills.SuperBreaker.Other.On", @@ -28,7 +28,7 @@ public enum AbilityType { "Mining.Skills.SuperBreaker.Other.Off"), GIGA_DRILL_BREAKER( - Config.gigaDrillBreakerCooldown, + Config.getAbilityCooldownGigaDrillBreaker(), "Excavation.Skills.GigaDrillBreaker.On", "Excavation.Skills.GigaDrillBreaker.Off", "Excavation.Skills.GigaDrillBreaker.Other.On", @@ -36,7 +36,7 @@ public enum AbilityType { "Excavation.Skills.GigaDrillBreaker.Other.Off"), GREEN_TERRA( - Config.greenTerraCooldown, + Config.getAbilityCooldownGreenTerra(), "Herbalism.Skills.GTe.On", "Herbalism.Skills.GTe.Off", "Herbalism.Skills.GTe.Other.On", @@ -44,7 +44,7 @@ public enum AbilityType { "Herbalism.Skills.GTe.Other.Off"), SKULL_SPLIITER( - Config.skullSplitterCooldown, + Config.getAbilityCooldownSkullSplitter(), "Axes.Skills.SS.On", "Axes.Skills.SS.Off", "Axes.Skills.SS.Other.On", @@ -52,7 +52,7 @@ public enum AbilityType { "Axes.Skills.SS.Other.Off"), TREE_FELLER( - Config.treeFellerCooldown, + Config.getAbilityCooldownTreeFeller(), "Woodcutting.Skills.TreeFeller.On", "Woodcutting.Skills.TreeFeller.Off", "Woodcutting.Skills.TreeFeller.Other.On", @@ -60,7 +60,7 @@ public enum AbilityType { "Woodcutting.Skills.TreeFeller.Other.Off"), SERRATED_STRIKES( - Config.serratedStrikeCooldown, + Config.getAbilityCooldownSerratedStrikes(), "Swords.Skills.SS.On", "Swords.Skills.SS.Off", "Swords.Skills.SS.Other.On", @@ -68,7 +68,7 @@ public enum AbilityType { "Swords.Skills.SS.Other.Off"), BLAST_MINING( - Config.blastMiningCooldown, + Config.getAbilityCooldownBlastMining(), null, null, "Mining.Blast.Other.On", diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 79359aa48..85b3d56e2 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -163,10 +163,10 @@ public class BlockListener implements Listener { */ if (mcPermissions.getInstance().mining(player) && Mining.canBeSuperBroken(mat)) { - if (Config.miningrequirespickaxe && ItemChecks.isMiningPick(inhand)) { + if (Config.getMiningRequiresTool() && ItemChecks.isMiningPick(inhand)) { Mining.miningBlockCheck(player, block); } - else if (!Config.miningrequirespickaxe) { + else if (!Config.getMiningRequiresTool()) { Mining.miningBlockCheck(player, block); } } @@ -176,10 +176,10 @@ public class BlockListener implements Listener { */ if (mcPermissions.getInstance().woodcutting(player) && mat.equals(Material.LOG)) { - if (Config.woodcuttingrequiresaxe && ItemChecks.isAxe(inhand)) { + if (Config.getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) { WoodCutting.woodcuttingBlockCheck(player, block); } - else if (!Config.woodcuttingrequiresaxe) { + else if (!Config.getWoodcuttingRequiresTool()) { WoodCutting.woodcuttingBlockCheck(player, block); } } @@ -193,10 +193,10 @@ public class BlockListener implements Listener { */ if (Excavation.canBeGigaDrillBroken(mat) && mcPermissions.getInstance().excavation(player) && !block.hasMetadata("mcmmoPlacedBlock")) { - if (Config.excavationRequiresShovel && ItemChecks.isShovel(inhand)) { + if (Config.getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) { Excavation.excavationProcCheck(block, player); } - else if (!Config.excavationRequiresShovel) { + else if (!Config.getExcavationRequiresTool()) { Excavation.excavationProcCheck(block, player); } } @@ -255,11 +255,11 @@ public class BlockListener implements Listener { Herbalism.greenTerra(player, block); } else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) { - if (Config.excavationRequiresShovel && ItemChecks.isShovel(inhand)) { + if (Config.getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) { event.setInstaBreak(true); Excavation.gigaDrillBreaker(player, block); } - else if (!Config.excavationRequiresShovel) { + else if (!Config.getExcavationRequiresTool()) { event.setInstaBreak(true); Excavation.gigaDrillBreaker(player, block); } @@ -277,23 +277,23 @@ public class BlockListener implements Listener { } } else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) { - if (Config.miningrequirespickaxe && ItemChecks.isMiningPick(inhand)) { + if (Config.getMiningRequiresTool() && ItemChecks.isMiningPick(inhand)) { event.setInstaBreak(true); Mining.SuperBreakerBlockCheck(player, block); } - else if (!Config.miningrequirespickaxe) { + else if (!Config.getMiningRequiresTool()) { event.setInstaBreak(true); Mining.SuperBreakerBlockCheck(player, block); } } else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && mat.equals(Material.LEAVES)) { - if (Config.woodcuttingrequiresaxe && ItemChecks.isAxe(inhand)) { + if (Config.getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) { if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) { event.setInstaBreak(true); WoodCutting.leafBlower(player, block); } } - else if (!Config.woodcuttingrequiresaxe && !inhand.getType().equals(Material.SHEARS)) { + else if (!Config.getWoodcuttingRequiresTool() && !inhand.getType().equals(Material.SHEARS)) { if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) { event.setInstaBreak(true); WoodCutting.leafBlower(player, block); diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 0448e04c1..c7c7d1eac 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -211,7 +211,7 @@ public class PlayerListener implements Listener { } /* ACTIVATION CHECKS */ - if (Config.enableAbilities && BlockChecks.abilityBlockCheck(mat)) { + if (Config.getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(mat)) { if (!mat.equals(Material.DIRT) && !mat.equals(Material.GRASS) && !mat.equals(Material.SOIL)) { Skills.activationCheck(player, SkillType.HERBALISM); } @@ -244,7 +244,7 @@ public class PlayerListener implements Listener { case RIGHT_CLICK_AIR: /* ACTIVATION CHECKS */ - if (Config.enableAbilities) { + if (Config.getAbilitiesEnabled()) { Skills.activationCheck(player, SkillType.AXES); Skills.activationCheck(player, SkillType.EXCAVATION); Skills.activationCheck(player, SkillType.HERBALISM); diff --git a/src/main/java/com/gmail/nossr50/skills/Excavation.java b/src/main/java/com/gmail/nossr50/skills/Excavation.java index bf9377106..9c34aa389 100644 --- a/src/main/java/com/gmail/nossr50/skills/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/Excavation.java @@ -131,7 +131,7 @@ public class Excavation { * @param block The block to check */ public static void gigaDrillBreaker(Player player, Block block) { - Skills.abilityDurabilityLoss(player.getItemInHand(), Config.abilityDurabilityLoss); + Skills.abilityDurabilityLoss(player.getItemInHand(), Config.getAbilityToolDamage()); if (!block.hasMetadata("mcmmoPlacedBlock")) { FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player); diff --git a/src/main/java/com/gmail/nossr50/skills/Mining.java b/src/main/java/com/gmail/nossr50/skills/Mining.java index 686b3fe50..87192beda 100644 --- a/src/main/java/com/gmail/nossr50/skills/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/Mining.java @@ -216,7 +216,7 @@ public class Mining { public static void SuperBreakerBlockCheck(Player player, Block block) { Material type = block.getType(); int tier = m.getTier(player.getItemInHand()); - int durabilityLoss = Config.abilityDurabilityLoss; + int durabilityLoss = Config.getAbilityToolDamage(); FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player); switch (type) { diff --git a/src/main/java/com/gmail/nossr50/skills/Skills.java b/src/main/java/com/gmail/nossr50/skills/Skills.java index 42a2e568e..4f88dc34f 100644 --- a/src/main/java/com/gmail/nossr50/skills/Skills.java +++ b/src/main/java/com/gmail/nossr50/skills/Skills.java @@ -80,7 +80,7 @@ public class Skills { * @param skill The skill the ability is tied to */ public static void activationCheck(Player player, SkillType skill) { - if (Config.enableOnlyActivateWhenSneaking && !player.isSneaking()) { + if (Config.getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) { return; } @@ -111,7 +111,7 @@ public class Skills { } } - if (Config.enableAbilityMessages) { + if (Config.getAbilityMessagesEnabled()) { player.sendMessage(tool.getRaiseTool()); } @@ -349,7 +349,7 @@ public class Skills { * @param durabilityLoss The durability to remove from the item */ public static void abilityDurabilityLoss(ItemStack inhand, int durabilityLoss) { - if (Config.toolsLoseDurabilityFromAbilities) { + if (Config.getAbilitiesDamageTools()) { if (!inhand.containsEnchantment(Enchantment.DURABILITY)) { inhand.setDurability((short) (inhand.getDurability() + durabilityLoss)); } diff --git a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java index 156ef0f82..a4a020a3b 100644 --- a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java @@ -315,8 +315,8 @@ public class WoodCutting { FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player); mcMMO.p.getServer().getPluginManager().callEvent(armswing); - if (Config.woodcuttingrequiresaxe) { - Skills.abilityDurabilityLoss(player.getItemInHand(), Config.abilityDurabilityLoss); + if (Config.getWoodcuttingRequiresTool()) { + Skills.abilityDurabilityLoss(player.getItemInHand(), Config.getAbilityToolDamage()); } if (Config.spoutEnabled) { @@ -329,7 +329,7 @@ public class WoodCutting { for (Block x : toBeFelled) { if (x.getType().equals(Material.LOG)) { durabilityLoss++; - durabilityLoss = durabilityLoss + Config.abilityDurabilityLoss; + durabilityLoss = durabilityLoss + Config.getAbilityToolDamage(); } }