From 8738036f6ffed259376a029884f62b66f710159b Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 21 Jun 2012 21:50:48 -0400 Subject: [PATCH] Added Reduced Cooldown perk for donors. --- .../nossr50/skills/gathering/BlastMining.java | 2 +- .../java/com/gmail/nossr50/util/Item.java | 4 ++-- .../java/com/gmail/nossr50/util/Skills.java | 23 +++++++++++++++---- src/main/resources/plugin.yml | 16 +++++++++++++ 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/gathering/BlastMining.java index e793ada50..6791afc68 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/BlastMining.java @@ -279,7 +279,7 @@ public class BlastMining { AbilityType ability = AbilityType.BLAST_MINING; /* Check Cooldown */ - if (!Skills.cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) { + if (!Skills.cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + Skills.calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)"); return; diff --git a/src/main/java/com/gmail/nossr50/util/Item.java b/src/main/java/com/gmail/nossr50/util/Item.java index 0e2b5e8cc..99cbfd701 100644 --- a/src/main/java/com/gmail/nossr50/util/Item.java +++ b/src/main/java/com/gmail/nossr50/util/Item.java @@ -32,7 +32,7 @@ public class Item { int amount = inHand.getAmount(); if (Permissions.getInstance().chimaeraWing(player) && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) { - if (Skills.cooldownOver(PP.getRecentlyHurt(), 60) && amount >= Config.getInstance().getChimaeraCost()) { + if (Skills.cooldownOver(PP.getRecentlyHurt(), 60, player) && amount >= Config.getInstance().getChimaeraCost()) { player.setItemInHand(new ItemStack(Config.getInstance().getChimaeraItemId(), amount - Config.getInstance().getChimaeraCost())); for (int y = 1; block.getY() + y < player.getWorld().getMaxHeight(); y++) { @@ -52,7 +52,7 @@ public class Item { player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass")); } - else if (!Skills.cooldownOver(PP.getRecentlyHurt(), 60) && amount >= Config.getInstance().getChimaeraCost()) { + else if (!Skills.cooldownOver(PP.getRecentlyHurt(), 60, player) && amount >= Config.getInstance().getChimaeraCost()) { player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", new Object[] {Skills.calculateTimeLeft(PP.getRecentlyHurt(), 60)})); } else if (amount <= Config.getInstance().getChimaeraCost()) { diff --git a/src/main/java/com/gmail/nossr50/util/Skills.java b/src/main/java/com/gmail/nossr50/util/Skills.java index 35f4a278b..e144072fc 100644 --- a/src/main/java/com/gmail/nossr50/util/Skills.java +++ b/src/main/java/com/gmail/nossr50/util/Skills.java @@ -34,12 +34,25 @@ public class Skills { * * @param oldTime The time the ability or item was last used * @param cooldown The amount of time that must pass between uses + * @param player The player whose cooldown is being checked * @return true if the cooldown is over, false otherwise */ - public static boolean cooldownOver(long oldTime, int cooldown){ + public static boolean cooldownOver(long oldTime, int cooldown, Player player){ long currentTime = System.currentTimeMillis(); + int adjustedCooldown = cooldown; - if (currentTime - oldTime >= (cooldown * TIME_CONVERSION_FACTOR)) { + //Reduced Cooldown Donor Perks + if (player.hasPermission("mcmmo.perks.cooldowns.halved")) { + adjustedCooldown = adjustedCooldown / 2; + } + else if (player.hasPermission("mcmmo.perks.cooldowns.thirded")) { + adjustedCooldown = adjustedCooldown / 3; + } + else if (player.hasPermission("mcmmo.perks.cooldowns.quartered")) { + adjustedCooldown = adjustedCooldown / 4; + } + + if (currentTime - oldTime >= (adjustedCooldown * TIME_CONVERSION_FACTOR)) { return true; } else { @@ -105,7 +118,7 @@ public class Skills { */ if (ability.getPermissions(player) && tool.inHand(inHand) && !PP.getToolPreparationMode(tool)) { if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) { - if (!PP.getAbilityMode(ability) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) { + if (!PP.getAbilityMode(ability) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)"); return; } @@ -383,7 +396,7 @@ public class Skills { * We show them the too tired message when they take action. */ if (type == SkillType.WOODCUTTING || type == SkillType.AXES) { - if (!PP.getAbilityMode(ability) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) { + if (!PP.getAbilityMode(ability) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) { player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)"); return; } @@ -396,7 +409,7 @@ public class Skills { ticks = maxTicks; } - if (!PP.getAbilityMode(ability) && cooldownOver(PP.getSkillDATS(ability), ability.getCooldown())) { + if (!PP.getAbilityMode(ability) && cooldownOver(PP.getSkillDATS(ability), ability.getCooldown(), player)) { player.sendMessage(ability.getAbilityOn()); for (Player y : player.getWorld().getPlayers()) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 44d09a0b0..a92ada659 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -138,6 +138,22 @@ permissions: mcmmo.tools.*: true mcmmo.admin: description: Allows access to mmoupdate and other sensitive commands + mcmmo.perks.cooldowns: + default: false + description: Reduced cooldown perks typically given to donors or VIPs + children: + mcmmo.perks.cooldowns.quartered: true + mcmmo.perks.cooldowns.thirded: true + mcmmo.perks.cooldowns.halved: true + mcmmo.perks.cooldowns.quartered: + default: false + description: Cuts cooldowns down by 1/4 + mcmmo.perks.cooldowns.thirded: + default: false + description: Cuts cooldowns down by 1/3 + mcmmo.perks.cooldowns.halved: + default: false + description: Cuts cooldowns down by 1/2 mcmmo.perks.xp: default: false description: XP Perks typically given to donors or VIPs