Here we go 1.19.4

This commit is contained in:
Cryptite
2023-04-10 07:26:32 -05:00
parent 67fbb12ac6
commit 00bd3e0d3c
37 changed files with 9 additions and 2461 deletions

View File

@@ -1,39 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tom <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 08:20:02 -0500
Subject: [PATCH] Set BlockData without light updates
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
index 9930ebe7a23d306c602840fd43652fbdaba481b3..ed65bb8867bc2b8e67726dee07a82ac3671b0306 100644
--- a/src/main/java/org/bukkit/block/Block.java
+++ b/src/main/java/org/bukkit/block/Block.java
@@ -297,6 +297,28 @@ public interface Block extends Metadatable, net.kyori.adventure.translation.Tran
*/
void setBlockData(@NotNull BlockData data, boolean applyPhysics);
+ /**
+ * Sets the complete data for this block
+ *
+ * <br>
+ * Note that applyPhysics = false is not in general safe. It should only be
+ * used when you need to avoid triggering a physics update of neighboring
+ * blocks, for example when creating a {@link Bisected} block. If you are
+ * using a custom populator, then this parameter may also be required to
+ * prevent triggering infinite chunk loads on border blocks. This method
+ * should NOT be used to "hack" physics by placing blocks in impossible
+ * locations. Such blocks are liable to be removed on various events such as
+ * world upgrades. Furthermore setting large amounts of such blocks in close
+ * proximity may overload the server physics engine if an update is
+ * triggered at a later point. If this occurs, the resulting behavior is
+ * undefined.
+ *
+ * @param data new block specific data
+ * @param applyPhysics false to cancel physics from the changed block
+ * @param checkLight false to prevent a light-check update
+ */
+ void setBlockData(@NotNull BlockData data, boolean applyPhysics, boolean checkLight);
+
/**
* Sets the type of this block
*

View File

@@ -1,79 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 09:54:07 -0500
Subject: [PATCH] Add BlockDestroyedByNeighborEvent
diff --git a/src/main/java/io/papermc/paper/event/block/BlockDestroyedByNeighborEvent.java b/src/main/java/io/papermc/paper/event/block/BlockDestroyedByNeighborEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..7db2789d54a609b023ea6deff87b45d717aabbf0
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/BlockDestroyedByNeighborEvent.java
@@ -0,0 +1,67 @@
+package io.papermc.paper.event.block;
+
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Called when a block is broken another block. This is generally the result of BlockPhysicsEvent propagation
+ */
+public class BlockDestroyedByNeighborEvent extends BlockEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private final Player player;
+ private final Block sourceBlock;
+ private boolean cancel;
+
+ public BlockDestroyedByNeighborEvent(@NotNull final Block theBlock, @Nullable Player player, @NotNull final Block sourceBlock) {
+ super(theBlock);
+
+ this.player = player;
+ this.sourceBlock = sourceBlock;
+ }
+
+ /**
+ * Gets the Player that caused this
+ *
+ * @return The Player that is breaking the block involved in this event
+ */
+ @Nullable
+ public Player getPlayer() {
+ return player;
+ }
+
+ /**
+ * Gets the source block that caused this block break
+ *
+ * @return The Source Block which block is involved in this event
+ */
+ @NotNull
+ public final Block getSourceBlock() {
+ return sourceBlock;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ @Override
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}

View File

