diff --git a/AuxProtect_1.20/src/main/java/dev/heliosares/auxprotect/utils/InventoryUtil_1_20.java b/AuxProtect_1.20/src/main/java/dev/heliosares/auxprotect/utils/InventoryUtil_1_20.java
index e14c0eb..9ae5049 100644
--- a/AuxProtect_1.20/src/main/java/dev/heliosares/auxprotect/utils/InventoryUtil_1_20.java
+++ b/AuxProtect_1.20/src/main/java/dev/heliosares/auxprotect/utils/InventoryUtil_1_20.java
@@ -1,4 +1,10 @@
package dev.heliosares.auxprotect.utils;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.inventory.Inventory;
+
public class InventoryUtil_1_20 {
+ public static Inventory getTopInventory(HumanEntity player) {
+ return player.getOpenInventory().getTopInventory();
+ }
}
diff --git a/AuxProtect_1.21/src/main/java/dev/heliosares/auxprotect/utils/InventoryUtil_1_21.java b/AuxProtect_1.21/src/main/java/dev/heliosares/auxprotect/utils/InventoryUtil_1_21.java
index 1eecaf1..7139dca 100644
--- a/AuxProtect_1.21/src/main/java/dev/heliosares/auxprotect/utils/InventoryUtil_1_21.java
+++ b/AuxProtect_1.21/src/main/java/dev/heliosares/auxprotect/utils/InventoryUtil_1_21.java
@@ -1,4 +1,10 @@
package dev.heliosares.auxprotect.utils;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.inventory.Inventory;
+
public class InventoryUtil_1_21 {
+ public static Inventory getTopInventory(HumanEntity player) {
+ return player.getOpenInventory().getTopInventory();
+ }
}
diff --git a/AuxProtect_Core/pom.xml b/AuxProtect_Core/pom.xml
index 6adddbb..bfded19 100644
--- a/AuxProtect_Core/pom.xml
+++ b/AuxProtect_Core/pom.xml
@@ -51,6 +51,7 @@
org.json:json
+ dev.heliosares:*
true
diff --git a/AuxProtect_Core/src/main/java/dev/heliosares/auxprotect/spigot/listeners/InventoryListener.java b/AuxProtect_Core/src/main/java/dev/heliosares/auxprotect/spigot/listeners/InventoryListener.java
index e536144..d2261d0 100644
--- a/AuxProtect_Core/src/main/java/dev/heliosares/auxprotect/spigot/listeners/InventoryListener.java
+++ b/AuxProtect_Core/src/main/java/dev/heliosares/auxprotect/spigot/listeners/InventoryListener.java
@@ -7,6 +7,8 @@ import dev.heliosares.auxprotect.database.EntryAction;
import dev.heliosares.auxprotect.database.SingleItemEntry;
import dev.heliosares.auxprotect.spigot.AuxProtectSpigot;
import dev.heliosares.auxprotect.utils.InvSerialization;
+import dev.heliosares.auxprotect.utils.InventoryUtil_1_20;
+import dev.heliosares.auxprotect.utils.InventoryUtil_1_21;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -86,7 +88,11 @@ public class InventoryListener implements Listener {
InventoryType type;
- type = e.getWhoClicked().getOpenInventory().getTopInventory().getType();
+ if (plugin.getCompatabilityVersion() < 21) {
+ type = InventoryUtil_1_20.getTopInventory(e.getWhoClicked()).getType();
+ } else {
+ type = InventoryUtil_1_21.getTopInventory(e.getWhoClicked()).getType();
+ }
if (e.getSlotType() != InventoryType.SlotType.RESULT) return;