Scissors/patches/server/0029-Add-spectator-teleport-event.patch
Luna 41e0723e0e
Patch cleanup 2 (#112)
* First pass

* Second pass

* Limit string tag visitors to 1024 elements

* Split configuration patch into multiple patches

* Third and final pass

* Fix build error
2023-07-01 15:21:13 -05:00

33 lines
1.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Tue, 5 Jul 2022 04:12:31 +0100
Subject: [PATCH] Add spectator teleport event
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index a38c677b01dc4a18ac63d2e5f63cd40d07cc02d9..871f060682a7ff9772d09c0a6afbd55c8360e296 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1,5 +1,6 @@
package net.minecraft.server.network;
+import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
import com.google.common.collect.Lists;
import com.google.common.primitives.Floats;
import com.mojang.brigadier.ParseResults;
@@ -2070,6 +2071,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
Entity entity = packet.getEntity(worldserver);
if (entity != null) {
+ // Scissors start - Add spectator teleport event
+ final SpectatorTeleportEvent event = new SpectatorTeleportEvent(this.player.getBukkitEntity(), entity.getBukkitEntity());
+
+ if(!event.callEvent()) {
+ return;
+ }
+ // Scissors end
+
this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit
return;
}