worth.sk

Created by TobyMinceraft

Other available versions. Ordered by newest to oldest versions:

Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.

# Notes
#   - This script has a failsafe; if neither the Essentials nor your custom worth.yml files exist in the locations you've specified, the script will automatically disable.
#   - The "/buy" command can ONLY be used by players in SURVIVAL mode.
#   - The "/skworth" command can be used by players and console
#   - This skript uses permissions rather than server operator status; please give your users the permissions
#   - To bypass any of these commands, such as granting access to EVERY command in this script, give them the "skworth.*" permission in your permissions plugin

options:
    # This options is NOT configurable; setting this value will break certain things
    version: 1.3

    # Do you wish to receive future script updates?
    # Type: boolean (true/false)
    # # Default value: true
    check-for-updates: true

    # This option enables you to use server operator status for "admin" commands, while allowing normal players to use regular commands freely
    # This method is NOT recommended as in the wrong hands, operators can severely hurt your server. Only give op status to EXTREMELY trusted members
    # Type: boolean (true/false)
    # # Default value: false
    use-op-perm: false

    # Location of your worth.yml file, if Essentials is not installed
    # Worth file HAS to be saved as a .yml type or it will not work!
    # Has to be a filepath directly to location including file extension
    # Type: text
    # # Default value: plugins/Essentials/worth.yml
    file-location: plugins/Essentials/worth.yml

    # What you want the internal cache name to be
    # Process will only be used on load of this skript, thus increasing server performance (reloading this skript will also work)
    # Only change this if other yaml skripts conflict with this skript, otherwise let it be
    # Type: text
    # # Default value: worth
    worth: worth

    # What you want to show up before the configured chat messages sent by this Skript
    # Supports color and formatting codes (use an ampersand "&" for the codes; the section symbol "ยง" is only usable within Minecraft itself)
    # Type: string
    # # Default value: &7[&6Essentials&7]&e
    tag: &7[&6Essentials&7]&e

    # This is in case you want the buy price to be higher than the sell price (calculated last)
    # Formula: SellingValueOfItem X Offset = PurchasePriceOfItem
    # If you don't want an offset (if you want items to be bought at same price as sold), set this value to 1
    # Type: integer
    # # Default value: 10
    offset: 10

    # This determines whether you want the script to use an economy plugin's balance value (such as Essentials), or a custom Skript variable
    # If this is a Skript variable, it HAS TO be a variable you have already set; this script file does NOT create it's own variables
    # Example: {caseSensitiveList::%player's uuid%}
    # NOTE: as of version 1.3, it is now possible to use "player's level" which will use the experience points level of the player
    # Type: string
    # # Default value: player's balance
    balance: player's balance

    # If using "player's level" or "level of player" as this script's economy, the item prices must be rounded else player's will receive free items
    # "normal": the normal way of rounding (i.e. 0.6 = 1)
    # "up": always round up to nearest whole number (i.e. 0.6 = 1)
    # "down": always round down to nearest whole number (i.e. 0.6 = 0) (NOT recommended, as it will make the item free)
    # Type: text (normal|up|down)
    # # Default value: normal
    rounding: normal

    # The permission you want players to have to purchase items
    # Default is the selling permission from the Essentials plugin
    # Make yourself a server operator to bypass this permission (not recommended)
    # Type: text
    # # Default value: essentials.sell
    item-purchase-permission: essentials.sell

    # The permission you want players to have to see selling/purchase values of items
    # Default is the worth permission from the Essentials/EssentialsX plugin
    # Make yourself a server operator to bypass this permission (not recommended)
    # Type: text
    # # Default value: essentials.worth
    item-worth-permission: essentials.worth

    # Set this to true if you want to send messages to console whenever players purchase an item using the /buy command
    # Type: boolean (true|false)
    # # Default value: true
    notify-console: true

    # Do you want admins to see when players purchase items using the buy command?
    # Type: boolean (true|false)
    # # Default value: true
    notify-admins: true

    # The permission you want admins to have to receive item purchase notifications from this script.
    # This permission will also act as the general admin permission for this script
    # Type: text
    # # Default value: skworth.admin
    admin-notify-permission: skworth.admin

    # How many inventory slots (spaces) should the player have before they are given the items? Defaults to "1"
    # By default, Essentials doesn't drop extra items on the ground if the player's inventory is full
    # If you set this value to 0, you'll need to set "drop-items-if-full" to "true" in the "config.yml" file in Essentials/EssentialsX
    # Type: number (0 or higher)
    # # Default value: 1
    inventory-space: 1

    # Do you want the Skript to notify console when the skript has loaded/unloaded?
    # Simply change this value to "false" (without quotes) if you'd rather not spam the console
    # Type: boolean (true|false)
    # # Default value: true
    console-startup: true

    # Do you want to use the skript-yaml plugin for getting yml values?
    # While setting this option to "false" allows you to use one less plugin, setting it to "true" uses skript-yaml's alternative to saving and handling yml code
    # Disabled by default
    # Type: boolean (true|false)
    # # Default value: false
    use-skript-yaml: false


