diff options
author | KHobbits <rob@khobbits.co.uk> | 2014-03-19 00:01:14 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2014-03-19 00:01:47 +0000 |
commit | 0b5718f7ffc249126199a8eb2278cde47a997506 (patch) | |
tree | e2b83ce80f3e23c75f43854209659bf9fcbf76ed | |
parent | c6b0dfaa4cd4c03e08d3f05939ce8a9e33415c50 (diff) | |
download | Essentials-0b5718f7ffc249126199a8eb2278cde47a997506.tar Essentials-0b5718f7ffc249126199a8eb2278cde47a997506.tar.gz Essentials-0b5718f7ffc249126199a8eb2278cde47a997506.tar.lz Essentials-0b5718f7ffc249126199a8eb2278cde47a997506.tar.xz Essentials-0b5718f7ffc249126199a8eb2278cde47a997506.zip |
Cleanup warp charging, to properly handle warp sign costs.
3 files changed, 37 insertions, 25 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index d8379ddf6..db6efb62d 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -55,9 +55,10 @@ public class EssentialsEntityListener implements Listener attacker.updateActivity(true); } else if (eAttack instanceof Projectile && eDefend instanceof Player) - { + { + final Projectile projectile = (Projectile)event.getDamager(); //This should return a ProjectileSource on 1.7.3 beta + - Object shooter = ((Projectile)event.getDamager()).getShooter(); + final Object shooter = projectile.getShooter(); if (shooter instanceof Player) { final User attacker = ess.getUser((Player)shooter); diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java index 225397b37..4812296bd 100644 --- a/Essentials/src/com/earth2me/essentials/Teleport.java +++ b/Essentials/src/com/earth2me/essentials/Teleport.java @@ -173,10 +173,17 @@ public class Teleport implements net.ess3.api.ITeleport double delay = ess.getSettings().getTeleportDelay(); Trade cashCharge = chargeFor; - if (chargeFor != null && !chargeFor.getCommandCost(teleportOwner).equals(BigDecimal.ZERO)) + + if (chargeFor != null) { chargeFor.isAffordableFor(teleportOwner); - cashCharge = new Trade(chargeFor.getCommandCost(teleportOwner), ess); + + //This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world. + if (!chargeFor.getCommandCost(teleportOwner).equals(BigDecimal.ZERO)) + { + //By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport. + cashCharge = new Trade(chargeFor.getCommandCost(teleportOwner), ess); + } } cooldown(true); diff --git a/Essentials/src/com/earth2me/essentials/TimedTeleport.java b/Essentials/src/com/earth2me/essentials/TimedTeleport.java index cf1a2497b..1b972c17c 100644 --- a/Essentials/src/com/earth2me/essentials/TimedTeleport.java +++ b/Essentials/src/com/earth2me/essentials/TimedTeleport.java @@ -1,6 +1,8 @@ package com.earth2me.essentials; import static com.earth2me.essentials.I18n._; +import java.util.logging.Level; +import java.util.logging.Logger; import net.ess3.api.IEssentials; import net.ess3.api.IUser; import org.bukkit.Location; @@ -95,27 +97,6 @@ public class TimedTeleport implements Runnable try { teleport.cooldown(false); - teleportUser.sendMessage(_("teleportationCommencing")); - try - { - if (timer_respawn) - { - teleport.respawnNow(teleportUser, timer_cause); - } - else - { - teleport.now(teleportUser, timer_teleportTarget, timer_cause); - } - cancelTimer(false); - if (timer_chargeFor != null) - { - timer_chargeFor.charge(teleportOwner); - } - } - catch (Exception ex) - { - ess.showError(teleportOwner.getSource(), ex, "\\ teleport"); - } } catch (Exception ex) { @@ -125,6 +106,29 @@ public class TimedTeleport implements Runnable teleportUser.sendMessage(_("cooldownWithMessage", ex.getMessage())); } } + try + { + cancelTimer(false); + teleportUser.sendMessage(_("teleportationCommencing")); + timer_chargeFor.isAffordableFor(teleportOwner); + if (timer_respawn) + { + teleport.respawnNow(teleportUser, timer_cause); + } + else + { + teleport.now(teleportUser, timer_teleportTarget, timer_cause); + } + if (timer_chargeFor != null) + { + timer_chargeFor.charge(teleportOwner); + } + } + catch (Exception ex) + { + ess.showError(teleportOwner.getSource(), ex, "\\ teleport"); + } + } } |