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();
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();
}
}

View File

@ -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;
}

View File

@ -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();
}