aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0616-Player-Chunk-Load-Unload-Events.patch
blob: a81224c1ab918316f576b009906b165f20512a81 (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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ysl3000 <yannicklamprecht@live.de>
Date: Mon, 5 Oct 2020 21:25:16 +0200
Subject: [PATCH] Player Chunk Load/Unload Events


diff --git a/src/main/java/net/minecraft/server/level/EntityPlayer.java b/src/main/java/net/minecraft/server/level/EntityPlayer.java
index d850721afc33230890353f16c5bc5579c9efb1bf..45c6eb96310146adab802dc3da019f7ee15e0fe5 100644
--- a/src/main/java/net/minecraft/server/level/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/level/EntityPlayer.java
@@ -139,6 +139,8 @@ import net.minecraft.world.scores.ScoreboardScore;
 import net.minecraft.world.scores.ScoreboardTeam;
 import net.minecraft.world.scores.ScoreboardTeamBase;
 import net.minecraft.world.scores.criteria.IScoreboardCriteria;
+import io.papermc.paper.event.packet.PlayerChunkLoadEvent; // Paper
+import io.papermc.paper.event.packet.PlayerChunkUnloadEvent; // Paper
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -2089,11 +2091,21 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
     public void a(ChunkCoordIntPair chunkcoordintpair, Packet<?> packet, Packet<?> packet1) {
         this.playerConnection.sendPacket(packet1);
         this.playerConnection.sendPacket(packet);
+        // Paper start
+        if(PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0){
+            new PlayerChunkLoadEvent(this.getBukkitEntity().getWorld().getChunkAt(chunkcoordintpair.longKey), this.getBukkitEntity()).callEvent();
+        }
+        // Paper end
     }
 
     public void a(ChunkCoordIntPair chunkcoordintpair) {
         if (this.isAlive()) {
             this.playerConnection.sendPacket(new PacketPlayOutUnloadChunk(chunkcoordintpair.x, chunkcoordintpair.z));
+            // Paper start
+            if(PlayerChunkUnloadEvent.getHandlerList().getRegisteredListeners().length > 0){
+                new PlayerChunkUnloadEvent(this.getBukkitEntity().getWorld().getChunkAt(chunkcoordintpair.longKey), this.getBukkitEntity()).callEvent();
+            }
+            // Paper end
         }
 
     }