# ------------------------------------------ #
# End of configuration | Beginning of script #
# ------------------------------------------ #

# Update checker command
command /skworthupdate:
    aliases: /skworth:update, /skworth:checkforupdates, /skworth:updatecheck, /skworth:skworthupdate
    description: Check for updates to the script (does not auto-download)
    trigger:
        send "[skWorth] &eManually checking for updates..."
        wait 1 second
        set {_update} to text from url "https://pastebin.com/raw/JFDKRufK"
        set {_update} to {_update} parsed as number
        wait 1 tick
        if {@version} is less than {_update}:
            send "[skWorth] &eThe updater the found an update! Go to &bhttps://forums.skunity.com/resources/skworth.1029/updates &ein your browser to download it!"
        if {@version} is greater than or equal to {_update}:
            if {@version} is equal to {_update}:
                send "[skWorth] &eThe updater could not find an update. You are using the latest version!"
            if {@version} is greater than {_update}:
                send "[skWorth] &eThe updater could not find an update. You are either using a beta version of the script or you changed your version number."


command /skworthconfig:
    aliases: /skworth:skworthconfig, /skript:skworthconfig, /skworth:config, /skworth:viewconfig, /skworth:showconfig
    description: Get in-game your current config, descriptions of values, and their values
    trigger:
        if {skworth.enabled} is true:
            escape 2
        send "{@tag} &cThis script is currently disabled"
        stop trigger

        if executor is console:
            escape 4
        if player is a op:
            escape 3
        if player has permission "{@admin-notify-permission}" or "skworth.*":
            escape 2
        send "{@tag} &cERROR: &eYou are lacking the permission node &a{@admin-notify-permission}"
        stop trigger

        send ""
        send "&d---------- &6-= &bSkWorth &f| &eConfig &6=- &d---------- "
        send "- &aversion"
        send "&e  Description: &fThe version of &6skWorth"
        send "&e  Current value: &a{@version}"
        send "- &acheck-for-updates"
        send "&e  Description: &fAllowing the script to automatically check for updates (does not download)"
        send "&e  Current value: &a{@check-for-updates}"
        send "&e  Default value: &btrue"
        send "- &ause-op-perm"
        send "&e  Description: &fUse server operator status as permissions for admin commands"
        send "&e  Current value: &a{@use-op-perm}"
        send "&e  Default value: &bfalse"
        send "- &afile-location"
        send "&e  Description: &fLocation of the &eworth.yml &ffile, if not in &6Essentials &ffolder"
        send "&e  Current value: &a{@file-location}"
        send "&e  Default value: &bplugins/Essentials/worth.yml"
        send "- &aworth"
        send "&e  Description: &fInternal name used for saving worth values to server cache"
        send "&e  Current value: &a{@worth}"
        send "&e  Default value: &bworth"
        send "- &atag"
        send "&e  Description: &fPrefix used for most of the messages sent using this script"
        send "&e  Current value: &a{@tag}"
        send "&e  Default value: &a&7[&6Essentials&7]&e"
        send "- &aoffset"
        send "&e  Description: &fThe item's selling price is multiplied by this number to calculate the purchase price"
        send "&e  Current value: &a{@offset}"
        send "&e  Default value: &b10"
        send "- &abalance"
        send "&e  Description: &fHow do you want the player's balance to be used by? This can be player's balance or a previously set Skript variable"
        send "&e  Current value: &a{@balance}"
        send "&e  Default value: &bplayer's balance"
        if "{@balance}" is "player's level" or "level of player":
            send "- &arounding"
            send "&e  Description: &fDo you want to round up, down, or normally? Only needed if using the (experience) level of the player instead of balance"
            send "&e  Current value: &a{@rounding}"
            send "&e  Default value: &bup"
        send "- &aitem-purchase-permission"
        send "&e  Description: &fPermission you want players to have to purchase items using the buy command"
        send "&e  Current value: &a{@item-purchase-permission}"
        send "&e  Default value: &bplugins/Essentials/worth.yml"
        send "- &aitem-worth-permission"
        send "&e  Description: &fPermission you want players to have to view an item's worth and purchase price"
        send "&e  Current value: &a{@item-worth-permission}"
        send "&e  Default value: &bessentials.sell"
        send "- &aadmin-notify-permission"
        send "&e  Description: &fPermission you want admins to have to see whenever a player purchases and item using the buy command"
        send "&e  Current value: &a{@admin-notify-permission}"
        send "&e  Default value: &bskworth.notify"
        send "- &anotify-console"
        send "&e  Description: &fIf you want startup notifications to be sent to the console whenever this script loads and reloads"
        send "&e  Current value: &a{@notify-console}"
        send "&e  Default value: &btrue"
        send "- &anotify-admins"
        send "&e  Description: &fSet this to true if you want admins to be notified whenever players purchase items using the buy command"
        send "&e  Current value: &a{@notify-admins}"
        send "&e  Default value: &btrue"
        send "- &ainventory-space"
        send "&e  Description: &fHow many inventory spaces do you want a player to have in order to purchase items? Set this to &a0 &fto disable, but read this script or the wiki to learn how to properly use this feature"
        send "&e  Current value: &a{@inventory-space}"
        send "&e  Default value: &b1"
        send "- &aconsole-startup"
        send "&e  Description: &fSet this to true if you want console to be sent the default loading text (name and author) on script load/reload"
        send "&e  Current value: &a{@console-startup}"
        send "&e  Default value: &btrue"
        send "- &ause-skript-yaml"
        send "&e  Description: &fSet this to true if you want to use &dskript-yaml &fto read yml files; this is better than using SkQuery's method"
        send "&e  Current value: &a{@use-skript-yaml}"
        send "&e  Default value: &bfalse"


