Paper/nms-patches/CommandTeleport.patch

49 lines
2.1 KiB
Diff
Raw Normal View History

2017-06-04 00:39:36 +02:00
--- a/net/minecraft/server/CommandTeleport.java
+++ b/net/minecraft/server/CommandTeleport.java
2018-12-25 22:00:00 +01:00
@@ -12,6 +12,11 @@
import java.util.Iterator;
import java.util.Set;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.event.entity.EntityTeleportEvent;
+// CraftBukkit end
public class CommandTeleport {
2020-06-25 02:00:00 +02:00
@@ -128,9 +133,9 @@
}
2018-08-26 04:00:00 +02:00
2020-06-25 02:00:00 +02:00
if (worldserver == entity.world) {
- ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set);
+ ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
} else {
- ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1);
+ ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
}
2017-06-04 00:39:36 +02:00
2020-06-25 02:00:00 +02:00
entity.setHeadRotation(f);
@@ -139,6 +144,21 @@
float f3 = MathHelper.g(f1);
2020-06-25 02:00:00 +02:00
f3 = MathHelper.a(f3, -90.0F, 90.0F);
+ // CraftBukkit start - Teleport event
+ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f3);
+ EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to);
+ worldserver.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+
2020-06-25 02:00:00 +02:00
+ d0 = to.getX();
+ d1 = to.getY();
+ d2 = to.getZ();
+ f2 = to.getYaw();
+ f3 = to.getPitch();
+ worldserver = ((CraftWorld) to.getWorld()).getHandle();
+ // CraftBukkit end
if (worldserver == entity.world) {
entity.setPositionRotation(d0, d1, d2, f2, f3);
entity.setHeadRotation(f2);