[SPIGOT-3033] Cancelling the InventoryMoveItemEvent cancels the move attempt for all items in a hopper Created: 25/Jan/17 Updated: 26/Jan/17 Resolved: 26/Jan/17 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | Phoenix616 | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | Craftbukkit, InventoryMoveItemEvent, hopper |
Description |
When you cancel the InventoryMoveItemEvent caused by a Hopper for one item (e.g. the one in the first slot) it will not move on to an item in a slot after it (like it would in Vanilla when the target container doesn't have a slot were the item fits) but it stops the moving completely. This seems to be due to the return of false here in the TileEntityHopper.patch. With a continue there it could result in a more Vanilla-like behaviour. I don't believe that this was intended behaviour when the event was implemented and if so I propose to change it as it would add more functionality to the event to make plugin mechanics that better match the Vanilla behaviour. |
Comments |
Comment by Phoenix616 [ 26/Jan/17 ] |
I realise now that my proposed "fix" results in more load due the nature how the InventoryMoveItemEvent is (probably) used in most plugins: As an inventory move item attempt event. They only check if one inventory can move to another for protection reasons and mostly don't care about the item. It might be better to revert this event to how it was previously, make it really clear in the documentation that this is just an attempt of a move and start deprecating the getItem method as it doesn't represent all items that could potentially be moved anyways. In the future the calling of the event could then be moved to an earlier part in the move process to avoid calling it for every item it loops over. It would probably be good to add a new event that only gets fired when an item is actually moved later on when it checked if the target can receive the item. (Currenlty the InventoryMoveItemEvent gets also fired if the target is full and no items are actually moved like if the target is full or the inventory doesn't accept that item type) |