diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index d8379ddf65..db6efb62d3 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -55,9 +55,10 @@ else if (eDefend instanceof Ageable) 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 225397b373..4812296bd9 100644 --- a/Essentials/src/com/earth2me/essentials/Teleport.java +++ b/Essentials/src/com/earth2me/essentials/Teleport.java @@ -173,10 +173,17 @@ private void teleport(IUser teleportee, ITarget target, Trade chargeFor, Telepor 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 cf1a2497bd..1b972c17cb 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 void run() 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 void run() 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"); + } + } }