Hello, first off I'm sorry if the title doesn't make sense. I'm very new to Java so feel free to help me rename it.
I'm currently trying to make a Gui/inventory that opens and allows me to handle player clicks. In it's current state the Gui opens and the event handler works fine. The part where I'm getting stuck is when trying to verify if a player has my custom Gui/inventory open vs their own inventory or a chest.
I've used https://www.spigotmc.org/wiki/creating-a-gui-inventory/ as a guide for building the gui.
I have 3 files:
When using the "/test" command, a player should have a Gui/inventory open up with items inside of it. This works just fine with my code.
Where my problem arises is when I try to do the following code in my TestGui class:
TestGui appears to be "null". I expected this to stop running an onInventoryClick event handler if the inventory is not equal to TestGui.
I've achieved this functionality previously on a 1.20.2 paper server but can't get this working again. After some googling I can't seem to figure this out with my current knowledge of Java. I've seen reference to paper's inventory handler guide but when I google about it it seems that that is not the correct way to handle this.
If anyone can help point me in the right direction I'd be very appreciative.
I'm currently trying to make a Gui/inventory that opens and allows me to handle player clicks. In it's current state the Gui opens and the event handler works fine. The part where I'm getting stuck is when trying to verify if a player has my custom Gui/inventory open vs their own inventory or a chest.
I've used https://www.spigotmc.org/wiki/creating-a-gui-inventory/ as a guide for building the gui.
I have 3 files:
- Main class (onEnable)
- TestGui class
- TestCommand class
When using the "/test" command, a player should have a Gui/inventory open up with items inside of it. This works just fine with my code.
Where my problem arises is when I try to do the following code in my TestGui class:
Code:
if (!e.getInventory().equals(TestGui)) return;
TestGui appears to be "null". I expected this to stop running an onInventoryClick event handler if the inventory is not equal to TestGui.
I've achieved this functionality previously on a 1.20.2 paper server but can't get this working again. After some googling I can't seem to figure this out with my current knowledge of Java. I've seen reference to paper's inventory handler guide but when I google about it it seems that that is not the correct way to handle this.
If anyone can help point me in the right direction I'd be very appreciative.