Browse Source

Added Reduced Cooldown perk for donors.

GJ 13 năm trước cách đây
mục cha
commit
8738036f6f

+ 1 - 1
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;

+ 2 - 2
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()) {

+ 18 - 5
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()) {

+ 16 - 0
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