aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0259-Call-player-spectator-target-events-and-improve-impl.patch
diff options
context:
space:
mode:
authorRiley Park <[email protected]>2024-05-15 17:06:59 -0700
committerGitHub <[email protected]>2024-05-15 17:06:59 -0700
commitf17519338bc589c045e0b32bfc37e048b23544d5 (patch)
treee50182ec698b4a9de8f366f485ee089b1901bbd9 /patches/server/0259-Call-player-spectator-target-events-and-improve-impl.patch
parent3fc93581bb876e8149b2ca423375a98f5ca12d27 (diff)
downloadPaper-f17519338bc589c045e0b32bfc37e048b23544d5.tar.gz
Paper-f17519338bc589c045e0b32bfc37e048b23544d5.zip
Expose server build information (#10729)
* Expose server build information * squash patches * final tweaks --------- Co-authored-by: Jake Potrebic <[email protected]> Co-authored-by: masmc05 <[email protected]>
Diffstat (limited to 'patches/server/0259-Call-player-spectator-target-events-and-improve-impl.patch')
-rw-r--r--patches/server/0259-Call-player-spectator-target-events-and-improve-impl.patch46
1 files changed, 46 insertions, 0 deletions
diff --git a/patches/server/0259-Call-player-spectator-target-events-and-improve-impl.patch b/patches/server/0259-Call-player-spectator-target-events-and-improve-impl.patch
new file mode 100644
index 0000000000..ab2281ee82
--- /dev/null
+++ b/patches/server/0259-Call-player-spectator-target-events-and-improve-impl.patch
@@ -0,0 +1,46 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Caleb Bassham <[email protected]>
+Date: Fri, 28 Sep 2018 02:32:19 -0500
+Subject: [PATCH] Call player spectator target events and improve
+ implementation
+
+Use a proper teleport for teleporting to entities in different
+worlds.
+
+Implementation improvements authored by Spottedleaf <[email protected]>
+Validate that the target entity is valid and deny spectate
+requests from frozen players.
+
+Also, make sure the entity is spawned to the client before
+sending the camera packet. If the entity isn't spawned clientside
+when it receives the camera packet, then the client will not
+spectate the target entity.
+
+Co-authored-by: Spottedleaf <[email protected]>
+
+diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
+index a0801437d631b148d435b3700e60f97f95e2bb92..7076801dce113004b255866c659bdc5e29d8e951 100644
+--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
+@@ -2133,6 +2133,21 @@ public class ServerPlayer extends Player {
+
+ this.camera = (Entity) (entity == null ? this : entity);
+ if (entity1 != this.camera) {
++ // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity
++ if (this.camera == this) {
++ com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent playerStopSpectatingEntityEvent = new com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent(this.getBukkitEntity(), entity1.getBukkitEntity());
++ if (!playerStopSpectatingEntityEvent.callEvent()) {
++ this.camera = entity1; // rollback camera entity again
++ return;
++ }
++ } else {
++ com.destroystokyo.paper.event.player.PlayerStartSpectatingEntityEvent playerStartSpectatingEntityEvent = new com.destroystokyo.paper.event.player.PlayerStartSpectatingEntityEvent(this.getBukkitEntity(), entity1.getBukkitEntity(), entity.getBukkitEntity());
++ if (!playerStartSpectatingEntityEvent.callEvent()) {
++ this.camera = entity1; // rollback camera entity again
++ return;
++ }
++ }
++ // Paper end - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity
+ Level world = this.camera.level();
+
+ if (world instanceof ServerLevel) {