Bug in the PlayerInventoryToChestEvent

  • hey @red51


    I tried to use the PlayerInventoryToChestEvent and I always get null when using the .getItem() method.


    This is how I tested it:


    This code snippet always prints "item is null"


    Edit: also just noticed there is a small mistake in the description of the getExchangeItem() method in the same event. Where it says: "Returns null if there is no exchange item (i.e. when the player moves the item to an empty slot in his inventory)." I think it should say: "Returns null if there is no exchange item (i.e. when the player moves the item to an empty slot in the chest)."

  • I did some more testing and it appears that the .getItem() method returns the item that the item I am placing in the chest will be exchanged with.


    For instance:


    1) When I place a tomato in a chest's empty slot I get null from the .getItem() method.


    2) When I place a tomato in a chest's slot that already contains a plank then it returns the name of the plank.


    So it appears that the method returns the wrong item i.e. the one already in the chest and not the one being placed.


    I did some more testing now and it appears the .getExchangeItem() method returns the item that is being placed so the two methods (.getItem() and .getExchangeItem()) seem to be written the other way around. :/

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!