瀏覽代碼

Fixed respawn cooldown checks

Thanks @Riking for pointing this out!
TfT_02 11 年之前
父節點
當前提交
3828f78480

+ 1 - 0
Changelog.txt

@@ -35,6 +35,7 @@ Version 1.4.07-dev
  = Fixed a bug where teleport location was never reset if warmup was set to 0 for "Chimaera Wing".
  = Fixed a bug where the "Dodge" DamageModifier wasn't being read from advanced.yml
  = Fixed a bug where squid were not awarding XP.
+ = Fixed a bug where Combat XP was granted within 5 seconds for respawned players
  ! Changed format of treasures.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
  ! Changed format of repair.vanilla.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
  ! Witches no longer drop water bottles from Shake, since they no longer drop them in Vanilla.

+ 1 - 1
src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java

@@ -56,7 +56,7 @@ public class AcrobaticsManager extends SkillManager {
             }
 
             // Why do we check respawn cooldown here?
-            if (System.currentTimeMillis() >= mcMMOPlayer.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
+            if (SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
                 applyXpGain((float) (damage * Acrobatics.dodgeXpModifier));
             }
 

+ 1 - 1
src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java

@@ -463,7 +463,7 @@ public final class CombatUtils {
 
             Player defender = (Player) target;
 
-            if (defender.isOnline() && System.currentTimeMillis() >= UserManager.getPlayer(defender).getRespawnATS() + 5) {
+            if (defender.isOnline() && SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
                 baseXP = 20 * ExperienceConfig.getInstance().getPlayerVersusPlayerXP();
             }
         }

+ 15 - 0
src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java

@@ -60,12 +60,27 @@ public class SkillUtils {
      *
      * @param deactivatedTimeStamp Time of deactivation
      * @param cooldown The length of the cooldown
+     * @param player The Player to check for cooldown perks
+     *
      * @return the number of seconds remaining before the cooldown expires
      */
     public static int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, Player player) {
         return (int) (((deactivatedTimeStamp + (PerksUtils.handleCooldownPerks(player, cooldown) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
     }
 
+    /**
+     * Check if the cooldown has expired.
+     * This does NOT account for cooldown perks!
+     *
+     * @param deactivatedTimeStamp Time of deactivation in seconds
+     * @param cooldown The length of the cooldown in seconds
+     *
+     * @return true if the cooldown is expired
+     */
+    public static boolean cooldownExpired(long deactivatedTimeStamp, int cooldown) {
+        return (System.currentTimeMillis() >= (deactivatedTimeStamp + cooldown) * Misc.TIME_CONVERSION_FACTOR);
+    }
+
     /**
      * Process activating abilities & readying the tool.
      *