command /skworth [<string>] [<integer=1>]:
    aliases: /cost, /skworth:cost, /skworth:skworth, /skworth:cost, /skript:skworth
    trigger:
        if {skworth.enabled} is true:
            escape 2
        send "{@tag} &cThis script is currently disabled"
        stop trigger

        if arg 1 is set:
            if arg-1 is "help":
                send "{@tag} If an item's worth is not found, here's a list of possible reasons:"
                send "  &f- &eItem is not from vanilla Minecraft"
                send "  &f- &eItem is not sellable"
                send "  &f- &eItem is Vanilla, but not spelled correctly"
                send "  &f- &eItem is not properly configured in the new format"
                send "&7Note: &eif you believe the last reason is the case, please contact staff with a message similar to the following:"
                send "  &f- &6""I'm trying to sell ""&f%{_essWorthItem}%&6"" and it is not working."" "
                send "{@tag} PLEASE make sure you've spelled the item correctly BEFORE sending staff a message!"
                send "  &f- &eThe /buy command multiplier is currently set to &a{@offset} &e(&bSelling Worth &eX &a{@offset} &e= &bPurchase Price)"
                stop trigger

            if arg 2 is not an integer:
                send "{@tag} &cThe second argument MUST BE an integer between 1 and 64"
                stop trigger
            set {_essWorthItem} to arg-1
            set {_essWorthItem} to "%{_essWorthItem}%"
            replace all "minecraft:" with "" in {_essWorthItem}
            replace all "_" with "" in {_essWorthItem}
            replace all " " with "" in {_essWorthItem}

        if executor is console:
            escape 5
        if player is a op:
            escape 4
        if "{@use-op-perm}" is "true":
            escape 3
        if player has permission "{@item-worth-permission}" or "{@admin-notify-permission}" or "skworth.*":
            escape 2
        send "{@tag} &cERROR: &eYou are lacking the permission node &a{@item-worth-permission}"
        stop trigger

        if arg 1 is not set:
            send "{@tag} &cError: &eYou must specify an item to get it's worth and purchase price. Until we find a proper workaround, this has to be the case!"
            stop trigger

        if arg 2 is not an integer:
            send "{@tag} &cThe second argument MUST BE an integer between 1 and 64"
            stop trigger

        if "{@use-skript-yaml}" is "false":
            if file "plugins/Essentials/worth.yml" does not exist:
                if yaml value "worth.%{_essWorthItem}%" from file "{@file-location}" is not set:
                    send "{@tag} &cError&7: &eCould not find selling value of ""&f%{_essWorthItem}%&e"""
                    stop trigger
                set {_essValue} to yaml value "worth.%{_essWorthItem}%" from file "{@file-location}"
            if file "plugins/Essentials/worth.yml" does exist:
                if yaml value "worth.%{_essWorthItem}%" from file "{@file-location}" is not set:
                    send "{@tag} &cError&7: &eCould not find selling value of ""&f%{_essWorthItem}%&e"""
                    stop trigger
                set {_essValue} to yaml value "worth.%{_essWorthItem}%" from file "plugins/Essentials/worth.yml"

        if "{@use-skript-yaml}" is "true":
            if yaml path "worth.%{_essWorthItem}%" in "{@worth}" does not exist:
                send "{@tag} &cError&7: &eCould not find selling value of ""&f%{_essWorthItem}%&e"""
                stop trigger
            yaml path "worth.%{_essWorthItem}%" in "{@worth}" exists
            set {_essValue} to skript-yaml value "worth.%{_essWorthItem}%" from "{@worth}"

        if executor is console:
            escape 5
        if player is a op:
            escape 4
        if "{@use-op-perm}" is "true":
            escape 3
        if player has permission "{@item-worth-permission}" or "{@admin-notify-permission}" or "skworth.*":
            escape 2
        send "{@tag} &cERROR: &eYou are lacking the permission node &a{@item-worth-permission}"
        stop trigger

