-
-
Notifications
You must be signed in to change notification settings - Fork 176
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
Make ItemInfoEvent cancellable (to cancel /iteminfo command) #349
base: master
Are you sure you want to change the base?
Conversation
Make ItemInfoEvent cancellable.
Doesn't this result in the item meta information getting sent before the ID messages? For this to work properly without changing the existing output you would need to move the item ID messages to their own listeners too. |
Will look into that. So just to be clear, you're saying that both trys are required to be successful before it sends the ItemInfoEvent and if so, why is that? Do you think we could get away with some sort of cancellable |
An additionally event is not necessary, simply make the command fully event driven by moving the two hard coded message sends into their own event handlers (e.g. in the ItemInfoListener class) on a lower priority than the existing meta ones and make sure that all ItemInfoEvent handlers ignore cancelled events as well. |
Sure I can do that, do you mind if i add a |
Wouldn't cancelling already do that shop of removing the message? |
Fair point, just gotta ignorecancelled real quick and then it should be ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall besides the return and empty check as well as the formatting issues.
src/main/java/com/Acrobot/ChestShop/Listeners/ItemInfoListener.java
Outdated
Show resolved
Hide resolved
src/main/java/com/Acrobot/ChestShop/Listeners/ItemInfoListener.java
Outdated
Show resolved
Hide resolved
src/main/java/com/Acrobot/ChestShop/Listeners/ItemInfoListener.java
Outdated
Show resolved
Hide resolved
src/main/java/com/Acrobot/ChestShop/Listeners/ItemInfoListener.java
Outdated
Show resolved
Hide resolved
Will fix this tomorrow, my ide auto formats on saving. |
ItemInfoEvent event = new ItemInfoEvent(sender, item); | ||
ChestShop.callEvent(event); | ||
|
||
return true; | ||
return !MaterialUtil.isEmpty(item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure any other event listener doesn't throw an error when the item is null/empty? (As you moved the check from before calling the event to after it and don't check that again anywhere)
Making this because I need to cancel /iteminfo depending on if the item has specific properties (e.g. custom nbt data)
Haven't been able to test but because this is so straight forward and small I don't see any way for it to cause any issues.