From 176eb70dd3c7aae721178e2ba9c93275cab3508c Mon Sep 17 00:00:00 2001 From: montlikadani Date: Sat, 22 Aug 2020 20:46:34 +0200 Subject: [PATCH] Fix for clickedInventory method not exists in 1.8 or oldest servers --- .../java/com/gamingmesh/jobs/listeners/JobsListener.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java index bfa85a12..d20891b3 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java @@ -626,12 +626,13 @@ public class JobsListener implements Listener { ItemStack newArmorPiece = event.getCursor(); ItemStack oldArmorPiece = event.getCurrentItem(); if (numberkey) { - if (event.getClickedInventory().getType() == InventoryType.PLAYER) { - ItemStack hotbarItem = event.getClickedInventory().getItem(event.getHotbarButton()); + org.bukkit.inventory.Inventory clicked = Version.isCurrentHigher(Version.v1_8_R1) ? event.getInventory() : event.getClickedInventory(); + if (clicked != null && clicked.getType() == InventoryType.PLAYER) { + ItemStack hotbarItem = clicked.getItem(event.getHotbarButton()); if (hotbarItem != null) { newArmorType = ArmorTypes.matchType(hotbarItem); newArmorPiece = hotbarItem; - oldArmorPiece = event.getClickedInventory().getItem(event.getSlot()); + oldArmorPiece = clicked.getItem(event.getSlot()); } else newArmorType = ArmorTypes.matchType(oldArmorPiece != null && oldArmorPiece.getType() != Material.AIR ? oldArmorPiece : event.getCursor()); }