9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-30 04:19:13 +00:00
Files
Leaf/leaf-server/paper-patches/features/0049-PlayerInventoryOverflowEvent.patch
Dreeam ae57aa904e Updated Upstream (Paper/Purpur)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@1fcc4162 Implement FeatureHooks#isChunkSent for Moonrise chunk system
PaperMC/Paper@e4d7178a Implement WaypointTransmitter#isChunkVisible
PaperMC/Paper@8980ead7 Directly walk text component after converting from JSON
PaperMC/Paper@5613ed6d Provide env environment variable and copy spigots sys prop for overriding default repository
PaperMC/Paper@62b7f86d Avoid and discourage use of Maven Central as a CDN (#12689)
PaperMC/Paper@f5534cb7 [ci/skip] Run generators (#12691)
PaperMC/Paper@4781d28b Re-add Log4j Javadocs (#12693)
PaperMC/Paper@74fbcce5 Check type of Material in get/set stats (#12607)
PaperMC/Paper@4b3f967e Improve Fix MC-44654 (#12703)
PaperMC/Paper@a7dd2635 Enable spigot obfuscation support (#12695)
PaperMC/Paper@6a51c44e Cleanup Primed TNT Fix (#12704)
PaperMC/Paper@839c6a18 Fix #11169 (#12706)
PaperMC/Paper@c77d5f99 Fix MC-297591
PaperMC/Paper@219f86ee Implement chunk unload delay config option
PaperMC/Paper@e4eb69b8 Do not allow ticket level decreases to be processed asynchronously
PaperMC/Paper@71b0c768 Adds support for vanilla negative explosions (#12705)
PaperMC/Paper@3750927a [ci/skip] Fix PermissionManager#clearPermissions() docs bad wording (#12657)
PaperMC/Paper@d61a51e8 Add ItemType#getBurnDuration() (#12604)
PaperMC/Paper@29fc8532 Allow empty paths in namespaced keys (#12687)
PaperMC/Paper@4419afb9 fix: Safely handle nanosecond overflow in ClickCallback (#12686)
PaperMC/Paper@56528821 Add `isProxyEnabled` method to ServerConfiguration (#12664)
PaperMC/Paper@c0dda0ea Add `isForceDefaultGameMode` method (#12673)
PaperMC/Paper@e714de63 Fix excess slot updates
PaperMC/Paper@6d0821d2 [ci/skip] Fix docs for Spawner class and cleanup (#12710)
PaperMC/Paper@cceffe3d Release ItemType and BlockType (#12708)
PaperMC/Paper@186e9e33 Relocate CommandMap#registerServerAliases() call to after lifecycle events have been run (#12601)
PaperMC/Paper@5edcf6dd Cleanup/command dispatching (#12713)

Purpur Changes:
PurpurMC/Purpur@baa196f5 Updated Upstream (Paper)
PurpurMC/Purpur@fdd1e980 Updated Upstream (Paper)
PurpurMC/Purpur@439f15db Updated Upstream (Paper)
PurpurMC/Purpur@46a28b93 [ci/skip] update version in README
PurpurMC/Purpur@162bd288 Updated Upstream (Paper)
PurpurMC/Purpur@afcdf9bb Updated Upstream (Paper)
2025-06-22 13:51:17 +08:00

60 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Wed, 19 Feb 2025 00:36:20 -0500
Subject: [PATCH] PlayerInventoryOverflowEvent
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
index 19180c08f41db939c1a9f0caeb62e5beb1117f69..aff8d16b17992f3228eb9fe8f2bd01d2d7aeea54 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
@@ -340,9 +340,48 @@ public class CraftInventory implements Inventory {
}
}
}
+
+ // Leaf start - PlayerInventoryOverflowEvent
+ if (isListeningInventoryOverflowEvent()
+ && !leftover.isEmpty() && this.inventory instanceof net.minecraft.world.entity.player.Inventory && this.inventory.getOwner() instanceof org.bukkit.entity.Player player) {
+ new org.dreeam.leaf.event.player.PlayerInventoryOverflowEvent(player, leftover).callEvent();
+
+ return new HashMap<>();
+ }
+ // Leaf end - PlayerInventoryOverflowEvent
+
return leftover;
}
+ // Leaf start - PlayerInventoryOverflowEvent
+ private static boolean isListeningInventoryOverflowEvent() {
+ if (org.dreeam.leaf.event.player.PlayerInventoryOverflowEvent.isListeningInvOverflowCached == -1) {
+ org.dreeam.leaf.event.player.PlayerInventoryOverflowEvent.isListeningInvOverflowCached = 0;
+
+ if (!org.dreeam.leaf.config.modules.gameplay.ConfigurableInventoryOverflowEvent.enabled) {
+ return false;
+ }
+
+ org.bukkit.plugin.RegisteredListener[] listeners = org.dreeam.leaf.event.player.PlayerInventoryOverflowEvent.getHandlerList().getRegisteredListeners();
+ if (listeners.length == 1) {
+ if (listeners[0].getListener().getClass().getName().equals(org.dreeam.leaf.config.modules.gameplay.ConfigurableInventoryOverflowEvent.listenerClass)) {
+ org.dreeam.leaf.event.player.PlayerInventoryOverflowEvent.isListeningInvOverflowCached = 1;
+ return true;
+ }
+ } else if (listeners.length > 1) {
+ for (org.bukkit.plugin.RegisteredListener registeredListener : listeners) {
+ if (registeredListener.getListener().getClass().getName().equals(org.dreeam.leaf.config.modules.gameplay.ConfigurableInventoryOverflowEvent.listenerClass)) {
+ org.dreeam.leaf.event.player.PlayerInventoryOverflowEvent.isListeningInvOverflowCached = 1;
+ return true;
+ }
+ }
+ }
+ }
+
+ return org.dreeam.leaf.event.player.PlayerInventoryOverflowEvent.isListeningInvOverflowCached == 1;
+ }
+ // Leaf end - PlayerInventoryOverflowEvent
+
@Override
public HashMap<Integer, ItemStack> removeItem(ItemStack... items) {
// Paper start