PaperMC/paper-server/nms-patches/net/minecraft/server/commands/CommandTeleport.patch
CraftBukkit/Spigot 536256d6ff SPIGOT-6508: Rename conflicted getServer
By: md_5 <git@md-5.net>
2021-06-11 21:33:49 +10:00

47 lines
2.2 KiB
Diff

--- a/net/minecraft/server/commands/CommandTeleport.java
+++ b/net/minecraft/server/commands/CommandTeleport.java
@@ -36,6 +36,12 @@
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.event.entity.EntityTeleportEvent;
+// CraftBukkit end
+
public class CommandTeleport {
private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(new ChatMessage("commands.teleport.invalidPosition"));
@@ -160,14 +166,29 @@
}
if (worldserver == entity.level) {
- ((EntityPlayer) entity).connection.a(d0, d1, d2, f2, f3, set);
+ ((EntityPlayer) entity).connection.a(d0, d1, d2, f2, f3, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
} else {
- ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f2, f3);
+ ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f2, f3, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
}
entity.setHeadRotation(f2);
} else {
float f4 = MathHelper.a(f3, -90.0F, 90.0F);
+ // CraftBukkit start - Teleport event
+ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f4);
+ EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to);
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+
+ d0 = to.getX();
+ d1 = to.getY();
+ d2 = to.getZ();
+ f2 = to.getYaw();
+ f4 = to.getPitch();
+ worldserver = ((CraftWorld) to.getWorld()).getHandle();
+ // CraftBukkit end
if (worldserver == entity.level) {
entity.setPositionRotation(d0, d1, d2, f2, f4);