96 lines
2.8 KiB
Diff
96 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cryptite <cryptite@gmail.com>
|
|
Date: Fri, 18 Nov 2022 08:06:32 -0600
|
|
Subject: [PATCH] PlayerPreChunkLoadEvent
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerPreChunkLoadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerPreChunkLoadEvent.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..b5cc9538a70c7ce0b494d4878d51b52134c2fd75
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/papermc/paper/event/packet/PlayerPreChunkLoadEvent.java
|
|
@@ -0,0 +1,69 @@
|
|
+package io.papermc.paper.event.packet;
|
|
+
|
|
+import org.bukkit.Chunk;
|
|
+import org.bukkit.World;
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.event.Cancellable;
|
|
+import org.bukkit.event.Event;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+/**
|
|
+ * Is called when a {@link Player} is about to receive a {@link Chunk}
|
|
+ * <p>
|
|
+ * Can be cancelled, but only use if you really really mean it.
|
|
+ */
|
|
+public class PlayerPreChunkLoadEvent extends Event implements Cancellable {
|
|
+
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private final World world;
|
|
+ private final int chunkX;
|
|
+ private final int chunkZ;
|
|
+ private final Player player;
|
|
+ private boolean cancel;
|
|
+
|
|
+ public PlayerPreChunkLoadEvent(World world, int chunkX, int chunkZ, @NotNull Player player) {
|
|
+ this.world = world;
|
|
+ this.chunkX = chunkX;
|
|
+ this.chunkZ = chunkZ;
|
|
+ this.player = player;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public World getWorld() {
|
|
+ return world;
|
|
+ }
|
|
+
|
|
+ public int getChunkX() {
|
|
+ return chunkX;
|
|
+ }
|
|
+
|
|
+ public int getChunkZ() {
|
|
+ return chunkZ;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public Player getPlayer() {
|
|
+ return player;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCancelled() {
|
|
+ return cancel;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ this.cancel = cancel;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
\ No newline at end of file
|
|
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
|
index adb5fcbacf5fa284e4c6efc1dcc0f30f3932761c..27f6db119f0c720e191ba7f9b64d8aded972a8f9 100644
|
|
--- a/src/main/java/org/bukkit/World.java
|
|
+++ b/src/main/java/org/bukkit/World.java
|
|
@@ -515,6 +515,8 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
|
//@Deprecated // Paper
|
|
public boolean refreshChunk(int x, int z);
|
|
|
|
+ it.unimi.dsi.fastutil.longs.LongOpenHashSet getSentChunks(Player p); // Slice
|
|
+
|
|
/**
|
|
* Gets whether the chunk at the specified chunk coordinates is force
|
|
* loaded.
|