mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
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:
parent
914a44007d
commit
335c9f37ab
5 changed files with 17 additions and 13 deletions
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
public class Teleport implements Runnable
|
public class Teleport implements Runnable
|
||||||
{
|
{
|
||||||
|
private static final double MOVE_CONSTANT = 0.3;
|
||||||
private static class Target
|
private static class Target
|
||||||
{
|
{
|
||||||
private final Location location;
|
private final Location location;
|
||||||
|
@ -57,9 +58,9 @@ public class Teleport implements Runnable
|
||||||
this.started = System.currentTimeMillis();
|
this.started = System.currentTimeMillis();
|
||||||
this.delay = delay;
|
this.delay = delay;
|
||||||
this.health = user.getHealth();
|
this.health = user.getHealth();
|
||||||
this.initX = Math.round(user.getLocation().getX() * 10000);
|
this.initX = Math.round(user.getLocation().getX()*MOVE_CONSTANT);
|
||||||
this.initY = Math.round(user.getLocation().getY() * 10000);
|
this.initY = Math.round(user.getLocation().getY()*MOVE_CONSTANT);
|
||||||
this.initZ = Math.round(user.getLocation().getZ() * 10000);
|
this.initZ = Math.round(user.getLocation().getZ()*MOVE_CONSTANT);
|
||||||
this.teleportTarget = target;
|
this.teleportTarget = target;
|
||||||
this.chargeFor = chargeFor;
|
this.chargeFor = chargeFor;
|
||||||
}
|
}
|
||||||
|
@ -72,9 +73,9 @@ public class Teleport implements Runnable
|
||||||
cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Math.round(user.getLocation().getX() * 10000) != initX
|
if (Math.round(user.getLocation().getX()*MOVE_CONSTANT) != initX
|
||||||
|| Math.round(user.getLocation().getY() * 10000) != initY
|
|| Math.round(user.getLocation().getY()*MOVE_CONSTANT) != initY
|
||||||
|| Math.round(user.getLocation().getZ() * 10000) != initZ
|
|| Math.round(user.getLocation().getZ()*MOVE_CONSTANT) != initZ
|
||||||
|| user.getHealth() < health)
|
|| user.getHealth() < health)
|
||||||
{ // user moved, cancel teleport
|
{ // user moved, cancel teleport
|
||||||
cancel(true);
|
cancel(true);
|
||||||
|
@ -237,9 +238,12 @@ public class Teleport implements Runnable
|
||||||
now(new Target(loc));
|
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));
|
now(new Target(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class Commandtp extends EssentialsCommand
|
||||||
charge(user);
|
charge(user);
|
||||||
User target = getPlayer(server, args, 0);
|
User target = getPlayer(server, args, 0);
|
||||||
User toPlayer = getPlayer(server, args, 1);
|
User toPlayer = getPlayer(server, args, 1);
|
||||||
target.getTeleport().now(toPlayer);
|
target.getTeleport().now(toPlayer, false);
|
||||||
target.sendMessage(Util.format("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
|
target.sendMessage(Util.format("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class Commandtp extends EssentialsCommand
|
||||||
sender.sendMessage(Util.i18n("teleporting"));
|
sender.sendMessage(Util.i18n("teleporting"));
|
||||||
User target = getPlayer(server, args, 0);
|
User target = getPlayer(server, args, 0);
|
||||||
User toPlayer = getPlayer(server, args, 1);
|
User toPlayer = getPlayer(server, args, 1);
|
||||||
target.getTeleport().now(toPlayer);
|
target.getTeleport().now(toPlayer, false);
|
||||||
target.sendMessage(Util.format("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
|
target.sendMessage(Util.format("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class Commandtpall extends EssentialsCommand
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
u.getTeleport().now(p);
|
u.getTeleport().now(p, false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class Commandtpo extends EssentialsCommand
|
||||||
//Just basically the old tp command
|
//Just basically the old tp command
|
||||||
User p = getPlayer(server, args, 0);
|
User p = getPlayer(server, args, 0);
|
||||||
charge(user);
|
charge(user);
|
||||||
user.getTeleport().now(p);
|
user.getTeleport().now(p, false);
|
||||||
user.sendMessage(Util.i18n("teleporting"));
|
user.sendMessage(Util.i18n("teleporting"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class Commandtpohere extends EssentialsCommand
|
||||||
//Just basically the old tphere command
|
//Just basically the old tphere command
|
||||||
User p = getPlayer(server, args, 0);
|
User p = getPlayer(server, args, 0);
|
||||||
charge(user);
|
charge(user);
|
||||||
p.getTeleport().now(user);
|
p.getTeleport().now(user, false);
|
||||||
user.sendMessage(Util.i18n("teleporting"));
|
user.sendMessage(Util.i18n("teleporting"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue