• 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!

Supported Minecraft Versions
  1. 1.9
  2. 1.10
  3. 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_language.skript:
# Adds a tag ("tag") to an entity ("entityToTag").
addTag(entityToTag, tag)

# Removes a tag ("tag") from an entity ("entityToUntag").
removeTag(entityToUntag, tag)

# Gets a list of all tags on an entity ("entityToCheck").
# This is returned as a Skript list of texts.
getTags(entityToCheck)

# Returns true if "entityToCheck" has the tag "tag", or false if not
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_language.skript:
# Returns true if the entity has a key-value tag with the given key
# This essentially is like checking if a variable named 'key' exists
hasKeyValueTag(entityToCheck, key)

# Stores a tag on "entityToTag" as "key=value"
# This literally maps directly to addTag(entityToTag, "key=value"), but it
# feels better to use a keyValueTag function when working with them
setKeyValueTag(entityToTag, key, value)

# Returns the value associated with the tag with key "key", e.g.:
# setKeyValueTag(player's target, "Owner", "%player%")
# getKeyValueTag(player's target, "Owner")
# Would return the "%player%" value set by setKeyValueTag
getKeyValueTag(entityToCheck, key)

# Removes the key-value tag with key "key" from "entityToUntag"
removeKeyValueTag(entityToUntag, key)


Reviews
"My mom loves it!" -- Me
"I can't believe it's not butter" -- Aunt Jemima
"Simba's my dad!!" -- Barack Obama
Author
Mr_Simba
Downloads
925
Views
925
First release
Last update
Rating
5.00 star(s) 3 ratings

Latest reviews

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
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
Your script is very very optimized, thanks for this.
I love you ! Because the Skellett nametag support is buggy