1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

API TagAPI 1.1

Like string metadata, but permanent! And better!

  1. Mr_Simba
    Supported Minecraft Versions:
    • 1.9, 1.10, 1.11
    TagAPI

    Description


    TagAPI gives you easy access to Mojang's scoreboard tag system which was introduced in 1.9. These tags allow you to permanently store up to 1024 text tags on an entity. Tags, like metadata from Skellett or RandomSk, are unique to an entity and can be checked or remove at any later point, but as they are stored directly in the entity's NBT, they are permanent and will persist through server restarts, chunk reloading, etc. -- all without using Skript variables.


    Requirements
    • Minecraft 1.9 or above (this is when scoreboard tags were added)
    • SkStuff

    Usage

    The following basic functions are made available to you by TagAPI:
    Code (Skript):
    1. # Adds a tag ("tag") to an entity ("entityToTag").
    2. addTag(entityToTag, tag)
    3.  
    4. # Removes a tag ("tag") from an entity ("entityToUntag").
    5. removeTag(entityToUntag, tag)
    6.  
    7. # Gets a list of all tags on an entity ("entityToCheck").
    8. # This is returned as a Skript list of texts.
    9. getTags(entityToCheck)
    10.  
    11. # Returns true if "entityToCheck" has the tag "tag", or false if not
    12. hasTag(entityToCheck, tag)

    These are the only features that directly use vanilla tag functionality. However, in my testing I found I often wanted to be able to use tags more like variables by having a key or "variable name" of sorts to reference tags by. So, I created the concept of key-value tags, which aid in getting and setting tags with a key=value setup, essentially allowing you to treat the tag as a variable named 'key' with a value of 'value'.
    Code (Skript):
    1. # Returns true if the entity has a key-value tag with the given key
    2. # This essentially is like checking if a variable named 'key' exists
    3. hasKeyValueTag(entityToCheck, key)
    4.  
    5. # Stores a tag on "entityToTag" as "key=value"
    6. # This literally maps directly to addTag(entityToTag, "key=value"), but it
    7. # feels better to use a keyValueTag function when working with them
    8. setKeyValueTag(entityToTag, key, value)
    9.  
    10. # Returns the value associated with the tag with key "key", e.g.:
    11. # setKeyValueTag(player's target, "Owner", "%player%")
    12. # getKeyValueTag(player's target, "Owner")
    13. # Would return the "%player%" value set by setKeyValueTag
    14. getKeyValueTag(entityToCheck, key)
    15.  
    16. # Removes the key-value tag with key "key" from "entityToUntag"
    17. removeKeyValueTag(entityToUntag, key)


    Reviews
    bi0, EWS, Gatt and 2 others like this.

Recent Reviews

  1. EWS
    EWS
    5/5,
    Version: 1.1
    Great!
    I thought there was no way to store tags that are not vanilla in entities, so thank you for this resource, it'll be really useful to get rid of some databases ;D
  2. jaylawl
    jaylawl
    5/5,
    Version: 1.1
    I love this, because it taught me how to make my own functions using Skript. :) I pretty much recoded the entire thing for own use and just learned so much from this, thank you.

    I wanna make a recommendation however! Your KeyTagValues are using a "=" between the name of the tag value and the actual value. While that is going to work fine internally, it does not work if intended to use with minecraft vanilla targeters (for example @e[type=chicken,tag=points=1]). The example should make clear why that is an issue that vanilla targeters can't digest ^^

    I use ":" instead of "=" in my version which do work and i'm sure many others would work, too. Just a heads up. :)

    Cheers
  3. Protoxy
    Protoxy
    5/5,
    Version: 1.1
    Your script is very very optimized, thanks for this.
    I love you ! Because the Skellett nametag support is buggy