Fix: No cooldown for all /tpo commands

TP-Delay: Player can move around roughly in the 9 blocks surrounding them.
This commit is contained in:
snowleo 2011-07-02 13:12:10 +02:00
parent 914a44007d
commit 335c9f37ab
5 changed files with 17 additions and 13 deletions

View file

@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
public class Teleport implements Runnable
{
private static final double MOVE_CONSTANT = 0.3;
private static class Target
{
private final Location location;
@ -57,9 +58,9 @@ public class Teleport implements Runnable
this.started = System.currentTimeMillis();
this.delay = delay;
this.health = user.getHealth();
this.initX = Math.round(user.getLocation().getX() * 10000);
this.initY = Math.round(user.getLocation().getY() * 10000);
this.initZ = Math.round(user.getLocation().getZ() * 10000);
this.initX = Math.round(user.getLocation().getX()*MOVE_CONSTANT);
this.initY = Math.round(user.getLocation().getY()*MOVE_CONSTANT);
this.initZ = Math.round(user.getLocation().getZ()*MOVE_CONSTANT);
this.teleportTarget = target;
this.chargeFor = chargeFor;
}
@ -72,9 +73,9 @@ public class Teleport implements Runnable
cancel();
return;
}
if (Math.round(user.getLocation().getX() * 10000) != initX
|| Math.round(user.getLocation().getY() * 10000) != initY
|| Math.round(user.getLocation().getZ() * 10000) != initZ
if (Math.round(user.getLocation().getX()*MOVE_CONSTANT) != initX
|| Math.round(user.getLocation().getY()*MOVE_CONSTANT) != initY
|| Math.round(user.getLocation().getZ()*MOVE_CONSTANT) != initZ
|| user.getHealth() < health)
{ // user moved, cancel teleport
cancel(true);
@ -237,9 +238,12 @@ public class Teleport implements Runnable
now(new Target(loc));
}
public void now(Entity entity) throws Exception
public void now(Entity entity, boolean cooldown) throws Exception
{
cooldown(false);
if (cooldown)
{
cooldown(false);
}
now(new Target(entity));
}

View file

@ -44,7 +44,7 @@ public class Commandtp extends EssentialsCommand
charge(user);
User target = getPlayer(server, args, 0);
User toPlayer = getPlayer(server, args, 1);
target.getTeleport().now(toPlayer);
target.getTeleport().now(toPlayer, false);
target.sendMessage(Util.format("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
break;
}
@ -61,7 +61,7 @@ public class Commandtp extends EssentialsCommand
sender.sendMessage(Util.i18n("teleporting"));
User target = getPlayer(server, args, 0);
User toPlayer = getPlayer(server, args, 1);
target.getTeleport().now(toPlayer);
target.getTeleport().now(toPlayer, false);
target.sendMessage(Util.format("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
}
}

View file

@ -45,7 +45,7 @@ public class Commandtpall extends EssentialsCommand
}
try
{
u.getTeleport().now(p);
u.getTeleport().now(p, false);
}
catch (Exception ex)
{

View file

@ -23,7 +23,7 @@ public class Commandtpo extends EssentialsCommand
//Just basically the old tp command
User p = getPlayer(server, args, 0);
charge(user);
user.getTeleport().now(p);
user.getTeleport().now(p, false);
user.sendMessage(Util.i18n("teleporting"));
}
}

View file

@ -23,7 +23,7 @@ public class Commandtpohere extends EssentialsCommand
//Just basically the old tphere command
User p = getPlayer(server, args, 0);
charge(user);
p.getTeleport().now(user);
p.getTeleport().now(user, false);
user.sendMessage(Util.i18n("teleporting"));
}
}