diff options
Diffstat (limited to 'patch-remap/og/net/minecraft/server/commands/CommandTeleport.patch')
-rw-r--r-- | patch-remap/og/net/minecraft/server/commands/CommandTeleport.patch | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/server/commands/CommandTeleport.patch b/patch-remap/og/net/minecraft/server/commands/CommandTeleport.patch new file mode 100644 index 0000000000..c96cfba8e5 --- /dev/null +++ b/patch-remap/og/net/minecraft/server/commands/CommandTeleport.patch @@ -0,0 +1,48 @@ +--- a/net/minecraft/server/commands/CommandTeleport.java ++++ b/net/minecraft/server/commands/CommandTeleport.java +@@ -33,6 +33,13 @@ + 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; ++import org.bukkit.event.player.PlayerTeleportEvent; ++// CraftBukkit end ++ + public class CommandTeleport { + + private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(IChatBaseComponent.translatable("commands.teleport.invalidPosition")); +@@ -155,7 +162,30 @@ + float f2 = MathHelper.wrapDegrees(f); + float f3 = MathHelper.wrapDegrees(f1); + +- if (entity.teleportTo(worldserver, d0, d1, d2, set, f2, f3)) { ++ // CraftBukkit start - Teleport event ++ boolean result; ++ if (entity instanceof EntityPlayer player) { ++ result = player.teleportTo(worldserver, d0, d1, d2, set, f2, f3, PlayerTeleportEvent.TeleportCause.COMMAND); ++ } else { ++ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f3); ++ 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(); ++ f3 = to.getPitch(); ++ worldserver = ((CraftWorld) to.getWorld()).getHandle(); ++ ++ result = entity.teleportTo(worldserver, d0, d1, d2, set, f2, f3); ++ } ++ ++ if (result) { ++ // CraftBukkit end + if (commandteleport_a != null) { + commandteleport_a.perform(commandlistenerwrapper, entity); + } |