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 jaylawl's (scoreboard) TagAPI 2.1.2

Allows storage of persistent data on any entity

  1. jaylawl
    Supported Minecraft Versions:
    • 1.9, 1.10, 1.11, 1.12, 1.13
    jaylawl's tagAPI

    ---------------------------------------------------
    Vanilla Skript is about to receive scoreboard-tag support in an upcoming version (potentially dev38) - Hence work on this will be discontinued :emoji_slight_smile:

    ---------------------------------------------------


    Dependencies:
    What are "scoreboard tags"?

    Scoreboard tags are a feature added to Minecraft in version 1.9. They are strings that are saved within an entity's NBT data (and do not affect scoreboards at all). They may be added to all any kind of living entity, including players, monsters, animals, item frames and armor stands. They can not be applied to tile entities.

    You may save any kind of data as a scoreboard tag, but note that it must be applied as a string/text. If you're storing a number as text, you will have to re-convert it back to a number when retrieving the data.
    • Scoreboard tags persist over server restarts
    • Up to 1024 tags can be stored per entity
    • Tags automatically get deleted if the carrying entity dies/despawns
    • Faster than file-storage (yaml/txt)
    • Only strings can be saved as tags
    • A bit slower than Skript-variable storage
    • Data must be converted to/from strings
    • Very useful for cross-plugin communication (for ex.: MythicMobs)
    When you'd want to use this storage method is up to you. As with any other storage method, you have to consider the advantages and disadvantages in relation to your project.


    Expressions:
    • %entity%'s [scoreboard(-| )]tags
      Allows to be get, looped, set, added to, removed from, deleted and reset

    • %entity%'s [scoreboard(-| )]tag(-| )value %string%
      allows to be get, set, deleted and reset
    Conditions:
    • %entity% (0¦does(n't| not) have|1¦has [got]|does have) [scoreboard(-| )]tag[s ] %strings%
    • %entity% (0¦does(n't| not) have|1¦has [got]|does have) [scoreboard(-| )]tag(-| )value[s ] %strings%
    Examples:
    Code (Skript):
    1. command /test:
    2.     trigger:
    3.  
    4.         add "this", "is", "just", "an", "example" to command sender's tags
    5.         loop command sender's tags:
    6.             send "%loop-value%"
    7.    
    8.         remove "this", "is", "just" from command sender's tags
    9.         send "%command sender's tags%"
    10.  
    11.         set command sender's tag value "IsTest" to "true"
    12.         command sender has tag value "IsTest":
    13.             command sender's tag value "IsTest" = "true"
    14.             send "&atrue!, command sender has the tags: %command sender's tags%"
    15.    
    16.         delete command sender's tag value "IsTest"
    17.         remove "an", "example" from command sender's tags
    18.  
    19.         send "%command sender's tags%"
    Old function syntax (no longer supported):
    Effects
    Code (Skript):
    1. addTag(entity, tag=text)
    Adds the given tag to the given entity

    Code (Skript):
    1. removeTag(entity, tag=text)
    Removes the given tag from the given entity

    Code (Skript):
    1. setTagValue(entity, tag=text, value=text)
    Sets the tag-value of the entity and overrides previous tag-values.

    Code (Skript):
    1. removeTagValue(entity, tag=text)
    Deletes any value of the given tag from the given entity.
    Expressions
    Code (Skript):
    1. getTags(entity)
    Loopable value. Returns a list-variable filled with the tags of the given entity. ex.: `set {_tags::*} to getTags(event-entity)`

    Code (Skript):
    1. getTagValue(entity, tag=text)
    Returns the value of the given tag from the given entity. Ex.: `set {_value} to getTagValue(attacker, "npc")`. Can also be used as a condition, ex.: `getTagValue(loop-entity, "gameball") = "true"`
    Conditions
    Code (Skript):
    1. hasTag(entity, tag=text)
    Returns either true or false. Ex.: `hasTag(player, "noob") = true`

    Code (Skript):
    1. hasTagValue(entity, tag=text)
    Returns either true or false. Ex.: `hasTag(player, "noob-state") = true`

    Example usage:
    Randomly deny 50 % of all villager trades:
    Code (Skript):
    1. on spawn of villager:
    2.     chance of 0.5
    3.     addTag(event-entity, "no_trades")
    4.  
    5. on right click on villager:
    6.     hasTag(event-entity, "no_trades") = true
    7.     cancel event
    Tag a "special entity":
    Code (Skript):
    1.  
    2. on command /special:
    3.     trigger:
    4.         loop all entities:
    5.             hasTag(loop-entity, "special_entity") = true
    6.             send "A special entity already exists!"
    7.             stop
    8.         spawn 1 armor stand at command sender's location
    9.         addTag(last spawned entity, "special_entity")
    10.  
    11. on damage of armor stand:
    12.     hasTag(victim, "special_entity") = true
    13.     cancel event
    14.  
    15. on command /findspecial:
    16.     trigger:
    17.         loop all entities:
    18.             hasTag(loop-entity, "special_entity") = true
    19.             send "Found special entity with UUID %loop-entity's uuid% at location %loop-entity's location%"
    20.             teleport command sender to loop-entity's location
    21.             stop
    22.  
    Code (Skript):
    1. on damage:
    2.     hasTag(victim, "golfball") = true
    3.     getTagValue(victim, "ball-owner") != attacker's uuid:
    4.         send "&cThat's not your ball!"
    5.         stop
    6.  
    7. on right click on entity:
    8.     getTagValue(event-entity, "owner") = event-player's uuid
    9.     make event-player ride event-entity
    10.  
    11. on right click on rabbit:
    12.     hasTagValue(event-entity, "owner") = false
    13.     setTagValue(event-entity, "owner", "%event-player's uuid%")
    14.     send "You tamed this rabbit!"

    command "/tagwand":
    Use this command to receive a wand that allows you to right click on entities to check the scoreboard tags they have. Works on all except tile-entities. Drop the item from your inventory to have it automatically destroyed.
    [​IMG]

    Special thanks go to @Mr_Simba! He made something very similar to this, except that it uses SkStuff instead of skript-mirror and showed it to me a while ago on bensku's github. That gave me my original introduction to making my own functions and helped me understand Skript a lot. Thanks again!

    Is this resource useful to you?
    Consider buying me a coffee or pizza if it is! Paypal: https://www.paypal.me/langejulian

Recent Updates

  1. Condense & fix
  2. Minor bugfix
  3. Custom expression/condition Update

Recent Reviews

  1. LeStegii
    LeStegii
    5/5,
    Version: 2.1.2
    Amazing job!
    This is a very awesome skript!

    ,,,,,,,,,,,,,,