summaryrefslogtreecommitdiffstats
path: root/src/main/java/net
diff options
context:
space:
mode:
authorNathan Adams <dinnerbone@dinnerbone.com>2011-12-04 11:04:14 +0000
committerNathan Adams <dinnerbone@dinnerbone.com>2011-12-04 11:04:14 +0000
commit55a532c2511a736c98b1be40b2c823d155096a05 (patch)
treed2218be9c4b8e149d0c7f8c8438ce8d84d591a92 /src/main/java/net
parent645079be08da59a89b7e19f519f1384836753ca4 (diff)
downloadcraftbukkit-55a532c2511a736c98b1be40b2c823d155096a05.tar
craftbukkit-55a532c2511a736c98b1be40b2c823d155096a05.tar.gz
craftbukkit-55a532c2511a736c98b1be40b2c823d155096a05.tar.lz
craftbukkit-55a532c2511a736c98b1be40b2c823d155096a05.tar.xz
craftbukkit-55a532c2511a736c98b1be40b2c823d155096a05.zip
Indicate when a teleport event was triggered by ender pearls or unknown internal teleports
Diffstat (limited to 'src/main/java/net')
-rw-r--r--src/main/java/net/minecraft/server/EntityEnderPearl.java33
-rw-r--r--src/main/java/net/minecraft/server/NetServerHandler.java6
2 files changed, 27 insertions, 12 deletions
diff --git a/src/main/java/net/minecraft/server/EntityEnderPearl.java b/src/main/java/net/minecraft/server/EntityEnderPearl.java
index 5469b6e2..04f7db9d 100644
--- a/src/main/java/net/minecraft/server/EntityEnderPearl.java
+++ b/src/main/java/net/minecraft/server/EntityEnderPearl.java
@@ -3,6 +3,8 @@ package net.minecraft.server;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.event.entity.EntityDamageEvent;
+import org.bukkit.event.player.PlayerPortalEvent;
+import org.bukkit.event.player.PlayerTeleportEvent;
public class EntityEnderPearl extends EntityProjectile {
public EntityEnderPearl(World world) {
@@ -28,23 +30,36 @@ public class EntityEnderPearl extends EntityProjectile {
if (!this.world.isStatic) {
// CraftBukkit start - dupe fix + damage event
- boolean damage = false;
+ boolean teleport = false;
+ PlayerTeleportEvent teleEvent = null;
+
if (this.shooter != null) {
if (this.shooter instanceof EntityPlayer) {
- damage = ((CraftPlayer)this.shooter.bukkitEntity).isOnline();
+ CraftPlayer player = (CraftPlayer)this.shooter.bukkitEntity;
+ teleport = player.isOnline();
+
+ if (teleport) {
+ teleEvent = new PlayerTeleportEvent(player, player.getLocation(), getBukkitEntity().getLocation(), PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
+ Bukkit.getPluginManager().callEvent(teleEvent);
+ teleport = !teleEvent.isCancelled();
+ }
} else {
- damage = true;
+ teleport = true;
}
}
- if (damage) {
- this.shooter.a_(this.locX, this.locY, this.locZ);
+ if (teleport) {
+ if (this.shooter instanceof EntityPlayer) {
+ ((EntityPlayer)this.shooter).netServerHandler.teleport(teleEvent.getTo());
+ } else {
+ this.shooter.a_(this.locX, this.locY, this.locZ);
+ }
this.shooter.fallDistance = 0.0F;
- EntityDamageEvent event = new EntityDamageEvent(getBukkitEntity(), EntityDamageEvent.DamageCause.FALL, 5);
- Bukkit.getPluginManager().callEvent(event);
+ EntityDamageEvent damageEvent = new EntityDamageEvent(getBukkitEntity(), EntityDamageEvent.DamageCause.FALL, 5);
+ Bukkit.getPluginManager().callEvent(damageEvent);
- if (!event.isCancelled()) {
- this.shooter.damageEntity(DamageSource.FALL, event.getDamage());
+ if (!damageEvent.isCancelled()) {
+ this.shooter.damageEntity(DamageSource.FALL, damageEvent.getDamage());
}
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java
index 9727f641..3c4f9e81 100644
--- a/src/main/java/net/minecraft/server/NetServerHandler.java
+++ b/src/main/java/net/minecraft/server/NetServerHandler.java
@@ -190,7 +190,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
there to avoid any 'Moved wrongly' or 'Moved too quickly' errors.
We only do this if the Event was not cancelled. */
if (!to.equals(event.getTo()) && !event.isCancelled()) {
- this.player.getBukkitEntity().teleport(event.getTo());
+ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
return;
}
@@ -204,7 +204,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
if (Double.isNaN(packet10flying.x) || Double.isNaN(packet10flying.y) || Double.isNaN(packet10flying.z) || Double.isNaN(packet10flying.stance)) {
- player.teleport(player.getWorld().getSpawnLocation());
+ player.teleport(player.getWorld().getSpawnLocation(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
System.err.println(player.getName() + " was caught trying to crash the server with an invalid position.");
player.kickPlayer("Nope!");
return;
@@ -386,7 +386,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
Player player = this.getPlayer();
Location from = player.getLocation();
Location to = new Location(this.getPlayer().getWorld(), d0, d1, d2, f, f1);
- PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
+ PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to, PlayerTeleportEvent.TeleportCause.UNKNOWN);
this.server.getPluginManager().callEvent(event);
from = event.getFrom();