diff options
author | Nassim Jahnke <[email protected]> | 2022-10-02 09:56:36 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-10-02 09:56:36 +0200 |
commit | 928bcc8d3a058221146cea1de7d42d7e178e78f2 (patch) | |
tree | fdb518a8812097f983c41d36ea693baf5c208554 /patches/server/0271-Call-player-spectator-target-events-and-improve-impl.patch | |
parent | ec3cfa9b7f147cf097692144f665893748fadc3b (diff) | |
download | Paper-928bcc8d3a058221146cea1de7d42d7e178e78f2.tar.gz Paper-928bcc8d3a058221146cea1de7d42d7e178e78f2.zip |
Updated Upstream (Bukkit/CraftBukkit) (#8430)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
09943450 Update SnakeYAML version
5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc
6f82b381 PR-788: Add getHand() to all relevant events
CraftBukkit Changes:
aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe
5329dd6fd PR-1107: Add getHand() to all relevant events
93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
Diffstat (limited to 'patches/server/0271-Call-player-spectator-target-events-and-improve-impl.patch')
-rw-r--r-- | patches/server/0271-Call-player-spectator-target-events-and-improve-impl.patch | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/patches/server/0271-Call-player-spectator-target-events-and-improve-impl.patch b/patches/server/0271-Call-player-spectator-target-events-and-improve-impl.patch new file mode 100644 index 0000000000..f5bd1e340c --- /dev/null +++ b/patches/server/0271-Call-player-spectator-target-events-and-improve-impl.patch @@ -0,0 +1,87 @@ +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 645012ea3590a46773e2bb14e9cafd9e3c695fd4..cb55e38b22330dbc542003841e8140eb6bee01bf 100644 +--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java ++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +@@ -1876,14 +1876,58 @@ public class ServerPlayer extends Player { + } + + public void setCamera(@Nullable Entity entity) { ++ // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Event and improve implementation + Entity entity1 = this.getCamera(); + +- this.camera = (Entity) (entity == null ? this : entity); +- if (entity1 != this.camera) { +- this.connection.send(new ClientboundSetCameraPacket(this.camera)); +- this.connection.teleport(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit ++ if (entity == null) { ++ entity = this; ++ } ++ ++ if (entity1 == entity) return; // new spec target is the current spec target ++ ++ if (entity == this) { ++ com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent playerStopSpectatingEntityEvent = new com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent(this.getBukkitEntity(), entity1.getBukkitEntity()); ++ ++ if (!playerStopSpectatingEntityEvent.callEvent()) { ++ 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()) { ++ return; ++ } ++ } ++ // Validate ++ if (entity != this) { ++ if (entity.isRemoved() || !entity.valid || entity.level == null) { ++ MinecraftServer.LOGGER.info("Blocking player " + this + " from spectating invalid entity " + entity); ++ return; ++ } ++ if (this.isImmobile()) { ++ // use debug: clients might maliciously spam this ++ MinecraftServer.LOGGER.debug("Blocking frozen player " + this + " from spectating entity " + entity); ++ return; ++ } + } + ++ this.camera = entity; // only set after validating state ++ ++ if (entity != this) { ++ // Make sure we're in the right place ++ this.ejectPassengers(); // teleport can fail if we have passengers... ++ this.getBukkitEntity().teleport(new Location(entity.getCommandSenderWorld().getWorld(), entity.getX(), entity.getY(), entity.getZ(), this.getYRot(), this.getXRot()), TeleportCause.SPECTATE); // Correctly handle cross-world entities from api calls by using CB teleport ++ ++ // Make sure we're tracking the entity before sending ++ ChunkMap.TrackedEntity tracker = ((ServerLevel)entity.level).getChunkSource().chunkMap.entityMap.get(entity.getId()); ++ if (tracker != null) { // dumb plugins... ++ tracker.updatePlayer(this); ++ } ++ } else { ++ this.connection.teleport(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit ++ } ++ this.connection.send(new ClientboundSetCameraPacket(entity)); ++ // Paper end + } + + @Override |