diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/InventoryClickContext.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/InventoryClickContext.java index 32ac3698..7f5fd539 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/InventoryClickContext.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/api/InventoryClickContext.java @@ -4,26 +4,31 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class InventoryClickContext { private final int slot; - private final ItemStack itemStack; + + @Nullable + private final ItemStack currentItem; + + @NotNull private final ClickType clickType; + @NotNull private final Cancellable event; - private Inventory inv; - public InventoryClickContext(int slot, ItemStack itemStack, ClickType clickType, Cancellable event) { - this.slot = slot; - this.itemStack = itemStack; - this.clickType = clickType; - this.event = event; + @Nullable + private final Inventory inv; + + public InventoryClickContext(int slot, ItemStack currentItem, ClickType clickType, Cancellable event) { + this(slot, currentItem, clickType, event, null); } - public InventoryClickContext(int slot, ItemStack itemStack, ClickType clickType, Cancellable event, Inventory inv) { + public InventoryClickContext(int slot, ItemStack currentItem, ClickType clickType, Cancellable event, Inventory inv) { this.slot = slot; - this.itemStack = itemStack; + this.currentItem = currentItem; this.clickType = clickType; this.event = event; this.inv = inv; @@ -48,13 +53,15 @@ public class InventoryClickContext { */ @Nullable public ItemStack getClickedItem() { - return itemStack; + return currentItem; } + @NotNull public Cancellable getEvent() { return event; } + @Nullable public Inventory getInventory() { return inv; } @@ -63,6 +70,7 @@ public class InventoryClickContext { return inv != null; } + @NotNull public ClickType getClickType() { return clickType; } diff --git a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java index 01ada1c5..94d9c093 100644 --- a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java +++ b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java @@ -39,7 +39,7 @@ public class PlayerListener implements Listener { */ @EventHandler public void b(InventoryClickEvent event) { - if (event.getInventory().getHolder() instanceof PluginInventory&&event.getCurrentItem()!=null) + if (event.getInventory().getHolder() instanceof PluginInventory) ((PluginInventory) event.getInventory().getHolder()) .whenClicked(new InventoryClickContext(event.getRawSlot(), event.getCurrentItem(), event.getClick(), event, event.getInventory())); }