From e0e574c19e45ee18ceb15d0d86759d568f4141a3 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 24 Jul 2013 13:50:33 -0400 Subject: [PATCH] Fix a potential issue with PTP and Chimera Wing teleportation cooldowns. --- .../commands/party/teleport/PtpCommand.java | 6 +++--- .../nossr50/datatypes/player/McMMOPlayer.java | 19 ++++++++++++++----- .../com/gmail/nossr50/util/ChimaeraWing.java | 6 +++--- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java index 82670388a..d2176232c 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java @@ -76,10 +76,10 @@ public class PtpCommand implements TabExecutor { } int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); - long lastTeleport = mcMMOPlayer.getLastTeleport(); + long ptpLastUse = mcMMOPlayer.getPtpLastUse(); if (ptpCooldown > 0) { - int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player); + int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player); if (timeRemaining > 0) { player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining)); @@ -196,6 +196,6 @@ public class PtpCommand implements TabExecutor { teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName())); targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName())); - mcMMOPlayer.actualizeRecentlyHurt(); + mcMMOPlayer.actualizePtpLastUse(); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 43e52dc35..3f325b62e 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -63,6 +63,7 @@ public class McMMOPlayer { private boolean ptpEnabled = true; private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired(); private long ptpTimeout; + private int ptpLastUse; private boolean partyChatMode; private boolean adminChatMode; @@ -83,7 +84,7 @@ public class McMMOPlayer { private int recentlyHurt; private int respawnATS; - private int teleportLastUse; + private int chimeraWingLastUse; private Location teleportCommence; private boolean isUsingUnarmed; @@ -310,12 +311,12 @@ public class McMMOPlayer { * Teleportation cooldown & warmup */ - public int getLastTeleport() { - return teleportLastUse; + public int getChimeraWingLastUse() { + return chimeraWingLastUse; } - public void actualizeLastTeleport() { - teleportLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); + public void actualizeChimeraWingLastUse() { + chimeraWingLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); } public Location getTeleportCommenceLocation() { @@ -612,6 +613,14 @@ public class McMMOPlayer { ptpConfirmRequired = !ptpConfirmRequired; } + public int getPtpLastUse() { + return ptpLastUse; + } + + public void actualizePtpLastUse() { + ptpLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); + } + public long getPtpTimeout() { return ptpTimeout; } diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index c396708ed..9dfef7da6 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -63,7 +63,7 @@ public final class ChimaeraWing { return; } - long lastTeleport = mcMMOPlayer.getLastTeleport(); + long lastTeleport = mcMMOPlayer.getChimeraWingLastUse(); int cooldown = Config.getInstance().getChimaeraCooldown(); if (cooldown > 0 ) { @@ -96,7 +96,7 @@ public final class ChimaeraWing { player.updateInventory(); player.setVelocity(new Vector(0, 0.5D, 0)); CombatUtils.dealDamage(player, Misc.getRandom().nextInt((int) (player.getHealth() - 10))); - mcMMOPlayer.actualizeLastTeleport(); + mcMMOPlayer.actualizeChimeraWingLastUse(); return; } } @@ -132,7 +132,7 @@ public final class ChimaeraWing { player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost()))); player.updateInventory(); - mcMMOPlayer.actualizeLastTeleport(); + mcMMOPlayer.actualizeChimeraWingLastUse(); if (Config.getInstance().getStatsTrackingEnabled()) { MetricsManager.chimeraWingUsed(); }