Scissors/patches/server/0027-Add-spectator-teleport-event.patch
2023-11-12 19:35:20 -06:00

31 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 65bb221993147a558995b36fb835f7b82e0eb4bd..4ea2c551d924f976a8de9e2ae521544f323fbec4 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.authlib.GameProfile;
@@ -2006,6 +2007,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
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;
}