mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-28 01:10:52 +00:00
Cleanup warp charging, to properly handle warp sign costs.
This commit is contained in:
parent
c6b0dfaa4c
commit
0b5718f7ff
3 changed files with 37 additions and 25 deletions
|
@ -56,8 +56,9 @@ public class EssentialsEntityListener implements Listener
|
||||||
}
|
}
|
||||||
else if (eAttack instanceof Projectile && eDefend instanceof Player)
|
else if (eAttack instanceof Projectile && eDefend instanceof Player)
|
||||||
{
|
{
|
||||||
|
final Projectile projectile = (Projectile)event.getDamager();
|
||||||
//This should return a ProjectileSource on 1.7.3 beta +
|
//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)
|
if (shooter instanceof Player)
|
||||||
{
|
{
|
||||||
final User attacker = ess.getUser((Player)shooter);
|
final User attacker = ess.getUser((Player)shooter);
|
||||||
|
|
|
@ -173,11 +173,18 @@ public class Teleport implements net.ess3.api.ITeleport
|
||||||
double delay = ess.getSettings().getTeleportDelay();
|
double delay = ess.getSettings().getTeleportDelay();
|
||||||
|
|
||||||
Trade cashCharge = chargeFor;
|
Trade cashCharge = chargeFor;
|
||||||
if (chargeFor != null && !chargeFor.getCommandCost(teleportOwner).equals(BigDecimal.ZERO))
|
|
||||||
|
if (chargeFor != null)
|
||||||
{
|
{
|
||||||
chargeFor.isAffordableFor(teleportOwner);
|
chargeFor.isAffordableFor(teleportOwner);
|
||||||
|
|
||||||
|
//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);
|
cashCharge = new Trade(chargeFor.getCommandCost(teleportOwner), ess);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cooldown(true);
|
cooldown(true);
|
||||||
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass")
|
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass")
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n._;
|
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.IEssentials;
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -95,27 +97,6 @@ public class TimedTeleport implements Runnable
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
teleport.cooldown(false);
|
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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -125,6 +106,29 @@ public class TimedTeleport implements Runnable
|
||||||
teleportUser.sendMessage(_("cooldownWithMessage", ex.getMessage()));
|
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 a new issue