ChestShop-3 icon indicating copy to clipboard operation
ChestShop-3 copied to clipboard

Make ItemInfoEvent cancellable (to cancel /iteminfo command)

Open LogGits opened this issue 5 years ago • 7 comments

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.

LogGits avatar Aug 03 '20 07:08 LogGits

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.

Phoenix616 avatar Aug 03 '20 09:08 Phoenix616

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 PreItemInfoEvent?

LogGits avatar Aug 03 '20 10:08 LogGits

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.

Phoenix616 avatar Aug 03 '20 10:08 Phoenix616

Sure I can do that, do you mind if i add a feedback boolean to the event to prevent sending the feedback message? I want to have a custom message when a player tries to /iteminfo specific items.

LogGits avatar Aug 03 '20 11:08 LogGits

Wouldn't cancelling already do that shop of removing the message?

Phoenix616 avatar Aug 03 '20 11:08 Phoenix616

Fair point, just gotta ignorecancelled real quick and then it should be ready for review. EDIT: Should be ready for review

LogGits avatar Aug 03 '20 11:08 LogGits

Will fix this tomorrow, my ide auto formats on saving.

LogGits avatar Aug 03 '20 18:08 LogGits