aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0225-Player-Chunk-Load-Unload-Events.patch
diff options
context:
space:
mode:
authorShane Freeder <[email protected]>2024-05-09 14:51:33 +0100
committerShane Freeder <[email protected]>2024-05-09 14:51:33 +0100
commit3693bbdc6b65e68db10375d3eeab70f06708b729 (patch)
tree4a71a5e6e5f50b3e2937053a5d4b4196ef67665b /patches/api/0225-Player-Chunk-Load-Unload-Events.patch
parentf2512b12385961f8ca1f69efebe5ed0e00c0caa8 (diff)
downloadPaper-3693bbdc6b65e68db10375d3eeab70f06708b729.tar.gz
Paper-3693bbdc6b65e68db10375d3eeab70f06708b729.zip
Use internals for getting block/entity countstimings/use-internals
For a long time I've been meaning to move some of this logic internally as this would allow us to avoid hitting systems like block state snapshots which can create issues as many of the spigot implementations of this stuff are increasingly broken, leading to unexpected crashes during ticking, even if the API cannot properly interact with these such states/items, it's generally more preferable to not crash the server in the course, and just let those interactions fail more gracefully.
Diffstat (limited to 'patches/api/0225-Player-Chunk-Load-Unload-Events.patch')
-rw-r--r--patches/api/0225-Player-Chunk-Load-Unload-Events.patch106
1 files changed, 106 insertions, 0 deletions
diff --git a/patches/api/0225-Player-Chunk-Load-Unload-Events.patch b/patches/api/0225-Player-Chunk-Load-Unload-Events.patch
new file mode 100644
index 0000000000..c1779bb840
--- /dev/null
+++ b/patches/api/0225-Player-Chunk-Load-Unload-Events.patch
@@ -0,0 +1,106 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: ysl3000 <[email protected]>
+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..3ddbc099a13df939b3912f30b54e7635840ba5a4
+--- /dev/null
++++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.java
+@@ -0,0 +1,45 @@
++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.ApiStatus;
++import org.jetbrains.annotations.NotNull;
++
++/**
++ * Is called when a {@link Player} receives a {@link Chunk}
++ * <p>
++ * Can for example be used for spawning a fake entity when the player receives a chunk.
++ * <p>
++ * 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 HANDLER_LIST = new HandlerList();
++
++ private final Player player;
++
++ @ApiStatus.Internal
++ public PlayerChunkLoadEvent(@NotNull Chunk chunk, @NotNull Player player) {
++ super(chunk);
++ this.player = player;
++ }
++
++ @NotNull
++ public Player getPlayer() {
++ return this.player;
++ }
++
++ @NotNull
++ @Override
++ public HandlerList getHandlers() {
++ return HANDLER_LIST;
++ }
++
++ @NotNull
++ public static HandlerList getHandlerList() {
++ return HANDLER_LIST;
++ }
++}
+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..2cac7e27991c04a9ced261f2dd8ad8657ccddf6b
+--- /dev/null
++++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java
+@@ -0,0 +1,43 @@
++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.ApiStatus;
++import org.jetbrains.annotations.NotNull;
++
++/**
++ * Is called when a {@link Player} receives a chunk unload packet.
++ * <p>
++ * Should only be used for packet/clientside related stuff.
++ * Not intended for modifying server side.
++ */
++public class PlayerChunkUnloadEvent extends ChunkEvent {
++
++ private static final HandlerList HANDLER_LIST = new HandlerList();
++
++ private final Player player;
++
++ @ApiStatus.Internal
++ public PlayerChunkUnloadEvent(@NotNull Chunk chunk, @NotNull Player player) {
++ super(chunk);
++ this.player = player;
++ }
++
++ @NotNull
++ public Player getPlayer() {
++ return this.player;
++ }
++
++ @NotNull
++ @Override
++ public HandlerList getHandlers() {
++ return HANDLER_LIST;
++ }
++
++ @NotNull
++ public static HandlerList getHandlerList() {
++ return HANDLER_LIST;
++ }
++}