Make ItemInfoEvent cancellable (to cancel /iteminfo command)#349
Make ItemInfoEvent cancellable (to cancel /iteminfo command)#349LogGits wants to merge 12 commits intoChestShop-authors:masterfrom
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. |
Phoenix616
left a comment
There was a problem hiding this comment.
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. |
| ChestShop.callEvent(event); | ||
|
|
||
| return true; | ||
| return !MaterialUtil.isEmpty(item); |
There was a problem hiding this comment.
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.