# This rounding process will only take effect if using player's experience level as server currency, otherwise it is skipped entirely
        if "{@balance}" is "level of player" or "player's level":
            if "{@rounding}" is "down":
                set {_essValue} to rounded down {_essValue}
                escape 2
            if "{@rounding}" is "up":
                set {_essValue} to rounded up {_essValue}
                escape 1
            if "{@rounding}" is "normal":
                set {_essValue} to rounded {_essValue}

        if arg-2 is an integer:
            set {_arg-2} to arg-2
            set {_buyWorth} to {_essValue}*{_arg-2}*{@offset}
            if "{@balance}" is "player's level" or "level of player":
                send "{@tag} &bSelling value of &a%arg-2% &b""&f%{_essWorthItem}%&b"": &a%{_essValue}*{_arg-2}% &exp level(s)"
                send "{@tag} &bPurchase price of &a%arg-2% &b""&f%{_essWorthItem}%&b"": &a%{_buyWorth}% &exp level(s)"
                escape 2
            send "{@tag} &bSelling value of &a%arg-2% &b""&f%{_essWorthItem}%&b"": &e$&a%{_essValue}*{_arg-2}%"
            send "{@tag} &bPurchase price of &a%arg-2% &b""&f%{_essWorthItem}%&b"": &e$&a%{_buyWorth}%"
            stop trigger

        if executor is console:
            escape 5
        if player is a op:
            escape 4
        if "{@use-op-perm}" is "true":
            escape 3
        if player has permission "{@item-worth-permission}" or "{@admin-notify-permission}" or "skworth.*":
            escape 2
        send "{@tag} &cERROR: &eYou are lacking the permission node &a{@item-worth-permission}"
        stop trigger

        set {_buyWorth} to {_essValue}*{@offset}
        if "{@balance}" is "player's level" or "level of player":
            send "{@tag} &bSelling value of ""&f%{_essWorthItem}%&b"": &e$&a%{_essValue}% &exp level(s)"
            send "{@tag} &bPurchase price of ""&f%{_essWorthItem}%&b"": &e$&a%{_buyWorth}% &exp level(s)"
            escape 2
        send "{@tag} &bSelling value of ""&f%{_essWorthItem}%&b"": &e$&a%{_essValue}%"
        send "{@tag} &bPurchase price of ""&f%{_essWorthItem}%&b"": &e$&a%{_buyWorth}%"
        stop trigger


