mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 01:27:40 +01:00
Cleanup warp charging, to properly handle warp sign costs.
This commit is contained in:
parent
c6b0dfaa4c
commit
0b5718f7ff
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user