Fix a potential issue with PTP and Chimera Wing teleportation cooldowns.

This commit is contained in:
GJ 2013-07-24 13:50:33 -04:00
parent 02126c93b9
commit e0e574c19e
3 changed files with 20 additions and 11 deletions

View File

@ -76,10 +76,10 @@ public class PtpCommand implements TabExecutor {
} }
int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
long lastTeleport = mcMMOPlayer.getLastTeleport(); long ptpLastUse = mcMMOPlayer.getPtpLastUse();
if (ptpCooldown > 0) { 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) { if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining)); 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())); teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName())); targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));
mcMMOPlayer.actualizeRecentlyHurt(); mcMMOPlayer.actualizePtpLastUse();
} }
} }

View File

@ -63,6 +63,7 @@ public class McMMOPlayer {
private boolean ptpEnabled = true; private boolean ptpEnabled = true;
private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired(); private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired();
private long ptpTimeout; private long ptpTimeout;
private int ptpLastUse;
private boolean partyChatMode; private boolean partyChatMode;
private boolean adminChatMode; private boolean adminChatMode;
@ -83,7 +84,7 @@ public class McMMOPlayer {
private int recentlyHurt; private int recentlyHurt;
private int respawnATS; private int respawnATS;
private int teleportLastUse; private int chimeraWingLastUse;
private Location teleportCommence; private Location teleportCommence;
private boolean isUsingUnarmed; private boolean isUsingUnarmed;
@ -310,12 +311,12 @@ public class McMMOPlayer {
* Teleportation cooldown & warmup * Teleportation cooldown & warmup
*/ */
public int getLastTeleport() { public int getChimeraWingLastUse() {
return teleportLastUse; return chimeraWingLastUse;
} }
public void actualizeLastTeleport() { public void actualizeChimeraWingLastUse() {
teleportLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); chimeraWingLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
} }
public Location getTeleportCommenceLocation() { public Location getTeleportCommenceLocation() {
@ -612,6 +613,14 @@ public class McMMOPlayer {
ptpConfirmRequired = !ptpConfirmRequired; ptpConfirmRequired = !ptpConfirmRequired;
} }
public int getPtpLastUse() {
return ptpLastUse;
}
public void actualizePtpLastUse() {
ptpLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
public long getPtpTimeout() { public long getPtpTimeout() {
return ptpTimeout; return ptpTimeout;
} }

View File

@ -63,7 +63,7 @@ public final class ChimaeraWing {
return; return;
} }
long lastTeleport = mcMMOPlayer.getLastTeleport(); long lastTeleport = mcMMOPlayer.getChimeraWingLastUse();
int cooldown = Config.getInstance().getChimaeraCooldown(); int cooldown = Config.getInstance().getChimaeraCooldown();
if (cooldown > 0 ) { if (cooldown > 0 ) {
@ -96,7 +96,7 @@ public final class ChimaeraWing {
player.updateInventory(); player.updateInventory();
player.setVelocity(new Vector(0, 0.5D, 0)); player.setVelocity(new Vector(0, 0.5D, 0));
CombatUtils.dealDamage(player, Misc.getRandom().nextInt((int) (player.getHealth() - 10))); CombatUtils.dealDamage(player, Misc.getRandom().nextInt((int) (player.getHealth() - 10)));
mcMMOPlayer.actualizeLastTeleport(); mcMMOPlayer.actualizeChimeraWingLastUse();
return; return;
} }
} }
@ -132,7 +132,7 @@ public final class ChimaeraWing {
player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost()))); player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost())));
player.updateInventory(); player.updateInventory();
mcMMOPlayer.actualizeLastTeleport(); mcMMOPlayer.actualizeChimeraWingLastUse();
if (Config.getInstance().getStatsTrackingEnabled()) { if (Config.getInstance().getStatsTrackingEnabled()) {
MetricsManager.chimeraWingUsed(); MetricsManager.chimeraWingUsed();
} }