2022-07-28 03:57:50 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2023-09-24 21:42:28 +00:00
|
|
|
From: Telesphoreo <me@telesphoreo.me>
|
|
|
|
Date: Sun, 24 Sep 2023 16:19:52 -0500
|
2022-07-28 03:57:50 +00:00
|
|
|
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
|
2023-09-24 21:42:28 +00:00
|
|
|
index b5fe3786b337fb99920aac72b865e6a25bcb9649..8e1b95371ed0bac1a4fff2d6550de118ba399650 100644
|
2022-07-28 03:57:50 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2023-09-24 21:42:28 +00:00
|
|
|
@@ -29,6 +29,7 @@ import java.util.function.UnaryOperator;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
+import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent;
|
|
|
|
import net.minecraft.ChatFormatting;
|
|
|
|
import net.minecraft.SharedConstants;
|
|
|
|
import net.minecraft.Util;
|
|
|
|
@@ -2005,6 +2006,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
2022-07-28 03:57:50 +00:00
|
|
|
Entity entity = packet.getEntity(worldserver);
|
|
|
|
|
|
|
|
if (entity != null) {
|
|
|
|
+ // Scissors start - Add spectator teleport event
|
|
|
|
+ final SpectatorTeleportEvent event = new SpectatorTeleportEvent(this.player.getBukkitEntity(), entity.getBukkitEntity());
|
2023-09-24 21:42:28 +00:00
|
|
|
+ if (!event.callEvent()) {
|
2022-07-28 03:57:50 +00:00
|
|
|
+ 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;
|
|
|
|
}
|