diff options
author | feildmaster <admin@feildmaster.com> | 2012-11-20 18:15:00 -0600 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-11-20 19:41:56 -0500 |
commit | 71b0510f88d1edf31dd8d823e4035f0b508c735f (patch) | |
tree | 9ce6fbfb8de335b95e36a0ad80717e4618721a6a /src/main/java/org/bukkit | |
parent | fed863049dce79f240bd4d38c04582c8dfc583e8 (diff) | |
download | craftbukkit-71b0510f88d1edf31dd8d823e4035f0b508c735f.tar craftbukkit-71b0510f88d1edf31dd8d823e4035f0b508c735f.tar.gz craftbukkit-71b0510f88d1edf31dd8d823e4035f0b508c735f.tar.lz craftbukkit-71b0510f88d1edf31dd8d823e4035f0b508c735f.tar.xz craftbukkit-71b0510f88d1edf31dd8d823e4035f0b508c735f.zip |
Fix teleporting entities with vehicles/passengers teleporting you illegally. Fixes BUKKIT-2821
Also some formatting...
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 46db36cc..efa4e05a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -346,7 +346,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) { EntityPlayer entity = getHandle(); - if (entity.netServerHandler == null || entity.netServerHandler.disconnected) return false; + + if (entity.netServerHandler == null || entity.netServerHandler.disconnected) { + return false; + } + + if (entity.vehicle != null || entity.passenger != null) { + return false; + } // From = Players current Location Location from = this.getLocation(); @@ -355,10 +362,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { // Create & Call the Teleport Event. PlayerTeleportEvent event = new PlayerTeleportEvent((Player) this, from, to, cause); server.getPluginManager().callEvent(event); + // Return False to inform the Plugin that the Teleport was unsuccessful/cancelled. - if (event.isCancelled() == true) { + if (event.isCancelled()) { return false; } + // Update the From Location from = event.getFrom(); // Grab the new To Location dependent on whether the event was cancelled. |