PaperMC/patches/api/0239-Player-Chunk-Load-Unload-Events.patch
Nassim Jahnke 928bcc8d3a
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
2022-10-02 09:56:36 +02:00

100 lines
3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ysl3000 <yannicklamprecht@live.de>
Date: Mon, 5 Oct 2020 21:24:45 +0200
Subject: [PATCH] Player Chunk Load/Unload Events
diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..2c1cda1126e577a88f19071e958eddb5a38785af
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java
@@ -0,0 +1,42 @@
+package io.papermc.paper.event.packet;
+
+import org.bukkit.Chunk;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.world.ChunkEvent;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Is called when a {@link org.bukkit.entity.Player} receives a {@link org.bukkit.Chunk}
+ * <p>
+ * Can for example be used for spawning a fake entity when the player receives a chunk.
+ *
+ * Should only be used for packet/clientside related stuff.
+ * Not intended for modifying server side state.
+ */
+public class PlayerChunkLoadEvent extends ChunkEvent {
+
+ private static final HandlerList handlers = new HandlerList();
+ private final Player player;
+
+ public PlayerChunkLoadEvent(@NotNull Chunk chunk, @NotNull Player player) {
+ super(chunk);
+ this.player = player;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public Player getPlayer() {
+ return player;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..12163a7b0591a7d022dc7eb9ee6608a1b6c39d9b
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java
@@ -0,0 +1,40 @@
+package io.papermc.paper.event.packet;
+
+import org.bukkit.Chunk;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.world.ChunkEvent;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Is called when a {@link Player} receives a chunk unload packet.
+ *
+ * Should only be used for packet/clientside related stuff.
+ * Not intended for modifying server side.
+ */
+public class PlayerChunkUnloadEvent extends ChunkEvent {
+
+ private static final HandlerList handlers = new HandlerList();
+ private final Player player;
+
+ public PlayerChunkUnloadEvent(@NotNull Chunk chunk, @NotNull Player player) {
+ super(chunk);
+ this.player = player;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public Player getPlayer() {
+ return player;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}