Matt-MX / ServerGUI

A customizable server gui for Velocity servers!
15 stars 1 forks source link

[Bug] GUI items Can be Moved and Removed (#2 returns) #8

Open Terminal-Access opened 1 year ago

Terminal-Access commented 1 year ago

ServerGUI: 2.0 Protocolize: 2.2.2:374 Velocity: 3.5.1

Using the versions labled above I've noticed bug report #2 has reared its head once again.

Items when clicked in the GUI can be picked up moved around and placed in to the players own inventory.

I beleive this is because the origional inventory "onClick" event is not being canceled.

Matt-MX commented 1 year ago

In the InventoryGui class we can see the event is cancelled ((here))

I'm really not sure what is causing this. Are the items the user moves ghost items when they exit the gui? If so that is even more strange.

Terminal-Access commented 1 year ago

In the InventoryGui class we can see the event is cancelled ((here))

I'm really not sure what is causing this. Are the items the user moves ghost items when they exit the gui? If so that is even more strange.

having looked at the code there i think the cancel click event is being called to early, from my understanding of that code its being called and canceled when the gui is opened.

instead it should be called during the onClick() event of an opened gui.

example: add the cansel event click at the beginning of this then do ur custom click event code after. public void onClick(InventoryClick click) { if (clickEvent != null) clickEvent.accept(this, click); ItemButton button = slot(click.slot()); if (button != null) button.click(click); }

this might be where this bug is arising from.

Matt-MX commented 1 year ago

In the build function we call i.onClick(this::onClickCancel); which registers the click callback to the onClickCancel(InventoryClick e) function.

This is only called when a player clicks it.

Terminal-Access commented 1 year ago

In the build function we call i.onClick(this::onClickCancel); which registers the click callback to the onClickCancel(InventoryClick e) function.

This is only called when a player clicks it.

Checking over your code the only place that I can see where "i.onClick(this::onClickCancel);" is two functions:

public void open(Player player) public void openSync(Player player) {

Both of thease only handle the opening of the GUI Interface, and do not conver any GUI interaction events sutch as (onClick) event.