ItemJoin

ItemJoin

157k Downloads

Error on console when using Chestsort

kalebbroo opened this issue ยท 10 comments

commented

Describe the bug
If I have items from Itemjoin in my inventory I will get an error on the console. error is in pastebin below.

To Reproduce
Steps to reproduce the behavior:

  1. add itemjoin item to chest.
  2. open and close chest so chestsort will stack/sort items.
  3. see error

Expected behavior
chestsort plugin sorts items and does not throw error

Pastebin
Error https://pastebin.com/hjsGq7JJ
Items.yml https://pastebin.com/a10DrsUZ
config.yml https://pastebin.com/fb2Db6j0

Please complete the following information:

  • Resource Version and Build Number: 5.1.1-SNAPSHOT-b658
  • Server Version Paper 1.16.5
commented

Added. I also had it generate a new config with same result.

Latest snapshot should now fix this issue including your issue #357 .

Link; https://ci.craftationgaming.com/job/ItemJoin/660/
Remember to remove your old ItemJoin.jar file.

commented

Further info (I am the author of ChestSort and already spoke to the user reporting this):

Used ChestSort version is latest 9.0.1

It happens everytime when the ChestSortEvent is called while an ItemJoin item is included in the inventory that is to be sorted. The error comes from a line where the ChestSortAPI isn't used.

commented

Describe the bug
If I have items from Itemjoin in my inventory I will get an error on the console. error is in pastebin below.

To Reproduce
Steps to reproduce the behavior:

  1. add itemjoin item to chest.
  2. open and close chest so chestsort will stack/sort items.
  3. see error

Expected behavior
chestsort plugin sorts items and does not throw error

Pastebin
https://pastebin.com/hjsGq7JJ

Please complete the following information:

  • Resource Version and Build Number: 5.1.1-SNAPSHOT-b658
  • Server Version Paper 1.16.5

Can you please provide your config.yml in a pastebin link.

commented

Added. I also had it generate a new config with same result.

commented

Further info (I am the author of ChestSort and already spoke to the user reporting this):

Used ChestSort version is latest 9.0.1

It happens everytime when the ChestSortEvent is called while an ItemJoin item is included in the inventory that is to be sorted. The error comes from a line where the ChestSortAPI isn't used.

Issues seems to be coming from your event.getPlayer() method. Is this supposed to be returning null? If I fetch the inventory holder, the player instance event.getInventory().getViewers().get(0) returns as a valid player.

Seems to be related to my prior post; mfnalex/ChestSort#100 (comment)

Except this only occurs when you sort the inventory, open a chest, drag around some items, and then close the chest.

commented

IIRC the getPlayer() method only returns a HumanEntity if a PlayerInventory is to be sorted. For normal chests, it always returns null. That might be a bit confusing, I might change that and/or update the API docs, but its clearly stated that getPlayer() may return null , both via API docs and via the @nullable annotation. Sorry for the confusion.

EDIT: Also sorry to the github user @nullable who is always linked whenever the annotation is mentioned, lol

commented

ChestSortEvent#getPlayer is @nullable by design, see here: https://repo.jeff-media.de/javadocs/ChestSortAPI/de/jeff_media/ChestSortAPI/ChestSortEvent.html#getPlayer()

Ah okay, yeah it's a bit confusing since it should return a valid player instance any time a chest/inventory is sorted. Since the inventory holder itself returns the player instance.

I guess I will just implement my hacky method for now, for when it returns as null.

commented

ChestSortEvent#getPlayer is @nullable by design, see here: https://repo.jeff-media.de/javadocs/ChestSortAPI/de/jeff_media/ChestSortAPI/ChestSortEvent.html#getPlayer()

Ah okay, yeah it's a bit confusing since it should return a valid player instance any time a chest/inventory is sorted. Since the inventory holder itself returns the player instance.

I guess I will just implement my hacky method for now, for when it returns as null.

Yeah sorry about that, I can totally understand the confusion. But you also have to keep in mind that its possible for other plugins to invoke the ChestSortEvent / call the ChestSortAPI#sortInventory method, so I can never guarantuee that a player is associated to that Event, that's why it's Nullable. However it's a good occasion to think about setting the player when a player sorts a container :)

commented

This bug has been officially fixed in the release of ItemJoin v5.2.0.
You can grab it here; https://www.spigotmc.org/resources/itemjoin.12661/download?version=383801

Please read the changelog as the documentation has not been updated yet;
https://github.com/RockinChaos/ItemJoin/wiki/Recent-Changes