Paste #56597: Economy command

Date: 2019/08/09 10:44:37 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


eco:
    type: command
    debug: false
    name: eco
    description: Manage the balance of a player.
    usage: /eco <&lt>playerName<&gt> <&lt>operation<&gt> <&lt>quantity<&gt>
    permission: workbench.commands.eco
    default constants:
        operations: li@add|sub|set
    tab complete:
        - if "<context.server>":
            - narrate "This command is for players only."
            - stop
        - define player_name "<context.args.get[1]||>"
        - define player_names "<server.list_players.parse[name]>"
        - if "<[player_names].contains[<[player_name]>].not>":
            - determine "<[player_names].filter[starts_with[<[player_name]>]]>"
        - define operation "<context.args.get[2]||>"
        - define operations "<script.constant[operations]>"
        - if "<[operations].contains[<[operation]>].not>":
            - determine "<[operations].filter[starts_with[<[operation]>]]>"
    script:
        - if "<context.server>":
            - narrate "This command is for players only."
            - stop
        - define player_name "<context.args.get[1]||null>"
        - if "<[player_name]>" == null:
            - narrate "<&6>Enter the name of the player whose balance manage."
            - narrate "<&6>Use<&co> <&c><script.yaml_key[usage].parsed><&6>."
            - playsound "<player>" "sound:BLOCK_NOTE_BLOCK_HARP"
            - queue clear
        - define player "<server.match_offline_player[<[player_name]>]||null>"
        - if "<[player]>" == null:
            - narrate "<&c><[player_name]> <&6>is not the name of any player."
            - playsound "<player>" "sound:BLOCK_NOTE_BLOCK_HARP"
            - queue clear
        - define operation "<context.args.get[2]||null>"
        - if "<[operation]>" == null:
            - narrate "<&6>Enter the operation to perform on <&c><[player].name>'s <&6>balance."
            - narrate "<&6>Use<&co> <&c><script.yaml_key[usage].parsed><&6>."
            - playsound "<player>" "sound:BLOCK_NOTE_BLOCK_HARP"
            - queue clear
        - define operations "<script.constant[operations]>"
        - if "<[operations].contains[<[operation]>].not>":
            - narrate "<&c><[operation]> <&6>is not a valid operation."
            - playsound "<player>" "sound:BLOCK_NOTE_BLOCK_HARP"
            - queue clear
        - define quantity "<context.args.get[3]||null>"
        - if "<[quantity]>" == null:
            - narrate "<&6>Enter the quantity to <&c><[operation]> <&6>to <&c><[player].name>'s <&6>balance."
            - narrate "<&6>Use<&co> <&c><script.yaml_key[usage].parsed><&6>."
            - playsound "<player>" "sound:BLOCK_NOTE_BLOCK_HARP"
            - queue clear
        - if "<[quantity].is[matches].to[number].not>":
            - narrate "<&c><[quantity]> <&6>is not a valid quantity."
            - narrate "<&6>It must be a number."
            - playsound "<player>" "sound:BLOCK_NOTE_BLOCK_HARP"
            - queue clear
        - define quark "<custom@quark[player=<[player]>]>"
        - run quark.tasks.balance "def:<[quark]>|<[operation]>|<[quantity]>"
        - narrate "<&6>You performed a <&c><[operation]> <&6>operation for <&c><[quantity]> coins."
        - narrate "<&c><[player].name>'s <&6>new balance: <&c><[quark].balance> coins<&6>."
        - playsound "<player>" "sound:BLOCK_NOTE_BLOCK_BELL"