command /skbuy [<string>] [<integer=1>]:
    aliases: /skworth:skbuy, /buy, /essentials:buy, /purchase, /skworth:purchase
    executable by: players
    trigger:
        if {skworth.enabled} is true:
            escape 2
        send "{@tag} &cThis script is currently disabled"
        stop trigger

        if arg-1 is "help" or "info":
            send "{@tag} If you got the ""unknown item"" error message, please check the following:"
            send "  &f-  &eYour spelling is correct"
            send "  &f-  &eThe item to be purchased is sellable: &f/worth item_name &e(you can only buy items that can also be sold)"
            send "&eIf you've tried the above and still get the error, please notify a staff member (it may help to take a screenshot of this message and your attempt) as it is possible the item isn't peroperly identified!"
            stop trigger
        if executor is console:
            send "{@tag} &cError: &eThat command can only be used by players."
            stop trigger
        else:
            if arg-1 is not set:
                make player execute command "/skbuy help"
                stop trigger
            
            if player is a op:
                escape 4
            if "{@use-op-perm}" is "true":
                escape 3
            if player has permission "{@item-purchase-permission}" or "{@admin-notify-permission}" or "skworth.*":
                escape 2
            send "{@tag} &cERROR: &eYou are lacking the permission node &a{@item-purchase-permission}" to player
            stop trigger
            
            if player's gamemode is not survival:
                send "{@tag} &cError: &eYou must be in &fSurvival Mode &eto use this command"
                stop trigger
            
            if arg-2 is not set:
                make player execute command "/skbuy %arg-1% 1"
                stop trigger

            if arg-2 is less than 1:
                send "{@tag} &cError: &eYou must specify a whole number greater than or equal to &a1"
                stop trigger
            
            set {_ymlItem} to arg-1
            set {_ymlItem} to "%{_ymlItem}%"
            replace all "minecraft:" with "" in {_ymlItem}
            set {_minecraftItem} to {_ymlItem}
            wait 1 tick
            replace all "_" with "" in {_ymlItem}
            replace all " " with "" in {_ymlItem}

            set {_space} to {@inventory-space}
            
            if "{@use-skript-yaml}" is "true":
                if yaml path "worth.%{_ymlItem}%" in "{@worth}" does not exist:
                    send "{@tag} &cError&7: &eEither the selling value of that item does not exist, the item doesn't exist, or you specified a quantity that isn't a whole number."
                    stop trigger
                set {_ymlWorth} to skript-yaml value "worth.%{_ymlItem}%" from "{@worth}"
                escape 1
            if "{@use-skript-yaml}" is "false":
                if file "plugins/Essentials/worth.yml" does not exist:
                    if yaml value "worth.%{_ymlItem}%" from file "{@file-location}" is not set:
                        send "{@tag} &cError&7: &eEither the selling value of that item does not exist, the item doesn't exist, or you specified a quantity that isn't a whole number."
                        stop trigger
                    set {_ymlWorth} to yaml value "worth.%{_ymlItem}%" from file "{@file-location}"
                if yaml value "worth.%{_ymlItem}%" from file "plugins/Essentials/worth.yml" is not set:
                    send "{@tag} &cError&7: &eEither the selling value of that item does not exist, the item doesn't exist, or you specified a quantity that isn't a whole number."
                    stop trigger
                set {_ymlWorth} to yaml value "worth.%{_ymlItem}%" from file "plugins/Essentials/worth.yml"

