Solved Using classes in skript-mirror

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

jaylawl

Active Member
Jan 29, 2017
173
31
0
33
skript-mirror is so amazing, it's a crime that there isn't more documentation on it!
But that's how it is and i can live with brute forcing my way through it until things work - however unfortunately i got stuck on this bit.

I'm try to make a script that can add itemflags. loading this script will produce no errors, but the part that adds the item flag does not work and i can't figure out why.

code_language.skript:
import:
    org.bukkit.inventory.ItemFlag as ItemFlag

command /test:
    trigger:
        set {_item} to diamond hoe named "adsasdas"
        {_item}.setItemMeta().addItemFlags(ItemFlag.HIDE_ATTRIBUTES!)
        send "%{_item}.getItemMeta().getItemFlags()%"

anybody push me in the right direction?
thank you

Solution:
The meta (for to me unknown reasons) had to be set to a variable first and then be applied to the item

code_language.skript:
import:
    org.bukkit.inventory.ItemFlag

command /test:
    trigger:
        set {_item} to diamond hoe named "adsasdas"
        set {_meta} to {_item}.getItemMeta()
        {_meta}.addItemFlags(ItemFlag.HIDE_ATTRIBUTES!, ItemFlag.HIDE_ENCHANTS!)
        {_item}.setItemMeta({_meta})
        send "%{_item}% flags: %{_item}.getItemMeta().getItemFlags()%"
        add 1 of {_item} to command sender's inventory
 
Last edited:
That is useful information. Thank you for explaining this despite the thread being marked as solved.
I'm aware of the skript-mirror gitbook, but unfortunately it's not much help to me in the way that's written. Although i do keep going back to it and understand a bit more each time.
 
Status
Not open for further replies.