RockinChaos / ItemJoin

Get custom items on join.
https://www.craftationgaming.com/
GNU Lesser General Public License v3.0
137 stars 35 forks source link

Clear-Items set to ITEMJOIN also clears Vanilla items, but only certain ones #585

Closed czerk89 closed 2 months ago

czerk89 commented 4 months ago

Server Version

paper-1.20.4-454

Resource Version

6.0.5-RELEASE-b928

Dump Information

https://ci.craftationgaming.com/dump?id=ikacokadip

Describe The Bug

I have the config file set to this:

Clear-Items:
  Type: ITEMJOIN
  Delay-Tick: 2
  Join: true
  Quit: true
  World-Switch: true
  Region-Enter: true
  Options: PROTECT, PROTECT_OP
  Blacklist: ''

But when I join a world, it clears vanilla items like swords and shields. It doesn't clear items like blocks. Or bones. I haven't tested every item it clears and doesn't clear. Even if I craft the item, like a shield, it still disappears.

Expected Behavior

I would expect it to only clear itemjoin items. I even used /data to check the tags of vanilla items to see if anything was off.

Steps To Reproduce

  1. Set all Clear-Items values to true
  2. Create an item join item like such:
  cartographer-item:
    id: FILLED_MAP
    slot: 0
    name: '&eMinimap'
    lore:
    - '&7Map updates as you move and'
    - '&7you can equip it as a shield!'
    itemflags: hide-flags, death-drops, self-drops, unbreakable, item-store, move-next
    enabled-worlds: ALL
  1. Run the commands /give bone 1 and /give diamond_sword in a survival world.
  2. Join the world. You should not have 3 items in the hot bar--1 itemjoin and 2 vanilla.
  3. Leave the world and come back. The sword will be gone. So you'll only have itemjoin item and bone.
  4. Then run /give diamond_sword again so you have 3 items in the hot bar--1 itemjoin and 2 vanilla.
  5. Change Clear-Items type from ITEMJOIN to VANILLA.
  6. Leave the world and come back. Now ONLY the bone will be gone, but the diamond_sword will remain.

My expected behavior would be that with ITEMJOIN, only the map would be gone. And with VANILLA, both the sword and bone would be gone. Also, if you set {id:DIAMOND_SWOTH}, then the sword remain with ITEMJOIN, as you would expect. But I shouldn't have to blacklist a vanilla item. I didn't find anything in the wiki about this behavior either. And no existing issue was found.

Additional Info

No response

Checklist

RockinChaos commented 4 months ago

Confirmed, this one was a bigger issue than just clear-items as ItemJoin uses NBT checks for pretty much everything and it was failing the NBT check (or rather passing) when it was an item that could contain NBT by default like weapons and armor.

Apparently, a recent change made these items return an empty NBT after trying to fetch the ItemJoin data instead of null which is what ItemJoin checks for.

I made it catch both cases (null and empty NBT data) which seems to have resolved the issue from my testing.

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

Thanks again for the bug report! Let me know!~

EDIT: Offical release is now available; Link; https://www.spigotmc.org/resources/itemjoin.12661/download?version=542784