Resource icon

Script Zabrid's YAML Manager 1.2.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!

Contributors
Zabrid
Supported Minecraft Versions
  1. 1.8
  2. 1.9
  3. 1.10
  4. 1.11
  5. 1.12
  6. 1.13
  7. 1.14
  8. 1.15
  9. 1.16
  10. 1.17
  11. 1.18
THIS RESOURCE IS TO HELP SKRIPT DEVELOPERS MANAGE THEIR DATA. IT IS NOT FOR YOUR AVERAGE SERVER OWNER!

Have you ever had problems with skript's built-in data storage system? Have you ever wanted to use Skript-YAML but didn't know how? Well then, this script has you covered!

This script automatically sort all of your data into separate folders (per uuid) to ensure maximum server performance at all times. Not only that, it can also store server-side data (i.e unique players).

Config:
Code:
# 
# ###################################################################

# Zabrid's YAML Manager
# Author(s): {zabrid}#3433
# Version: 1.1.0
# Date 4/26/22

# Required Plugins:
# - Skript
# - Skript-YAML

# Functions:
# - zdata_server_setvalue(value: text, chicken: text, save: boolean): - Set server related data
# - zdata_server_delvalue(value: text, save: boolean): - Delete server related data
# - zdata_server_getvalue(value: text) :: text: - Get server related data
# - zdata_server_save(): - Save all server related data
# - zdata_player_setvalue(p: player, value: text, chicken: text, save: boolean): - Set data for a specific player
# - zdata_player_delvalue(p: player, value: text, save: boolean): - Delete data for a specific player
# - zdata_player_getvalue(p: player, value: text) :: text: - Get data from a specific player
# - zdata_player_save(p: player): - Save a specific player's data
# - zdata_player_gettop(value: text) :: texts: - Get a sorted list from high to low (Player data, duh)

# Values Cheat Sheet:
# - chicken = What you're setting the value to
# - value = The name of the variable you're setting.
#   - Values can be split into different nodes by putting a "." (ex: "stats.blocks-placed.cactus")
# - save = Do you want to save the data immediently?

# ###################################################################

# Configuration
options:

#  How often the server will auto-save YAML data
    auto-save-speed: 5

#  Whether or not the server will announce YAML data saving
    auto-save-announcement-boolean: true

#  Only send the YAML saving announcement message to server ops
    auto-save-announcement-ops-only: true

#  YAML data save message
    auto-save-announcement-starting-message: "&8[&cData&8] &7Saving all player and server data..."
    auto-save-announcement-ended-message: "&8[&cData&8] &7Successfully saved all player and server data. &8(&c%{_time}%&8)"

#  Still Loading Data Kick Message
    still-loading-message: "&8&m                         %nl%%nl%&7You cannot join at this time.%nl%&7Data from the server is still being loaded.%nl%%nl%&cPlease try again in ~15 seconds.%nl%%nl%&8&m                         "

#  Do you want to automatically delete a YAML value if it is less than or equal to 0? (Only for numbers and integers)
    do-not-save-numbers-equal-less-than-0: false

#  The folder where you want all data to go to.
#  WARNING: IF YOU CHANGE THIS DATA DOES NOT TRANSFER
    directory: plugins/ZabridYamlManager

Example:
Code:
# This is an example on how to use Zabrid's YAML Manager
# This example shows how you could track a player's kills and deaths, aswell as make a leaderboard

on death:

    victim is a player

    set {_deaths} to zdata_player_getvalue(victim, "kill-tracker.deaths") parsed as integer # Retrieving the amount of deaths the victim has
    add 1 to {_deaths} # Adding 1 to the amount of deaths the victim has
    zdata_player_setvalue(victim, "kill-tracker.deaths", "%{_deaths}%", true) # Setting the amount of deaths the victim has. This data will be saved instantly.

    attacker is a player

    set {_kills} to zdata_player_getvalue(victim, "kill-tracker.kills") parsed as integer # Retrieving the amount of kills the attacker has
    add 1 to {_kills} # Adding 1 to the amount of kills the attacker has
    zdata_player_setvalue(victim, "kill-tracker.deaths", "%{_deaths}%", true) # Setting the amount of kills the attacker has. This data will be saved instantly.

on join:

    set {_deaths} to zdata_player_getvalue(player, "kill-tracker.deaths")
    if "%{_deaths}%" is "<none>": # Skript bug, means you have to do it like this
        zdata_player_setvalue(player, "kill-tracker.deaths", "0", false) # I did not save here because I will save later in the event

    set {_kills} to zdata_player_getvalue(player, "kill-tracker.kills")
    if "%{_kills}%" is "<none>":
        zdata_player_setvalue(player, "kill-tracker.kills", "0", false) # I did not save here because I will save later in the event
 
    zdata_player_save(player) # Saves all of the players YAML data

command /kills [<offline player>]:
    trigger:
        set {_p} to arg 1 ? player
        set {_kills} to zdata_player_getvalue({_p}, "kill-tracker.kills")
        if {_kills} is set:
            send "&a%{_p}% has killed &n%{_kills}%&a people."
        else:
            send "&cThis player does not have any Kills data stored."

command /deaths [<offline player>]:
    trigger:
        set {_p} to arg 1 ? player
        set {_deaths} to zdata_player_getvalue({_p}, "kill-tracker.deaths")
        if {_deaths} is set:
            send "&c%{_p}% has died &n%{_deaths}%&c times."
        else:
            send "&cThis player does not have any Deaths data stored."

# This is how you make a leaderboard with Zabrid's YAML Manager

command /killstop:
    trigger:

        set {_leaderboard::*} to zdata_player_gettop("kill-tracker.kills")

        send "%{_leaderboard::1} parsed as offline player% &7is the top killer."

        send ""
        send "&aTop 10 Killers on the server!"
        send "&8-> &7Tracking &d%size of {_leaderboard::*}%&7 players"
        send ""

        loop {_leaderboard::*}:

            if loop-index parsed as integer is greater than 10: #This means only the top 10 most kills will show up
                stop
     
            # loop-value = the UUID of the player
            # loop-index = The player's position. This value is text by default, so parse it if you need to do math
            set {_value} to zdata_player_getvalue(loop-value parsed as offline player, "kill-tracker.kills") # loop-value saved as the uuid of the player, so to get the name you need to parse as offline player

            send "&7 %loop-index%. &a%loop-value parsed as offline player% &8- &7%{_value}%"
 
        send ""

Required Plugins:
Code:
  Skript
  Skript-YAML

Support Discord: https://discord.gg/vMuWFWXJVy
Author
Zabrid
Downloads
1,204
Views
1,204
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Zabrid

Latest updates

  1. 1.2.1

    - Fixed player delete YAML value function
  2. 1.2.0

    - Improved YAML loading sequence when a player joins the server. - Fixed YAML not loaded...
  3. 1.1.0

    - Added functions for deleting server & player yaml values.