RockinChaos / ItemJoin

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

Item not working when a world is changed/set to Creative #583

Closed czerk89 closed 7 months ago

czerk89 commented 7 months ago

Server Version

paper-1.20.4-454

Resource Version

6.0.5-RELEASE-b928

Dump Information

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

Describe The Problem

I have the following item set up:

  dragonhub-item:
    id: FIREWORK_STAR
    charge-color: RED
    name: '&eTeleport Stone'
    slot: 35
    lore:
    - '&7Click to go to Dragonhub!'
    interact:
    - 'delay: 1'
    - mvtp dragonhub
    - 'message: &eSending you to the Dragonhub!'
    inventory:
    - 'delay: 1'
    - mvtp dragonhub
    - 'message: &eSending you to the Dragonhub!'
    itemflags: inventory-modify, hide-flags, death-drops, self-drops, unbreakable, clear-items
    triggers: join, respawn, world-switch
    permission-node: itemjoin.dragonhub
    enabled-worlds: world_creative, castle

This item works in all my non-creative worlds. But it doesn't work in creative worlds. When I click it in my creative world, it just closes the inventory and does nothing. Here are debugging steps I've taken:

  1. I've run the /mvtp dragonhub command manually in that world to make sure I have permission to run it in creative mode. So it's not permission.
  2. I ran /mvm set gamemode survival world_creative, and all of a sudden the items started working. If I change back to creative, they stop again. So it's not something specific to the world, but the gamemode.
  3. I tested it in other worlds, and as soon I switch to creative, the items stop working.
  4. I turned on debug mode and saw nothing appear in the console.
  5. I deleted CREATIVE from the config under Bypass.
  6. I've created multiple items, and none of them work in Creative

At this point, I'm fairly positive it's something with ItemJoin--likely a setting I missed and not a bug. Any guidance would be appreciated.

Additional Context

No response

Checklist

czerk89 commented 7 months ago

You might already have figured it out, but I think this might actually be a bug. So when an item is in slot 0-8 (quick bar), it works in either CREATIVE or SURVIVAL. But when I move it to 9-35, it stops working in CREATIVE, but works in SURVIVAL.

I tested this item in both slot 6 and 34:

  fly-item:
    id: FIREWORK_ROCKET
    name: '&eFlying Token'
    slot: 34
    lore:
    - '&7Click to toggle flying mode!'
    interact:
    - 'delay: 1'
    - fly
    inventory:
    - 'delay: 1'
    - fly
    itemflags: inventory-modify, hide-flags, death-drops, self-drops, unbreakable, clear-items, item-store
    triggers: join, respawn, world-switch
    permission-node: itemjoin.dragonhub
    enabled-worlds: castle, arthur*, ben

It worked in slot 6 in SURVIVAL and CREATIVE. But only worked in SURVIVAL in slot 34.

RockinChaos commented 7 months ago

You might already have figured it out, but I think this might actually be a bug. So when an item is in slot 0-8 (quick bar), it works in either CREATIVE or SURVIVAL. But when I move it to 9-35, it stops working in CREATIVE, but works in SURVIVAL.

I tested this item in both slot 6 and 34:

  fly-item:
    id: FIREWORK_ROCKET
    name: '&eFlying Token'
    slot: 34
    lore:
    - '&7Click to toggle flying mode!'
    interact:
    - 'delay: 1'
    - fly
    inventory:
    - 'delay: 1'
    - fly
    itemflags: inventory-modify, hide-flags, death-drops, self-drops, unbreakable, clear-items, item-store
    triggers: join, respawn, world-switch
    permission-node: itemjoin.dragonhub
    enabled-worlds: castle, arthur*, ben

It worked in slot 6 in SURVIVAL and CREATIVE. But only worked in SURVIVAL in slot 34.

Okay, so this is intended. The action of the inventory closing is a result of the inventory-modify itemflag. To prevent item duplication I have to force close the player's inventory because the creative events are glitchy and not programmed well by Mojang/Microsoft. Since it's nothing on my end I can fix this is why most developers suggest using an Emulated Creative mode plugin instead of actual creative mode since it's easy to exploit. Unfortunately, that's the result until Microsoft decides to re-code creative mode.

As for the command not executing this is because you haven't told ItemJoin to listen for Creative inventory events. You need to use inventory-creative for creative (as per the wiki). Note: The inventory will still close to prevent potential bugging and item duplication.

So your item should look like this;

  fly-item:
    id: FIREWORK_ROCKET
    name: '&eFlying Token'
    slot: 34
    lore:
    - '&7Click to toggle flying mode!'
    interact:
    - 'delay: 1'
    - fly
    inventory:
    - 'delay: 1'
    - fly
    inventory-creative:
    - 'delay: 1'
    - fly
    itemflags: inventory-modify, hide-flags, death-drops, self-drops, unbreakable, clear-items, item-store
    triggers: join, respawn, world-switch
    permission-node: itemjoin.dragonhub
    enabled-worlds: castle, arthur*, ben

I hope that makes sense! Let me know~

czerk89 commented 7 months ago

That makes a lot of sense! Thank you!