Skript: Issue with options and shield with a name

Created on 7 Oct 2019  路  9Comments  路  Source: SkriptLang/Skript

Description

When using an option referring to a shield with a name, it doesn't recognise the shield as an item if you write "shield" and not "shields".

Steps to Reproduce

options:
    admin_shield: shield named "&fAdmin Shield"

command /AdminShield:
    trigger:
        give player {@admin_shield}

use this code with skript 2.4-beta8, and in game do /adminshield, not tested on other version

Expected Behavior

I should get a shield with the name "Admin Shield" using "shield" or "shields"

Errors / Screenshots

No error in the console

Server Information

  • Server version/platform: Paper version git-Paper-209 (MC: 1.14.4)
  • Skript version: Skript 2.4-beta8
aliases bug low

Most helpful comment

Okay... after much MUCH testing I figured out what the issue is.

When the named expression is initializing, its thinking that shield is the player's shield.
I ran two tests, one with shield and one with a shield, outcome: (I just added some debug code into the plugin to test the initialization)

[00:21:16 INFO]: This is initializing - name: "shield test" exp: the tool of event-living entity
[00:21:16 INFO]: This is initializing - name: "a shield test" exp: shield

as you can see shield returns the expression the tool of event-living entity
and a shield returns the expression shield

so when you do something like give player shield named "TEST", Skript is thinking you are saying give player shield of player named "TEST"
If I put a diamond sword in my offhand slot and run give player shield of player named "TEST" it gives me a diamond sword named "TEST"
hence why a shield works perfectly.

I'm not entirely sure how to fix this, or if this is even fixable, technically this isn't a bug as this could be considered "expected behaviour"

All 9 comments

This has nothing to do with options, it has to do with item types with data.
ex:
give player diamond sword named "bob" will not work
give player a diamond sword named "bob" will work

You need to add a before the item

But then why does it works with "shields" and not "shield" ?

That's grammar... look at the 2 following sentences:
Bob gave an apple to Steve
Bob gave apples to Steve

If there is no error it should definitely work (also the code is correct). I think Shane states that there is a bug with shield but a shield works (weird)

Hmm... What I was able to find is:

command /test:
    trigger:
        give player shield

Works

command /test:
    trigger:
        give player shield named "test"

Doesn't Work

Both parse successfully, but the one with the named "test" doesn't

Wealthyturtle I know that's grammar but both should work the same according to the alias files

In second case, item is from expression. Aliases are not expressions; that could explain the difference.

Okay... after much MUCH testing I figured out what the issue is.

When the named expression is initializing, its thinking that shield is the player's shield.
I ran two tests, one with shield and one with a shield, outcome: (I just added some debug code into the plugin to test the initialization)

[00:21:16 INFO]: This is initializing - name: "shield test" exp: the tool of event-living entity
[00:21:16 INFO]: This is initializing - name: "a shield test" exp: shield

as you can see shield returns the expression the tool of event-living entity
and a shield returns the expression shield

so when you do something like give player shield named "TEST", Skript is thinking you are saying give player shield of player named "TEST"
If I put a diamond sword in my offhand slot and run give player shield of player named "TEST" it gives me a diamond sword named "TEST"
hence why a shield works perfectly.

I'm not entirely sure how to fix this, or if this is even fixable, technically this isn't a bug as this could be considered "expected behaviour"

Aliases could take priority over expressions if the expression directly matches an alias?

shield -> alias, because shield exists as one
player's shield -> expression, because there is no player's shield alias

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Anoniempje1234 picture Anoniempje1234  路  3Comments

wohahobg picture wohahobg  路  3Comments

Romitou picture Romitou  路  3Comments

GiraffeCubed picture GiraffeCubed  路  3Comments

ghost picture ghost  路  3Comments