blob: bbfe5bf1696691ffd02b813f9abbc3d618ca1896 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
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..2815c5802eb38e5a48f9db42b9247e24c27db134
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkLoadEvent.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.jspecify.annotations.NullMarked;
+
+/**
+ * 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.
+ */
+@NullMarked
+public class PlayerChunkLoadEvent extends ChunkEvent {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Player player;
+
+ @ApiStatus.Internal
+ public PlayerChunkLoadEvent(final Chunk chunk, final Player player) {
+ super(chunk);
+ this.player = player;
+ }
+
+ public Player getPlayer() {
+ return this.player;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ 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..3ebb35b680193109cc751398675e935eed746750
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/packet/PlayerChunkUnloadEvent.java
@@ -0,0 +1,41 @@
+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.jspecify.annotations.NullMarked;
+
+/**
+ * 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.
+ */
+@NullMarked
+public class PlayerChunkUnloadEvent extends ChunkEvent {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Player player;
+
+ @ApiStatus.Internal
+ public PlayerChunkUnloadEvent(final Chunk chunk, final Player player) {
+ super(chunk);
+ this.player = player;
+ }
+
+ public Player getPlayer() {
+ return this.player;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+}
|