Skript: Removing item from inventory ignores extra data on the item

Created on 8 Aug 2019  路  6Comments  路  Source: SkriptLang/Skript

Description

I found it impossible to remove only not enchanted items from the inventory.

Steps to Reproduce

  1. Install this script:
command /test:
    trigger:
        clear player's inventory
        give player diamond pickaxe
        give player diamond pickaxe of efficiency 1
        give player diamond pickaxe of efficiency 2

        set {_item} to "diamond pickaxe" parsed as item

        remove 3 of {_item} from player's inventory
  1. Run /test as a player

Expected Behavior

Only one pickaxe should be removed from inventory, as the {_item} variable contains the exact item, not itemtype. Instead, all 3 pickaxes are removed.

Server Information

  • Server version/platform: git-Paper-134
  • Skript version: 2.4-beta5

Additional Context

In this issue I am assuming that diamond pickaxe and diamond pickaxe of efficiency 1 are not the same things when parsed as item - at least that's what I found in the documentation:

Unlike item type an item can only represent exactly one item

bug completed high

Most helpful comment

I can confirm this as an issue and it can cause huge issues in some cases, hence the high priority.

Personal example: on my server I have a script which allows players to sent items directly to each other (e.g. /itemsend <player> [<amount>] ). I calculate what they're trying to send, store it in a variable, validate that they have it, then remove it from their inventory and add it to a queue for the target player to claim.

Due to this bug, If a player is trying to send a newly crafted diamond pickaxe, it will instead save the plain pickaxe in a variable, give that to the target player (putting it in their queue), and remove the first diamond pickaxe it finds in the user's inventory instead of the correct one that they're holding. Often that will end up being their main pick over in one of their first couple of slots, which ends up being straight up deleted as a result.

I had to update multiple scripts to use skript-mirror to remove the item from the player's inventory instead of using Skript's remove effect.

All 6 comments

I just also found out that this issue appeared in 2.4-beta5 version. In 2.4-beta4 the code above works properly and the issue is not present.

Seems like it's removing an item type rather than an item

I can confirm this as an issue and it can cause huge issues in some cases, hence the high priority.

Personal example: on my server I have a script which allows players to sent items directly to each other (e.g. /itemsend <player> [<amount>] ). I calculate what they're trying to send, store it in a variable, validate that they have it, then remove it from their inventory and add it to a queue for the target player to claim.

Due to this bug, If a player is trying to send a newly crafted diamond pickaxe, it will instead save the plain pickaxe in a variable, give that to the target player (putting it in their queue), and remove the first diamond pickaxe it finds in the user's inventory instead of the correct one that they're holding. Often that will end up being their main pick over in one of their first couple of slots, which ends up being straight up deleted as a result.

I had to update multiple scripts to use skript-mirror to remove the item from the player's inventory instead of using Skript's remove effect.

I hope my quick fix doesn't break anything else.

@bensku How reassuring! :sweat_smile:
I'm sure it's fine.

It was fixed in beta6 but appeared again in beta7. #2404

Was this page helpful?
0 / 5 - 0 ratings