mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Readd Leaves protocols
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
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..9b5c8c4c39657c18e67ad654bd0e5a30c09232c6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
|
||||
@@ -340,9 +340,49 @@ 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
|
||||
Reference in New Issue
Block a user