2021-03-15 23:00:00 +01:00
--- a/net/minecraft/server/commands/CommandTeleport.java
+++ b/net/minecraft/server/commands/CommandTeleport.java
2021-11-21 23:00:00 +01:00
@@ -35,6 +35,12 @@
2021-03-15 23:00:00 +01:00
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
2021-03-08 22:47:33 +01:00
2018-09-07 12:32:57 +02:00
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.event.entity.EntityTeleportEvent;
+// CraftBukkit end
2021-03-08 22:47:33 +01:00
+
2018-09-07 12:32:57 +02:00
public class CommandTeleport {
2022-06-07 18:00:00 +02:00
private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(IChatBaseComponent.translatable("commands.teleport.invalidPosition"));
2021-11-21 23:00:00 +01:00
@@ -159,14 +165,29 @@
2020-06-25 02:00:00 +02:00
}
2018-08-26 04:00:00 +02:00
2021-06-11 07:00:00 +02:00
if (worldserver == entity.level) {
2021-11-21 23:00:00 +01:00
- ((EntityPlayer) entity).connection.teleport(d0, d1, d2, f2, f3, set);
+ ((EntityPlayer) entity).connection.teleport(d0, d1, d2, f2, f3, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
2020-06-25 02:00:00 +02:00
} else {
2021-11-21 23:00:00 +01:00
- ((EntityPlayer) entity).teleportTo(worldserver, d0, d1, d2, f2, f3);
+ ((EntityPlayer) entity).teleportTo(worldserver, d0, d1, d2, f2, f3, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
2020-06-25 02:00:00 +02:00
}
2017-06-04 00:39:36 +02:00
2021-11-21 23:00:00 +01:00
entity.setYHeadRot(f2);
2021-06-11 07:00:00 +02:00
} else {
2021-11-21 23:00:00 +01:00
float f4 = MathHelper.clamp(f3, -90.0F, 90.0F);
2020-06-25 02:00:00 +02:00
+ // CraftBukkit start - Teleport event
2021-06-11 07:00:00 +02:00
+ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f4);
2020-06-25 02:00:00 +02:00
+ EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to);
2021-06-11 13:33:49 +02:00
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
2020-06-25 02:00:00 +02:00
+ if (event.isCancelled()) {
+ return;
+ }
2018-09-07 12:32:57 +02:00
+
2020-06-25 02:00:00 +02:00
+ d0 = to.getX();
+ d1 = to.getY();
+ d2 = to.getZ();
+ f2 = to.getYaw();
2021-06-11 07:00:00 +02:00
+ f4 = to.getPitch();
2020-06-25 02:00:00 +02:00
+ worldserver = ((CraftWorld) to.getWorld()).getHandle();
+ // CraftBukkit end
2021-06-11 07:00:00 +02:00
if (worldserver == entity.level) {
2021-11-21 23:00:00 +01:00
entity.moveTo(d0, d1, d2, f2, f4);