From 798bd46d0a37064dfe1ecf073f77baf5b8038ab1 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 1 May 2012 16:29:52 -0400 Subject: [PATCH] Command updates - Repair (Finally done!) --- Changelog.txt | 1 + .../commands/skills/TamingCommand.java | 152 +++++++++++++----- .../java/com/gmail/nossr50/util/Combat.java | 2 +- .../com/gmail/nossr50/util/Permissions.java | 2 +- .../resources/locale/locale_en_US.properties | 8 +- 5 files changed, 117 insertions(+), 48 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 4de6a2a19..be6431909 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -25,6 +25,7 @@ Version 1.3.07 ! Changed Super Breaker to be non-functional when used with a Silk Touch enchanted pick ! Changed MySQL to save player information 50ms apart from each other to reduce the load on the MySQL server ! Changed the permission node for Blast Mining detonation to mcmmo.ability.blastmining.detonate (was mcmmo.skills.blastmining) for the sake of consistency + ! Changed skill commands to only display what you have permissions for - Removed some unused permission nodes - Removed a few config options in favor of permissions nodes (Hunger Bonus, Armor/Tool Repair, Instant Wheat Regrowth) - Removed level requirement for repairing string tools from the config file diff --git a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java index 85178973b..5cc9547ea 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java @@ -1,5 +1,7 @@ package com.gmail.nossr50.commands.skills; +import java.text.DecimalFormat; + import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -11,12 +13,22 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Page; +import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class TamingCommand implements CommandExecutor { private float skillValue; private String goreChance; + private boolean canBeastLore; + private boolean canGore; + private boolean canSharpenedClaws; + private boolean canEnvironmentallyAware; + private boolean canThickFur; + private boolean canShockProof; + private boolean canCallWild; + private boolean canFastFood; + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (CommandHelper.noConsoleUsage(sender)) { @@ -32,61 +44,102 @@ public class TamingCommand implements CommandExecutor { skillValue = (float) PP.getSkillLevel(SkillType.TAMING); dataCalculations(skillValue); + permissionsCheck(player); player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Taming.SkillName") })); player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Taming") })); player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) })); - player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") })); - player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1") })); - player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3") })); - player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5") })); - player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7") })); - player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9") })); - player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11") })); - player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13") })); - player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17") })); - player.sendMessage(LocaleLoader.getString("Taming.Effect.14", new Object[] { Config.getInstance().getTamingCOTWOcelotCost() })); - player.sendMessage(LocaleLoader.getString("Taming.Effect.15", new Object[] { Config.getInstance().getTamingCOTWWolfCost() })); - - player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") })); - - if (PP.getSkillLevel(SkillType.TAMING) < 100) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0") })); - } - else { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1") })); + if (canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur) { + player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") })); } - if (PP.getSkillLevel(SkillType.TAMING) < 250) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1") })); - } - else { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3") })); + if (canBeastLore) { + player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1") })); } - if (PP.getSkillLevel(SkillType.TAMING) < 500) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2") })); - } - else { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5") })); + if (canGore) { + player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3") })); } - if (PP.getSkillLevel(SkillType.TAMING) < 750) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3") })); - } - else { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7") })); + if (canSharpenedClaws) { + player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5") })); } - if (PP.getSkillLevel(SkillType.TAMING) < 50) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4") })); - } - else { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9") })); + if (canEnvironmentallyAware) { + player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7") })); } - player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance })); + if (canThickFur) { + player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9") })); + } + + if (canShockProof) { + player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11") })); + } + + if (canFastFood) { + player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17") })); + } + + if (canCallWild) { + player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13") })); + player.sendMessage(LocaleLoader.getString("Taming.Effect.14", new Object[] { Config.getInstance().getTamingCOTWOcelotCost() })); + player.sendMessage(LocaleLoader.getString("Taming.Effect.15", new Object[] { Config.getInstance().getTamingCOTWWolfCost() })); + } + + if (canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur) { + player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") })); + } + + if (canFastFood) { + if (PP.getSkillLevel(SkillType.TAMING) < 50) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4") })); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9") })); + } + } + + if (canEnvironmentallyAware) { + if (PP.getSkillLevel(SkillType.TAMING) < 100) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0") })); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1") })); + } + } + + if (canThickFur) { + if (PP.getSkillLevel(SkillType.TAMING) < 250) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1") })); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3") })); + } + } + + if (canShockProof) { + if (PP.getSkillLevel(SkillType.TAMING) < 500) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2") })); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5") })); + } + } + + if (canSharpenedClaws) { + if (PP.getSkillLevel(SkillType.TAMING) < 750) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3") })); + } + else { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7") })); + } + } + + if (canGore) { + player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance })); + } Page.grabGuidePageForSkill(SkillType.TAMING, player, args); @@ -94,11 +147,26 @@ public class TamingCommand implements CommandExecutor { } private void dataCalculations(float skillValue) { + DecimalFormat percent = new DecimalFormat("##0.00%"); + if (skillValue >= 1000) { - goreChance = "100"; + goreChance = "100.00%"; } else { - goreChance = String.valueOf(skillValue / 10); + goreChance = percent.format(skillValue / 1000); } } + + private void permissionsCheck(Player player) { + Permissions permInstance = Permissions.getInstance(); + + canBeastLore = permInstance.beastLore(player); + canCallWild = permInstance.callOfTheWild(player); + canEnvironmentallyAware = permInstance.environmentallyAware(player); + canFastFood = permInstance.fastFoodService(player); + canGore = permInstance.gore(player); + canSharpenedClaws = permInstance.sharpenedClaws(player); + canShockProof = permInstance.shockProof(player); + canThickFur = permInstance.thickFur(player); + } } diff --git a/src/main/java/com/gmail/nossr50/util/Combat.java b/src/main/java/com/gmail/nossr50/util/Combat.java index 7eca54ef1..0bc99c3eb 100644 --- a/src/main/java/com/gmail/nossr50/util/Combat.java +++ b/src/main/java/com/gmail/nossr50/util/Combat.java @@ -123,7 +123,7 @@ public class Combat { Taming.fastFoodService(PPo, wolf, event); } - if (Permissions.getInstance().sharpenedclaws(master)) { + if (Permissions.getInstance().sharpenedClaws(master)) { Taming.sharpenedClaws(PPo, event); } diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index 583c67d54..ff4d12486 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -76,7 +76,7 @@ public class Permissions { return player.hasPermission("mcmmo.ability.taming.fastfoodservice"); } - public boolean sharpenedclaws(Player player) { + public boolean sharpenedClaws(Player player) { return player.hasPermission("mcmmo.ability.taming.sharpenedclaws"); } diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 0487bc3e1..69f6d5594 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -274,7 +274,7 @@ Taming.Ability.Locked.1=LOCKED UNTIL 250+ SKILL (THICK FUR) Taming.Ability.Locked.2=LOCKED UNTIL 500+ SKILL (SHOCK PROOF) Taming.Ability.Locked.3=LOCKED UNTIL 750+ SKILL (SHARPENED CLAWS) Taming.Ability.Locked.4=LOCKED UNTIL 50+ SKILL (FAST FOOD SERVICE) -Taming.Combat.Chance.Gore=[[RED]]Gore Chance: [[YELLOW]]{0}% +Taming.Combat.Chance.Gore=[[RED]]Gore Chance: [[YELLOW]]{0} Taming.Effect.0=Beast Lore Taming.Effect.1=Bone-whacking inspects wolves & ocelots Taming.Effect.10=Shock Proof @@ -305,8 +305,8 @@ Taming.Summon.Fail.Wolf=[[RED]]You have too many wolves nearby to summon any mor Unarmed.Ability.Berserk.Length=[[RED]]Berserk Length: [[YELLOW]]{0}s Unarmed.Ability.Bonus.0=Iron Arm Style Unarmed.Ability.Bonus.1=+{0} DMG Upgrade -Unarmed.Ability.Chance.ArrowDeflect=[[RED]]Arrow Deflect Chance: [[YELLOW]]{0}% -Unarmed.Ability.Chance.Disarm=[[RED]]Disarm Chance: [[YELLOW]]{0}% +Unarmed.Ability.Chance.ArrowDeflect=[[RED]]Arrow Deflect Chance: [[YELLOW]]{0} +Unarmed.Ability.Chance.Disarm=[[RED]]Disarm Chance: [[YELLOW]]{0} Unarmed.Ability.Lower=[[GRAY]]**YOU LOWER YOUR FISTS** Unarmed.Ability.Ready=[[GREEN]]**YOU READY YOUR FISTS** Unarmed.Effect.0=Berserk (ABILITY) @@ -329,7 +329,7 @@ Unarmed.Skillup=[[YELLOW]]Unarmed skill increased by {0}. Total ({1}) #WOODCUTTING Woodcutting.Ability.0=Leaf Blower Woodcutting.Ability.1=Blow away leaves -Woodcutting.Ability.Chance.DDrop=[[RED]]Double Drop Chance: [[YELLOW]]{0}% +Woodcutting.Ability.Chance.DDrop=[[RED]]Double Drop Chance: [[YELLOW]]{0} Woodcutting.Ability.Length=[[RED]]Tree Feller Length: [[YELLOW]]{0}s Woodcutting.Ability.Locked.0=LOCKED UNTIL 100+ SKILL (LEAF BLOWER) Woodcutting.Effect.0=Tree Feller (ABILITY)