# This rounding process will only take effect if using player's experience level as server currency, otherwise it is skipped entirely
            if "{@balance}" is "level of player" or "player's level":
                if "{@rounding}" is "down":
                    set {_ymlWorth} to rounded down {_ymlWorth}
                    escape 2
                if "{@rounding}" is "up":
                    set {_ymlWorth} to rounded up {_ymlWorth}
                    escape 1
                if "{@rounding}" is "normal":
                    set {_ymlWorth} to rounded {_ymlWorth}

            set {_arg2} to arg-2
            set {_total} to {_arg2}*{_ymlWorth}
            
            if {@offset} is greater than or equal to 1:
                set {_total} to {_total}*{@offset}
            wait 10 ticks
            
            if {@balance} is less than {_total}:
                send "{@tag} &cError: &eYou do not have enough server currency to purchase that item"
                stop trigger
            
            if {_space} is greater than or equal to 1:
                if player has enough space for {@inventory-space} diamond sword:
                    subtract {_total} from {@balance}
                    if "{@balance}" is "player's level" or "level of player":
                        send "{@tag} You purchased &b%arg-2% &f%{_ymlItem}% &efor &a%{_total}% &exp level(s)"
                        escape 1
                    send "{@tag} You purchased &b%arg-2% &f%{_ymlItem}% &efor $&a%{_total}%"
                    if "{@notify-console}" is "true":
                        if "{@balance}" is "player's level" or "level of player":
                            send "{@tag} &7[&b%player's world%&7] &f%player% &ebought &a%arg-2% &f%arg-1% &efor &a%{_total}% &exp level(s) &7(&a%arg-2% &eitems at &a%{_ymlWorth}%&ex&a{@offset}&7)" to console
                            escape 1
                        send "{@tag} &7[&b%player's world%&7] &f%player% &ebought &a%arg-2% &f%arg-1% &efor &a$%{_total}% &7(&a%arg-2% &eitems at &a%{_ymlWorth}%&ex&a{@offset}&7)" to console
                    if "{@notify-admins}" is "true":
                        loop all players:
                            if player is a op:
                                escape 4
                            if "{@use-op-perm}" is "true":
                                escape 3
                            if player has permission "{@item-purchase-permission}" or "{@admin-notify-permission}":
                                escape 2
                            send "{@tag} &cError: &eYou do not have permission to purchase items"
                            stop trigger

                            if loop-player is a op:
                                if "{@balance}" is "player's level" or "level of player":
                                    send "{@tag} &7[&b%player's world%&7] &f%player% &ebought &a%arg-2% &f%arg-1% &efor &a%{_total}% &exp level(s) &7(&a%arg-2% &eitems at &a%{_ymlWorth}%&ex&a{@offset}&7)" to loop-player
                                    escape 1
                                send "{@tag} &7[&b%player's world%&7] &f%player% &ebought &a%arg-2% &f%arg-1% &efor &a$%{_total}% &7(&a%arg-2% &eitems at &a%{_ymlWorth}%&ex&a{@offset}&7)" to loop-player
                                escape 1
                            if loop-player has permission "{@admin-notify-permission}":
                                if "{@balance}" is "player's level" or "level of player":
                                    send "{@tag} &7[&b%player's world%&7] &f%player% &ebought &a%arg-2% &f%arg-1% &efor &a%{_total}% &exp level(s) &7(&a%arg-2% &eitems at &a%{_ymlWorth}%&ex&a{@offset}&7)" to loop-player
                                    escape 1
                                send "{@tag} &7[&b%player's world%&7] &f%player% &ebought &a%arg-2% &f%arg-1% &efor &a$%{_total}% &7(&a%arg-2% &eitems at &a%{_ymlWorth}%&ex&a{@offset}&7)" to loop-player
                    if file "plugins/Essentials/config.yml" does not exist:
                        make console execute command "/minecraft:give %player% %{_minecraftItem}% %arg-2%"
                        stop trigger
                    make console execute command "/give %player% %{_minecraftItem}% %arg-2%"
                    stop trigger
                send "{@tag} &cError: &eYou are required to have AT LEAST &aone &efree inventory space, NOT including armor, offhand, Ender Chest, or a plugin backpack. You must have space to hold at least 1 Diamond Sword to purchase items using this command" to player
                stop trigger

            subtract {_total} from {@balance}
            if "{@balance}" is "player's level" or "level of player":
                send "{@tag} You purchased &b%arg-2% &f%{_ymlItem}% &efor &a%{_total}% &exp level(s)"
                escape 1
            send "{@tag} You purchased &b%arg-2% &f%{_ymlItem}% &efor $&a%{_total}%"
            if "{@notify-console}" is "true":
                if "{@balance}" is "player's level" or "level of player":
                    send "{@tag} &7[&b%player's world%&7] &f%player% &ebought &a%arg-2% &f%arg-1% &efor &a%{_total}% &exp level(s) &7(&a%arg-2% &eitems at &a%{_ymlWorth}%&ex&a{@offset}&7)" to console
                    escape 1
                send "{@tag} &7[&b%player's world%&7] &f%player% &ebought &a%arg-2% &f%arg-1% &efor &a$%{_total}% &7(&a%arg-2% &eitems at &a%{_ymlWorth}%&ex&a{@offset}&7)" to console
            if "{@notify-admins}" is "true":
                loop all players:
                    if loop-player is a op:
                        if "{@balance}" is "player's level" or "level of player":
                            send "{@tag} &7[&b%player's world%&7] &f%player% &ebought &a%arg-2% &f%arg-1% &efor &a%{_total}% &exp level(s) &7(&a%arg-2% &eitems at &a%{_ymlWorth}%&ex&a{@offset}&7)" to loop-player
                            escape 1
                        send "{@tag} &7[&b%player's world%&7] &f%player% &ebought &a%arg-2% &f%arg-1% &efor &a$%{_total}% &7(&a%arg-2% &eitems at &a%{_ymlWorth}%&ex&a{@offset}&7)" to loop-player
                        escape 1
                    if loop-player has permission "{@admin-notify-permission}":
                        if "{@balance}" is "player's level" or "level of player":
                            send "{@tag} &7[&b%player's world%&7] &f%player% &ebought &a%arg-2% &f%arg-1% &efor &a%{_total}% &exp level(s) &7(&a%arg-2% &eitems at &a%{_ymlWorth}%&ex&a{@offset}&7)" to loop-player
                            escape 1
                        send "{@tag} &7[&b%player's world%&7] &f%player% &ebought &a%arg-2% &f%arg-1% &efor &a$%{_total}% &7(&a%arg-2% &eitems at &a%{_ymlWorth}%&ex&a{@offset}&7)" to loop-player
            make console execute command "/give %player% %{_ymlItem}% %arg-2%"
            stop trigger

