From e650c2f53455131f89b14b31097dfc03ae953612 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 25 Apr 2012 11:40:37 -0400 Subject: [PATCH] Perm checks for abilities display - Acrobatics. --- .../commands/skills/AcrobaticsCommand.java | 51 ++++++++++++++++--- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java index 9f0e81732..661d70521 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java @@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.Users; +import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; @@ -18,6 +19,10 @@ public class AcrobaticsCommand implements CommandExecutor { private String rollChance; private String gracefulRollChance; + private boolean canDodge; + private boolean canRoll; + private boolean canGracefulRoll; + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (CommandHelper.noConsoleUsage(sender)) { @@ -33,20 +38,43 @@ public class AcrobaticsCommand implements CommandExecutor { skillValue = (float) PP.getSkillLevel(SkillType.ACROBATICS); dataCalculations(skillValue); + permissionsCheck(player); player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Acrobatics.SkillName") })); player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.Acrobatics") })); player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) })); - player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") })); - player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Acrobatics.Effect.0"), mcLocale.getString("Acrobatics.Effect.1") })); - player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Acrobatics.Effect.2"), mcLocale.getString("Acrobatics.Effect.3") })); - player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Acrobatics.Effect.4"), mcLocale.getString("Acrobatics.Effect.5") })); + if (canDodge || canGracefulRoll || canRoll) { + player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") })); + } - player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") })); - player.sendMessage(mcLocale.getString("Acrobatics.Roll.Chance", new Object[] { rollChance })); - player.sendMessage(mcLocale.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance })); - player.sendMessage(mcLocale.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance })); + if (canRoll) { + player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Acrobatics.Effect.0"), mcLocale.getString("Acrobatics.Effect.1") })); + } + + if (canGracefulRoll) { + player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Acrobatics.Effect.2"), mcLocale.getString("Acrobatics.Effect.3") })); + } + + if (canDodge) { + player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Acrobatics.Effect.4"), mcLocale.getString("Acrobatics.Effect.5") })); + } + + if (canDodge || canGracefulRoll || canRoll) { + player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") })); + } + + if (canRoll) { + player.sendMessage(mcLocale.getString("Acrobatics.Roll.Chance", new Object[] { rollChance })); + } + + if (canGracefulRoll) { + player.sendMessage(mcLocale.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance })); + } + + if (canDodge) { + player.sendMessage(mcLocale.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance })); + } Page.grabGuidePageForSkill(SkillType.ACROBATICS, player, args); @@ -75,4 +103,11 @@ public class AcrobaticsCommand implements CommandExecutor { gracefulRollChance = String.valueOf(skillValue / 5); } } + + private void permissionsCheck(Player player) { + mcPermissions permInstance = mcPermissions.getInstance(); + canDodge = permInstance.dodge(player); + canRoll = permInstance.roll(player); + canGracefulRoll = permInstance.gracefulRoll(player); + } } \ No newline at end of file