@@ -1,31 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:40:48 -0500
Subject: [PATCH] Add provided Material to getDrops
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
index ed65bb8867bc2b8e67726dee07a82ac3671b0306..3da43fba552b1cb16b9a5480c46a5d0ea0f9c087 100644
--- a/src/main/java/org/bukkit/block/Block.java
+++ b/src/main/java/org/bukkit/block/Block.java
@@ -639,6 +639,20 @@ public interface Block extends Metadatable, net.kyori.adventure.translation.Tran
@NotNull
Collection<ItemStack> getDrops(@NotNull ItemStack tool, @Nullable Entity entity);
+ // Slice start
+ /**
+ * Returns a list of items which would drop by the entity destroying this
+ * block as though it were a given Material with a specific tool
+ *
+ * @param blockType The block type to use as the source loot
+ * @param tool The tool or item in hand used for digging
+ * @param entity the entity destroying the block
+ * @return a list of dropped items for this type of block
+ */
+ @NotNull
+ Collection<ItemStack> getDrops(@NotNull Material blockType, @NotNull ItemStack tool, @Nullable Entity entity);
+ // Slice end
+
/**
* Returns if the given item is a preferred choice to break this Block.
*

View File

@@ -1,52 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:41:44 -0500
Subject: [PATCH] Add Player to SpongeAbsorbEvent
diff --git a/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java b/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java
index 7029cfcd00ed5d9c7f06898ec2b81238ec775a70..0e2f21e0f1983d2e8b67deebf4d12d25107d1582 100644
--- a/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java
+++ b/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java
@@ -7,6 +7,7 @@ import org.bukkit.block.BlockState;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; // Paper
/**
* Called when a sponge absorbs water from the world.
@@ -21,11 +22,13 @@ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
+ private final org.bukkit.entity.Player player; // Paper
private final List<BlockState> blocks;
- public SpongeAbsorbEvent(@NotNull Block block, @NotNull List<BlockState> waterblocks) {
+ public SpongeAbsorbEvent(@NotNull Block block, @Nullable org.bukkit.entity.Player player, @NotNull List<BlockState> waterblocks) { // Paper
super(block);
this.blocks = waterblocks;
+ this.player = player; // Paper
}
/**
@@ -41,6 +44,18 @@ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable {
return blocks;
}
+ // Paper start
+ /**
+ * Gets the Player that placed the Sponge Block
+ *
+ * @return The Player that placed the sponge block causing the absorb event, or null if no Player was involved
+ */
+ @Nullable
+ public org.bukkit.entity.Player getPlayer() {
+ return player;
+ }
+ // Paper end
+
@Override
public boolean isCancelled() {
return cancelled;

View File

@@ -1,22 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:45:51 -0500
Subject: [PATCH] Add World Instance flag
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index e8c0c853eb52d1473c20231660355f77b1f7e016..02e524f718566a13880c9417518ebaeca816a8fc 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -2591,6 +2591,11 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
*/
public void setAutoSave(boolean value);
+ // Slice start
+ public boolean isInstance();
+ public void setInstance(boolean value);
+ // Slice end
+
/**
* Sets the Difficulty of the world.
*

View File

@@ -1,133 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tom <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:52:37 -0500
Subject: [PATCH] Add player data saving events
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadDataEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadDataEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..ae0132d9c7ae17b478d1d504961e1fd6b479f6d0
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadDataEvent.java
@@ -0,0 +1,63 @@
+package com.destroystokyo.paper.event.player;
+
+import com.google.gson.JsonObject;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.UUID;
+
+/**
+ * Calls an event in which playerdata can be provided. If null, will load from disk, otherwise will use provided data
+ */
+public class PlayerLoadDataEvent extends Event {
+ private static final HandlerList handlers = new HandlerList();
+ private final UUID playerId;
+ private Object playerData;
+ private JsonObject statistics;
+
+ public PlayerLoadDataEvent(@NotNull UUID playerId) {
+ super();
+ this.playerId = playerId;
+ }
+
+ /**
+ * Gets the player's unique ID.
+ *
+ * @return The unique ID
+ */
+ @NotNull
+ public UUID getUniqueId() {
+ return playerId;
+ }
+
+ @Nullable
+ public Object getPlayerData() {
+ return playerData;
+ }
+
+ public void setPlayerData(@NotNull Object playerData) {
+ this.playerData = playerData;
+ }
+
+ @Nullable
+ public JsonObject getStatistics() {
+ return statistics;
+ }
+
+ public void setStatistics(@NotNull JsonObject statistics) {
+ this.statistics = statistics;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerSaveDataEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerSaveDataEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..c706201394d89f4a6f795ebbbac3d1041f395104
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerSaveDataEvent.java
@@ -0,0 +1,52 @@
+package com.destroystokyo.paper.event.player;
+
+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;
+
+/**
+ * Calls whenever playerdata is attempted to be saved. This is fired even if SpigotConfig.disablePlayerDataSaving is true
+ */
+public class PlayerSaveDataEvent extends Event implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private final Player player;
+ private boolean cancel;
+
+ public PlayerSaveDataEvent(@NotNull Player player) {
+ super();
+ this.player = player;
+ }
+
+ /**
+ * Gets the player
+ *
+ * @return The player
+ */
+ @NotNull
+ public Player getPlayer() {
+ return player;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+}

View File

@@ -1,65 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 11:00:39 -0500
Subject: [PATCH] Add PlayerGetRespawnLocationEvent
diff --git a/src/main/java/org/bukkit/event/player/PlayerGetRespawnLocationEvent.java b/src/main/java/org/bukkit/event/player/PlayerGetRespawnLocationEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..7eca4d6929fc7a75974d182c1ea692d3823a19c0
--- /dev/null
+++ b/src/main/java/org/bukkit/event/player/PlayerGetRespawnLocationEvent.java
@@ -0,0 +1,53 @@
+package org.bukkit.event.player;
+
+import org.apache.commons.lang3.Validate;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Called when a respawn event tries to determine the location of a respawn
+ */
+public class PlayerGetRespawnLocationEvent extends PlayerEvent {
+ private static final HandlerList handlers = new HandlerList();
+ private Location respawnLocation;
+
+ public PlayerGetRespawnLocationEvent(@NotNull final Player respawnPlayer) {
+ super(respawnPlayer);
+ }
+
+ /**
+ * Gets the current respawn location
+ *
+ * @return Location current respawn location
+ */
+ @Nullable
+ public Location getRespawnLocation() {
+ return this.respawnLocation;
+ }
+
+ /**
+ * Sets the new respawn location
+ *
+ * @param respawnLocation new location for the respawn
+ */
+ public void setRespawnLocation(@NotNull Location respawnLocation) {
+ Validate.notNull(respawnLocation, "Respawn location can not be null");
+ Validate.notNull(respawnLocation.getWorld(), "Respawn world can not be null");
+
+ this.respawnLocation = respawnLocation;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}

View File

@@ -1,35 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Sat, 13 Aug 2022 08:40:03 -0500
Subject: [PATCH] Set multiple Team settings at once
diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java
index 06a5d3177ca7ab90c3fd9d2053b2ec5e887c7c62..31e2756c134462debfcfa768d2d0ccb988046d72 100644
--- a/src/main/java/org/bukkit/scoreboard/Team.java
+++ b/src/main/java/org/bukkit/scoreboard/Team.java
@@ -532,6 +532,24 @@ public interface Team {
boolean hasEntity(@NotNull org.bukkit.entity.Entity entity) throws IllegalStateException, IllegalArgumentException;
// Paper end
+ //Slice start
+ /**
+ * Fully set all team options, combining all 5 options into one packet send, rather than one packet sent
+ * for every single option change.
+ * @param displayName New display name
+ * @param prefix New prefix
+ * @param suffix New suffix
+ * @param color new color
+ * @param options A Paired list of options
+ * @throws IllegalStateException
+ */
+ void teamOptions(net.kyori.adventure.text.Component displayName,
+ net.kyori.adventure.text.Component prefix,
+ net.kyori.adventure.text.Component suffix,
+ net.kyori.adventure.text.format.NamedTextColor color,
+ java.util.List<org.apache.commons.lang3.tuple.Pair<Option, OptionStatus>> options) throws IllegalStateException;
+ //Slice end
+
/**
* Represents an option which may be applied to this team.
*/

View File

@@ -1,30 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Sat, 13 Aug 2022 08:58:21 -0500
Subject: [PATCH] Smooth Teleports
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 1e27b9de47f111b9c000243214e22890e323f7fc..39c65831f38b3992c52f35abcc4aab1d2e09473c 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -2763,6 +2763,19 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
String getClientBrandName();
// Paper end
+ /**
+ * This abuses some of how Minecraft works and allows teleporting a player to another world without
+ * triggering typical respawn packets. All of natural state of chunk resends, entity adds/removes, etc still
+ * happen but the visual "refresh" of a world change is hidden. Depending on the destination location/world,
+ * this can act as a "smooth teleport" to a world if the new world is very similar looking to the old one.
+ *
+ * @param location New location to teleport this Player to
+ */
+ // Slice start
+ @org.jetbrains.annotations.ApiStatus.Experimental
+ void teleportWithoutRespawn(Location location);
+ // Slice end
+
// Paper start - Teleport API
/**
* Sets the player's rotation.

View File

@@ -1,149 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 18 Nov 2022 08:02:12 -0600
Subject: [PATCH] Equipment Packet Caching
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 97336be470a9d545d93f78e683a793f328013ad8..d57ff4b918e3c6e97b2d0664394c7faf46aa3b00 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -1059,4 +1059,11 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
*/
void damageItemStack(org.bukkit.inventory.@NotNull EquipmentSlot slot, int amount);
// Paper end
+
+ // Slice start
+ /**
+ * @param p The player to send this entity's equipment packet to
+ */
+ void sendEquipment(Player p);
+ // Slice end
}
diff --git a/src/main/java/org/bukkit/event/entity/EntityEquipmentItemLookup.java b/src/main/java/org/bukkit/event/entity/EntityEquipmentItemLookup.java
new file mode 100644
index 0000000000000000000000000000000000000000..6c329ca3c22d1fd712041334c5c1e7bd7e7201ac
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/EntityEquipmentItemLookup.java
@@ -0,0 +1,54 @@
+package org.bukkit.event.entity;
+
+import org.bukkit.entity.Entity;
+import org.bukkit.event.HandlerList;
+import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Called when requesting a cached equipment item lookup
+ */
+public class EntityEquipmentItemLookup extends EntityEvent {
+ private static final HandlerList handlers = new HandlerList();
+ private final String tag;
+ private final EquipmentSlot equipmentSlot;
+ private ItemStack itemStack;
+
+ public EntityEquipmentItemLookup(@NotNull final Entity entity, @NotNull String tag, @NotNull EquipmentSlot slot, @NotNull final ItemStack itemStack) {
+ super(entity);
+ this.tag = tag;
+ this.equipmentSlot = slot;
+ this.itemStack = itemStack;
+ }
+
+ @NotNull
+ public ItemStack getItemStack() {
+ return itemStack;
+ }
+
+ public void setItemStack(ItemStack itemStack) {
+ this.itemStack = itemStack;
+ }
+
+ @NotNull
+ public EquipmentSlot getEquipmentSlot() {
+ return equipmentSlot;
+ }
+
+ @NotNull
+ public String getTag() {
+ return tag;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/player/PlayerReceiveEquipmentEvent.java b/src/main/java/org/bukkit/event/player/PlayerReceiveEquipmentEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..513d62342d8e29e8d3c92fe932d0d77f659cf2f1
--- /dev/null
+++ b/src/main/java/org/bukkit/event/player/PlayerReceiveEquipmentEvent.java
@@ -0,0 +1,61 @@
+package org.bukkit.event.player;
+
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Called when a player is about to receive an equipment packet about another player
+ */
+public class PlayerReceiveEquipmentEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private final Entity tracked;
+ private boolean cancel;
+ private String tag;
+
+ public PlayerReceiveEquipmentEvent(@NotNull final Player player, @NotNull final Entity tracked) {
+ super(player);
+ this.tracked = tracked;
+ }
+
+ /**
+ * Gets the tracked entity
+ *
+ * @return Entity the player is now tracking
+ */
+ @NotNull
+ public Entity getTracked() {
+ return tracked;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}

View File

@@ -1,21 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 18 Nov 2022 08:03:20 -0600
Subject: [PATCH] AntiXray Bypass
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 39c65831f38b3992c52f35abcc4aab1d2e09473c..8c101c66b2c8d7044d29474e37c10838ee3e5d0c 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -2543,6 +2543,10 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
*/
boolean hasResourcePack();
+ // Slice start
+ void toggleAntiXrayBypass(boolean bypass);
+ // Slice end
+
/**
* Gets a copy of this players profile
* @return The players profile object

View File

@@ -1,95 +0,0 @@
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.