on script load:
    if "{@console-startup}" is "true" or "enabled":
        wait 1 second
        send "[skWorth] Now loading &bSkWorth &av{@version}" to console
        send "[skWorth] A custom Essentials /buy command created by &6TobyMinceraft" to console
        wait 1 tick
    if "{@check-for-updates}" is "true" or "enabled":
        send "[skWorth] &eYou opted in to check for updates. Checking..." to console
        wait 2 seconds
        set {_update} to text from url "https://pastebin.com/raw/JFDKRufK"
        set {_update} to {_update} parsed as number
        wait 1 tick
        if {@version} is less than {_update}:
            send "[skWorth] &eThe updater the found an update! Go to &bhttps://forums.skunity.com/resources/skworth.1029/updates &ein your browser to download it!" to console
        if {@version} is greater than or equal to {_update}:
            if {@version} is equal to {_update}:
                send "[skWorth] &eThe updater could not find an update. You are using the latest version!" to console
            if {@version} is greater than {_update}:
                send "[skWorth] &eThe updater could not find an update. You are either using a beta version of the script or you changed your version number." to console
    if "{@balance}" is "player's balance" or "balance of player":
        send "[skWorth] &aUsing ""&b{@balance}&a"" as player balance manager. Locating &6Vault" to console
        wait 2 ticks
        if file "plugins/Vault/config.yml" does not exist:
            if "{@console-startup}" is "true" or "enabled":
                send "[skWorth] &6Vault &cplugin could not be found. Disabling script to prevent issues" to console
            wait 1 tick
            set {skworth.enabled} to false
            stop
        if "{@console-startup}" is "true" or "enabled":
            send "[skWorth] &6Vault &asuccessfully found. Locating &6Essentials&a' item worth file" to console
        escape 1
    if "{@balance}" is not "player's balance" or "balance of player":
        if "{@balance}" is "player's level" or "level of player":
            if "{@console-startup}" is "true" or "enabled":
                send "[skWorth] &aUsing ""&b{@balance}&a"" as player balance manager." to console
            escape 1
        if "{@console-startup}" is "true" or "enabled":
            send "[skWorth] &aPlayer balance manager being used by Skript variable ""&e{@balance}""&a." to console
    if "plugins/Essentials/worth.yml" exists:
        if "{@console-startup}" is "true" or "enabled":
            send "[skWorth] &aDefault Essentials worth file found. Loading it into memory." to console
        escape 1
    if file "plugins/Essentials/worth.yml" does not exist:
        if "{@console-startup}" is "true" or "enabled":
            send "[skWorth] &cDefault worth file ""&e{@file-location}"" &ccould not be found. Using fallback location." to console
        wait 1 tick
        if file "{@file-location}" does not exist:
            if "{@console-startup}" is "true" or "enabled":
                send "[skWorth] &cFallback file in location &e""{@file-location}""&ccould not be found. SkWorth script disabled." to console
            wait 1 tick
            set {skworth.enabled} to false
            stop
        if "{@console-startup}" is "true" or "enabled":
            send "[skWorth] &aWorth file at location ""&e{@file-location}&a"" discovered. Loading it into memory." to console
        wait 1 tick
        if "{@use-skript-yaml}" is "true" or "enabled":
            if "{@console-startup}" is "true" or "enabled":
                send "[skWorth] &eUsing &6skript-yaml &eas YAML manager" to console
            load yaml "{@file-location}" as "{@worth}"
    set {skworth.enabled} to true
    send "[skWorth] &bSkWorth &fscript successfully loaded and ready for players" to console
    if "{@use-skript-yaml}" is "true":
        load yaml "{@file-location}" as "{@worth}"


# # End of script file # #