Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Terminal-Access opened this issue Nov 22, 2022 · 4 comments
Open

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

Terminal-Access opened this issue Nov 22, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@Terminal-Access
Copy link

Terminal-Access commented Nov 22, 2022

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.

@Terminal-Access Terminal-Access changed the title GUI items Can be Moved and Removed (#6 returns) [Bug] GUI items Can be Moved and Removed (#6 returns) Nov 22, 2022
@Terminal-Access Terminal-Access changed the title [Bug] GUI items Can be Moved and Removed (#6 returns) [Bug] GUI items Can be Moved and Removed (#2 returns) Nov 22, 2022
@Matt-MX Matt-MX added the bug Something isn't working label Nov 22, 2022
@Matt-MX
Copy link
Owner

Matt-MX commented Nov 22, 2022

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
Copy link
Author

Terminal-Access commented Nov 22, 2022

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
Copy link
Owner

Matt-MX commented Nov 23, 2022

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants