summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-07-02 13:12:10 +0200
committersnowleo <schneeleo@gmail.com>2011-07-02 13:12:10 +0200
commit335c9f37ab8685b115bbf756938b4e4602492958 (patch)
tree486150dc83e1254c0230acbde0af93c87f07f228
parent914a44007d72148eb4bed422ab7afc1113f5d996 (diff)
downloadEssentials-335c9f37ab8685b115bbf756938b4e4602492958.tar
Essentials-335c9f37ab8685b115bbf756938b4e4602492958.tar.gz
Essentials-335c9f37ab8685b115bbf756938b4e4602492958.tar.lz
Essentials-335c9f37ab8685b115bbf756938b4e4602492958.tar.xz
Essentials-335c9f37ab8685b115bbf756938b4e4602492958.zip
Fix: No cooldown for all /tpo commands
TP-Delay: Player can move around roughly in the 9 blocks surrounding them.
-rw-r--r--Essentials/src/com/earth2me/essentials/Teleport.java20
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtp.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpall.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpo.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java2
5 files changed, 17 insertions, 13 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java
index e63d1699e..429834b02 100644
--- a/Essentials/src/com/earth2me/essentials/Teleport.java
+++ b/Essentials/src/com/earth2me/essentials/Teleport.java
@@ -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));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
index a8b805e8d..c147c5d25 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
@@ -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()));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
index d564e90ea..cc58944d7 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
@@ -45,7 +45,7 @@ public class Commandtpall extends EssentialsCommand
}
try
{
- u.getTeleport().now(p);
+ u.getTeleport().now(p, false);
}
catch (Exception ex)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
index 6b74f5062..2a9e34da8 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
@@ -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"));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
index 5dc7a4478..593d17b59 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
@@ -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"));
}
}