Paper/nms-patches/TileEntityEndGateway.patch
2018-11-07 11:15:24 +11:00

49 lines
2.2 KiB
Diff

--- a/net/minecraft/server/TileEntityEndGateway.java
+++ b/net/minecraft/server/TileEntityEndGateway.java
@@ -6,11 +6,17 @@
import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.event.player.PlayerTeleportEvent;
+// CraftBukkit end
public class TileEntityEndGateway extends TileEntityEnderPortal implements ITickable {
private static final Logger a = LogManager.getLogger();
- private long e;
+ public long e; // PAIL
private int f;
public BlockPosition exitPortal;
public boolean exactTeleport;
@@ -113,6 +119,26 @@
if (this.exitPortal != null) {
BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.i();
+ // CraftBukkit start - Fire PlayerTeleportEvent
+ if (entity instanceof EntityPlayer) {
+ org.bukkit.craftbukkit.entity.CraftPlayer player = (CraftPlayer) entity.getBukkitEntity();
+ org.bukkit.Location location = new Location(world.getWorld(), (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D);
+ location.setPitch(player.getLocation().getPitch());
+ location.setYaw(player.getLocation().getYaw());
+
+ PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.END_GATEWAY);
+ Bukkit.getPluginManager().callEvent(teleEvent);
+ if (teleEvent.isCancelled()) {
+ return;
+ }
+
+ ((EntityPlayer) entity).playerConnection.teleport(teleEvent.getTo());
+ this.f(); // CraftBukkit - call at end of method
+ return;
+
+ }
+ // CraftBukkit end
+
entity.enderTeleportTo((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D);
}