mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 20:50:41 +01:00
SPIGOT-1644: Fire PlayerTeleportEvent with reason END_GATEWAY for end gateways
This commit is contained in:
parent
bad994e724
commit
3f534696a3
1 changed files with 40 additions and 0 deletions
40
nms-patches/TileEntityEndGateway.patch
Normal file
40
nms-patches/TileEntityEndGateway.patch
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
--- a/net/minecraft/server/TileEntityEndGateway.java
|
||||||
|
+++ b/net/minecraft/server/TileEntityEndGateway.java
|
||||||
|
@@ -5,6 +5,10 @@
|
||||||
|
import java.util.Random;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
+import org.bukkit.Location;
|
||||||
|
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
|
+import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
|
public class TileEntityEndGateway extends TileEntity implements ITickable {
|
||||||
|
|
||||||
|
@@ -103,6 +107,26 @@
|
||||||
|
if (this.h != null) {
|
||||||
|
BlockPosition blockposition = this.i ? this.h : this.j();
|
||||||
|
|
||||||
|
+ // 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.h();
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
|
entity.enderTeleportTo((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue