From f26f347726898cef5b73f1b77970876834d7f9f6 Mon Sep 17 00:00:00 2001 From: ArikSquad <75741608+ArikSquad@users.noreply.github.com> Date: Wed, 8 Apr 2026 22:34:36 +0300 Subject: [PATCH] fix: view events --- .../generic/gui/v2/event/ActionInventoryClose.java | 5 ++++- .../generic/gui/v2/event/ActionInventoryOpen.java | 11 +++++++++-- .../gui/v2/event/ActionInventoryPostClick.java | 9 +++++++-- .../generic/gui/v2/event/ActionInventoryPreClick.java | 5 ++++- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryClose.java b/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryClose.java index aa1a08285..183940c26 100644 --- a/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryClose.java +++ b/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryClose.java @@ -15,6 +15,9 @@ public void onPlayerInventoryClose(InventoryCloseEvent event) { HypixelPlayer player = (HypixelPlayer) event.getPlayer(); ViewNavigator.find(player).ifPresent(navigator -> { ViewSession session = navigator.getCurrentSession(); + if (session == null) { + return; + } if (event.getInventory() != session.inventory() || session.isSuppressCloseEvent()) { session.setSuppressCloseEvent(false); return; @@ -23,4 +26,4 @@ public void onPlayerInventoryClose(InventoryCloseEvent event) { }); } -} +} \ No newline at end of file diff --git a/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryOpen.java b/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryOpen.java index 075f5285d..de70b4c71 100644 --- a/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryOpen.java +++ b/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryOpen.java @@ -7,6 +7,7 @@ import net.swofty.type.generic.event.HypixelEventClass; import net.swofty.type.generic.gui.v2.ViewNavigator; import net.swofty.type.generic.user.HypixelPlayer; +import org.tinylog.Logger; public class ActionInventoryOpen implements HypixelEventClass { @@ -14,9 +15,15 @@ public class ActionInventoryOpen implements HypixelEventClass { public void onPlayerInventoryOpen(InventoryOpenEvent event) { MinecraftServer.getSchedulerManager().scheduleNextTick(() -> { HypixelPlayer player = (HypixelPlayer) event.getPlayer(); - ViewNavigator.find(player).ifPresent(navigator -> navigator.getCurrentSession().onOpenEvent(event)); + ViewNavigator.find(player).ifPresent(navigator -> { + if (navigator.getCurrentSession() == null) { + Logger.warn("Current session is null for player {} when opening inventory, this should not happen.", player.getUsername()); + return; + } + navigator.getCurrentSession().onOpenEvent(event); + }); }); } -} +} \ No newline at end of file diff --git a/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryPostClick.java b/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryPostClick.java index 40e0029cd..5d111577e 100644 --- a/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryPostClick.java +++ b/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryPostClick.java @@ -12,7 +12,12 @@ public class ActionInventoryPostClick implements HypixelEventClass { @HypixelEvent(node = EventNodes.INVENTORY, requireDataLoaded = false) public void onInventoryPostClick(InventoryClickEvent event) { HypixelPlayer player = (HypixelPlayer) event.getPlayer(); - ViewNavigator.find(player).ifPresent(navigator -> navigator.getCurrentSession().onPostClickEvent(event)); + ViewNavigator.find(player).ifPresent(navigator -> { + if (navigator.getCurrentSession() == null) { + return; + } + navigator.getCurrentSession().onPostClickEvent(event); + }); } -} +} \ No newline at end of file diff --git a/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryPreClick.java b/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryPreClick.java index 81343f72b..f5f2d5bd5 100644 --- a/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryPreClick.java +++ b/type.generic/src/main/java/net/swofty/type/generic/gui/v2/event/ActionInventoryPreClick.java @@ -13,8 +13,11 @@ public class ActionInventoryPreClick implements HypixelEventClass { public void onActionPlayerInventoryPreClick(InventoryPreClickEvent event) { HypixelPlayer player = (HypixelPlayer) event.getPlayer(); ViewNavigator.find(player).ifPresent(navigator -> { + if (navigator.getCurrentSession() == null) { + return; + } navigator.getCurrentSession().onPreClickEvent(event); }); } -} +} \ No newline at end of file