Anuj

Act as an expert Minecraft Skript developer specializing in high-performance scripts for Paper 1.21.11. Write a complete, production-ready, and bug-free Skript (plugins/Skript/scripts/bounty.sk) based on the specifications below.

---

Key Requirements & Specifications

#### 1. General Formatting & Aesthetics * Prefix: Clean, unbolded white prefix (e.g., &f[&7bounty&f] &r or using small caps unicode text like &f[&7ʙᴏᴜɴᴛʏ&f] &f). * Typography: Use clean white text (&f) and small capital unicode letters (e.g., ᴀ ʙ ᴄ ᴅ ᴇ...) for user names, coordinate broadcasts, death messages, and bossbars to achieve a sleek, modern SMP aesthetic. Avoid heavy bolding or loud colors.

#### 2. Target Effects & Totem Protection * Glowing Only: Apply a permanent glowing effect to the bounty target while the bounty is active. * Totem Pop Handler: When a bounty target pops a Totem of Undying (which clears potion effects), immediately re-apply the glowing effect so target visibility is never lost. * Removed Effects: Do NOT apply saturation or night_vision at any point. Remove these effects completely from the script.

#### 3. Bossbar Management * Style & Duration: The bossbar must remain completely full (100% progress) with no time limit or countdown. It must stay visible continuously until the target dies or the bounty is manually removed. * Design: Minimalist layout containing only the target's name in small capital text with a white prefix (e.g., &f&l⚔ &f<user>). * Join Handling: Display active bossbars to joining players without duplicating or creating overlapping bars.

#### 4. Coordinate Broadcasts * Timer: Broadcast the target's coordinates exact every 8 seconds (not 7 or 10 seconds). * Format: White prefix and clean typography: <user> is at x y z (e.g., &f[&7ʙᴏᴜɴᴛʏ&f] &f<user> ɪs ᴀᴛ <x> <y> <z>).

#### 5. Death & Reward Handling * Death Announcement: Broadcast the kill using white prefix and clean typography: <user with bounty> died by <killer> (e.g., &f[&7ʙᴏᴜɴᴛʏ&f] &f<user> ᴅɪᴇᴅ ʙʏ <killer>). * Direct Inventory Reward: * Deliver the reward directly into the killer's inventory. * Strict Anti-Duplication: Do NOT drop the item on the ground under any circumstance. * Inventory Overflow Handling: If the killer's inventory is full, scan for trash items (e.g., dirt, cobblestone, stone, netherrack, gravel, rotten flesh). Clear 1 slot containing trash and insert the reward directly into that newly emptied slot. * Cleanup: On target death, immediately delete all bounty variables, remove the bossbar from all players, and remove the glowing effect.

#### 6. GUI & Commands * Maintain full functionality for /bounty set <user> <reward> <amount>, /bounty remove <user>, and /bounty list. * Ensure proper item parsing (handling _ spaces) and head skull loading in the /bounty list GUI.

---

Source Reference Script (Refactor this code):

=======================================================

Infinite Custom Bounty System for Paper 1.21.11

File Path: plugins/Skript/scripts/bounty.sk

=======================================================

options: prefix: &8[&6Bounty&8] &r msg_prefix: &8[&6Bounty&8] &7

command /bounty [<text>] [<offline player>] [<text>] [<integer>]: permission: bounty.admin permission message: {@msg_prefix}&cPermission denied. trigger: if arg-1 is not set: send "{@msg_prefix}&e/bounty set <user> <reward> <amount>" to sender send "{@msg_prefix}&e/bounty remove <user>" to sender send "{@msg_prefix}&e/bounty list" to sender stop

if arg-1 is "list": if sender is console: send "{@msg_prefix}&cOnly players can open the bounty menu." to sender stop

set {_gui} to chest inventory with 6 rows named "&6[&c⚔ &6&lBounty List&6]" set {_slot} to 0

loop {bounty::*}: set {_tuuid} to loop-index set {_pname} to {bounty_name::%{_tuuid}%} set {_item} to {bounty_item::%{_tuuid}%} set {_amt} to {bounty_amount::%{_tuuid}%}

set {_head} to skull of ({_pname} parsed as offline player) set name of {_head} to "&e&l%{_pname}%" set lore of {_head} to "&7Reward: &a%{_amt}%x %{_item}%" and "" and "&bLeft-Click to Teleport" and "&eRight-Click to View Reward" set slot {_slot} of {_gui} to {_head} add 1 to {_slot}

if {_slot} is 0: set slot 22 of {_gui} to paper named "&c&lNo Active Bounties" with lore "&7There are currently no bounties active."

open {_gui} to player stop

if arg-1 is "set": if arg-2 is not set: send "{@msg_prefix}&cUsage: /bounty set <user> <reward> <amount>" to sender stop if arg-3 is not set: send "{@msg_prefix}&cPlease specify a reward item (use '_' for item spaces, e.g. totem_of_undying)!" to sender stop if arg-4 is not set: send "{@msg_prefix}&cPlease specify the item amount!" to sender stop

set {_target_name} to name of arg-2 set {_tuuid} to uuid of arg-2

if {bounty::%{_tuuid}%} is set: send "{@msg_prefix}&cThere is already an active bounty on %{_target_name}%!" to sender stop

set {_item_str} to arg-3 replace all "_" with " " in {_item_str} set {_item} to {_item_str} parsed as item type

if {_item} is not set: send "{@msg_prefix}&cInvalid item type '%{_item_str}%'!" to sender stop

set {_amt} to arg-4 if {_amt} <= 0: send "{@msg_prefix}&cAmount must be greater than 0." to sender stop

set {bounty::%{_tuuid}%} to true set {bounty_name::%{_tuuid}%} to {_target_name} set {bounty_item::%{_tuuid}%} to {_item} set {bounty_amount::%{_tuuid}%} to {_amt}

execute console command "bossbar add bounty_%{_tuuid}% {""text"":""%{_target_name}%"",""color"":""blue"",""bold"":true}" execute console command "bossbar set minecraft:bounty_%{_tuuid}% color blue" execute console command "bossbar set minecraft:bounty_%{_tuuid}% style progress" execute console command "bossbar set minecraft:bounty_%{_tuuid}% players @a"

broadcast "" broadcast "&6&l☠ NEW BOUNTY PLACED ☠" broadcast "&eTarget: &c%{_target_name}%" broadcast "&eReward: &a%{_amt}%x %{_item_str}%" broadcast ""

set {_coordinate_ticks} to 0

while {bounty::%{_tuuid}%} is set: add 1 to {_coordinate_ticks}

set {_p} to {_target_name} parsed as player if {_p} is online: if {_p} does not have glowing: apply glowing 1 to {_p} for 999 days if {_p} does not have night vision: apply night vision 1 to {_p} for 999 days if {_p} does not have saturation: apply saturation 1 to {_p} for 999 days

if {_coordinate_ticks} >= 7: set {_x} to x-coordinate of {_p} set {_y} to y-coordinate of {_p} set {_z} to z-coordinate of {_p} broadcast "{@msg_prefix}&e%{_target_name}% &7is located at &cX: %{_x}%&7, &cY: %{_y}%&7, &cZ: %{_z}%" set {_coordinate_ticks} to 0

wait 1 second stop

if arg-1 is "remove": if arg-2 is not set: send "{@msg_prefix}&cUsage: /bounty remove <user>" to sender stop

set {_target_name} to name of arg-2 set {_tuuid} to uuid of arg-2

if {bounty::%{_tuuid}%} is not set: send "{@msg_prefix}&cNo active bounty on %{_target_name}%." to sender stop

delete {bounty::%{_tuuid}%} delete {bounty_name::%{_tuuid}%} delete {bounty_item::%{_tuuid}%} delete {bounty_amount::%{_tuuid}%}

execute console command "bossbar remove minecraft:bounty_%{_tuuid}%"

set {_p} to {_target_name} parsed as player if {_p} is online: remove glowing from {_p} remove night vision from {_p} remove saturation from {_p}

broadcast "{@msg_prefix}&cThe bounty on &e%{_target_name}% &chas been cancelled." stop

send "{@msg_prefix}&e/bounty set <user> <reward> <amount>" to sender send "{@msg_prefix}&e/bounty remove <user>" to sender send "{@msg_prefix}&e/bounty list" to sender

on join: loop {bounty::*}: set {_tuuid} to loop-index execute console command "bossbar set minecraft:bounty_%{_tuuid}% players @a"

on death of player: set {_vuuid} to uuid of victim if {bounty::%{_vuuid}%} is set: set {_item} to {bounty_item::%{_vuuid}%} set {_amt} to {bounty_amount::%{_vuuid}%} set {_vname} to name of victim

delete {bounty::%{_vuuid}%} delete {bounty_name::%{_vuuid}%} delete {bounty_item::%{_vuuid}%} delete {bounty_amount::%{_vuuid}%}

execute console command "bossbar remove minecraft:bounty_%{_tuuid}%" remove glowing from victim remove night vision from victim remove saturation from victim

if attacker is a player: set {_killer} to attacker set {_reward} to {_amt} of {_item}

if {_killer} has space for {_reward}: give {_reward} to {_killer} else: set {_cleared} to false loop 36 times: set {_s} to loop-number - 1 set {_slot_item} to slot {_s} of {_killer}'s inventory if type of {_slot_item} is dirt or cobblestone or netherrack or stone or gravel or rotten flesh: set slot {_s} of {_killer}'s inventory to air set {_cleared} to true exit loop

if {_cleared} is false: drop slot 0 of {_killer}'s inventory at location of {_killer} set slot 0 of {_killer}'s inventory to air

give {_reward} to {_killer}

broadcast "" broadcast "&6&l☠ BOUNTY CLAIMED ☠" broadcast "&c%{_killer}% &7has slain &e%{_vname}% &7and claimed &a%{_amt}%x %{_item}%&7!" broadcast ""

loop all players: send title "&c%{_vname}% Killed!" with subtitle "&aClaimed by &e%name of {_killer}%" to loop-player for 10 ticks, 60 ticks, 10 ticks

on inventory click: if name of event-inventory is "&6[&c⚔ &6&lBounty List&6]": cancel event

if event-item is set: if type of event-item is player head: set {_pname} to uncolored name of event-item set {_target} to {_pname} parsed as offline player

if {_target} is set: set {_tuuid} to uuid of {_target}

if click type is left mouse button: if {_target} is online: teleport player to ({_target} parsed as player) send "{@msg_prefix}&aTeleported to bounty target &e%{_pname}%&a." to player close inventory of player else: send "{@msg_prefix}&cTarget &e%{_pname}% &cis currently offline!" to player

else if click type is right mouse button: set {_item} to {bounty_item::%{_tuuid}%} set {_amt} to {bounty_amount::%{_tuuid}%} send "{@msg_prefix}&eBounty Target: &f%{_pname}% &8| &eReward: &a%{_amt}%x %{_item}%" to player

📎 1 file 9,910 chars
📄
buunty.sk
sk 236 lines
▶
# =======================================================
# Infinite Custom Bounty System for Paper 1.21.11
# File Path: plugins/Skript/scripts/bounty.sk
# =======================================================

options:
    prefix: &8[&6Bounty&8] &r
    msg_prefix: &8[&6Bounty&8] &7

# ---------------------------------------------------
# Commands: /bounty set | /bounty remove | /bounty list
# ---------------------------------------------------
command /bounty [] [] [] []:
    permission: bounty.admin
    permission message: {@msg_prefix}&cPermission denied.
    trigger:
        if arg-1 is not set:
            send "{@msg_prefix}&e/bounty set   " to sender
            send "{@msg_prefix}&e/bounty remove " to sender
            send "{@msg_prefix}&e/bounty list" to sender
            stop

        if arg-1 is "list":
            if sender is console:
                send "{@msg_prefix}&cOnly players can open the bounty menu." to sender
                stop

            set {_gui} to chest inventory with 6 rows named "&6[&c⚔ &6&lBounty List&6]"
            set {_slot} to 0

            loop {bounty::*}:
                set {_tuuid} to loop-index
                set {_pname} to {bounty_name::%{_tuuid}%}
                set {_item} to {bounty_item::%{_tuuid}%}
                set {_amt} to {bounty_amount::%{_tuuid}%}

                set {_head} to skull of ({_pname} parsed as offline player)
                set name of {_head} to "&e&l%{_pname}%"
                set lore of {_head} to "&7Reward: &a%{_amt}%x %{_item}%" and "" and "&bLeft-Click to Teleport" and "&eRight-Click to View Reward"
                set slot {_slot} of {_gui} to {_head}
                add 1 to {_slot}

            if {_slot} is 0:
                set slot 22 of {_gui} to paper named "&c&lNo Active Bounties" with lore "&7There are currently no bounties active."

            open {_gui} to player
            stop

        if arg-1 is "set":
            if arg-2 is not set:
                send "{@msg_prefix}&cUsage: /bounty set   " to sender
                stop
            if arg-3 is not set:
                send "{@msg_prefix}&cPlease specify a reward item (use '_' for item spaces, e.g. totem_of_undying)!" to sender
                stop
            if arg-4 is not set:
                send "{@msg_prefix}&cPlease specify the item amount!" to sender
                stop

            set {_target_name} to name of arg-2
            set {_tuuid} to uuid of arg-2

            if {bounty::%{_tuuid}%} is set:
                send "{@msg_prefix}&cThere is already an active bounty on %{_target_name}%!" to sender
                stop

            set {_item_str} to arg-3
            replace all "_" with " " in {_item_str}
            set {_item} to {_item_str} parsed as item type

            if {_item} is not set:
                send "{@msg_prefix}&cInvalid item type '%{_item_str}%'!" to sender
                stop

            set {_amt} to arg-4
            if {_amt} <= 0:
                send "{@msg_prefix}&cAmount must be greater than 0." to sender
                stop

            set {bounty::%{_tuuid}%} to true
            set {bounty_name::%{_tuuid}%} to {_target_name}
            set {bounty_item::%{_tuuid}%} to {_item}
            set {bounty_amount::%{_tuuid}%} to {_amt}

            execute console command "bossbar add bounty_%{_tuuid}% {""text"":""%{_target_name}%"",""color"":""blue"",""bold"":true}"
            execute console command "bossbar set minecraft:bounty_%{_tuuid}% color blue"
            execute console command "bossbar set minecraft:bounty_%{_tuuid}% style progress"
            execute console command "bossbar set minecraft:bounty_%{_tuuid}% players @a"

            broadcast ""
            broadcast "&6&l☠ NEW BOUNTY PLACED ☠"
            broadcast "&eTarget: &c%{_target_name}%"
            broadcast "&eReward: &a%{_amt}%x %{_item_str}%"
            broadcast ""

            set {_coordinate_ticks} to 0

            while {bounty::%{_tuuid}%} is set:
                add 1 to {_coordinate_ticks}

                set {_p} to {_target_name} parsed as player
                if {_p} is online:
                    if {_p} does not have glowing:
                        apply glowing 1 to {_p} for 999 days
                    if {_p} does not have night vision:
                        apply night vision 1 to {_p} for 999 days
                    if {_p} does not have saturation:
                        apply saturation 1 to {_p} for 999 days

                    if {_coordinate_ticks} >= 7:
                        set {_x} to x-coordinate of {_p}
                        set {_y} to y-coordinate of {_p}
                        set {_z} to z-coordinate of {_p}
                        broadcast "{@msg_prefix}&e%{_target_name}% &7is located at &cX: %{_x}%&7, &cY: %{_y}%&7, &cZ: %{_z}%"
                        set {_coordinate_ticks} to 0

                wait 1 second
            stop

        if arg-1 is "remove":
            if arg-2 is not set:
                send "{@msg_prefix}&cUsage: /bounty remove " to sender
                stop

            set {_target_name} to name of arg-2
            set {_tuuid} to uuid of arg-2

            if {bounty::%{_tuuid}%} is not set:
                send "{@msg_prefix}&cNo active bounty on %{_target_name}%." to sender
                stop

            delete {bounty::%{_tuuid}%}
            delete {bounty_name::%{_tuuid}%}
            delete {bounty_item::%{_tuuid}%}
            delete {bounty_amount::%{_tuuid}%}

            execute console command "bossbar remove minecraft:bounty_%{_tuuid}%"

            set {_p} to {_target_name} parsed as player
            if {_p} is online:
                remove glowing from {_p}
                remove night vision from {_p}
                remove saturation from {_p}

            broadcast "{@msg_prefix}&cThe bounty on &e%{_target_name}% &chas been cancelled."
            stop

        send "{@msg_prefix}&e/bounty set   " to sender
        send "{@msg_prefix}&e/bounty remove " to sender
        send "{@msg_prefix}&e/bounty list" to sender

# ---------------------------------------------------
# Display active bounty boss bars to joining players
# ---------------------------------------------------
on join:
    loop {bounty::*}:
        set {_tuuid} to loop-index
        execute console command "bossbar set minecraft:bounty_%{_tuuid}% players @a"

# ---------------------------------------------------
# Death and reward claim event
# ---------------------------------------------------
on death of player:
    set {_vuuid} to uuid of victim
    if {bounty::%{_vuuid}%} is set:
        set {_item} to {bounty_item::%{_vuuid}%}
        set {_amt} to {bounty_amount::%{_vuuid}%}
        set {_vname} to name of victim

        delete {bounty::%{_vuuid}%}
        delete {bounty_name::%{_vuuid}%}
        delete {bounty_item::%{_vuuid}%}
        delete {bounty_amount::%{_vuuid}%}

        execute console command "bossbar remove minecraft:bounty_%{_vuuid}%"
        remove glowing from victim
        remove night vision from victim
        remove saturation from victim

        if attacker is a player:
            set {_killer} to attacker
            set {_reward} to {_amt} of {_item}

            if {_killer} has space for {_reward}:
                give {_reward} to {_killer}
            else:
                set {_cleared} to false
                loop 36 times:
                    set {_s} to loop-number - 1
                    set {_slot_item} to slot {_s} of {_killer}'s inventory
                    if type of {_slot_item} is dirt or cobblestone or netherrack or stone or gravel or rotten flesh:
                        set slot {_s} of {_killer}'s inventory to air
                        set {_cleared} to true
                        exit loop

                if {_cleared} is false:
                    drop slot 0 of {_killer}'s inventory at location of {_killer}
                    set slot 0 of {_killer}'s inventory to air

                give {_reward} to {_killer}

            broadcast ""
            broadcast "&6&l☠ BOUNTY CLAIMED ☠"
            broadcast "&c%{_killer}% &7has slain &e%{_vname}% &7and claimed &a%{_amt}%x %{_item}%&7!"
            broadcast ""

            loop all players:
                send title "&c%{_vname}% Killed!" with subtitle "&aClaimed by &e%name of {_killer}%" to loop-player for 10 ticks, 60 ticks, 10 ticks

# ---------------------------------------------------
# GUI listener for /bounty list
# ---------------------------------------------------
on inventory click:
    if name of event-inventory is "&6[&c⚔ &6&lBounty List&6]":
        cancel event

        if event-item is set:
            if type of event-item is player head:
                set {_pname} to uncolored name of event-item
                set {_target} to {_pname} parsed as offline player

                if {_target} is set:
                    set {_tuuid} to uuid of {_target}

                    if click type is left mouse button:
                        if {_target} is online:
                            teleport player to ({_target} parsed as player)
                            send "{@msg_prefix}&aTeleported to bounty target &e%{_pname}%&a." to player
                            close inventory of player
                        else:
                            send "{@msg_prefix}&cTarget &e%{_pname}% &cis currently offline!" to player

                    else if click type is right mouse button:
                        set {_item} to {bounty_item::%{_tuuid}%}
                        set {_amt} to {bounty_amount::%{_tuuid}%}
                        send "{@msg_prefix}&eBounty Target: &f%{_pname}% &8| &eReward: &a%{_amt}%x %{_item}%" to player
Kodari AI
KodariSep 21 at 1:48 pm 2

Place the file at plugins/Skript/scripts/bounty.sk, then run:

Plain Text
/sk reload bounty
Kodari can make mistakes. Review important code before using.
Files
plugins
Code
1 297
plugins/Skript/scripts/bounty.sk
# =======================================================
# Infinite Custom Bounty System
# Paper 1.21.11 / Skript
# Place this file in plugins/Skript/scripts/
# Reload with: /sk reload bounty
# =======================================================

options:
    prefix: &f[&7ʙᴏᴜɴᴛʏ&f] &r
    msg_prefix: &f[&7ʙᴏᴜɴᴛʏ&f] &f
    gui_name: &f[&7ʙᴏᴜɴᴛʏ&f] &7ʟɪsᴛ

# -------------------------------------------------------
# Rebuild persistent bossbars after a script reload
# -------------------------------------------------------
on script load:
    loop {bounty::*}:
        set {_tuuid} to loop-index
        set {_target_name} to {bounty_name::%{_tuuid}%}

        execute console command "bossbar remove bounty_%{_tuuid}%"
        execute console command "bossbar add bounty_%{_tuuid}% {""text"":""⚔ %{_target_name}%"",""color"":""white"",""bold"":false}"
        execute console command "bossbar set bounty_%{_tuuid}% color white"
        execute console command "bossbar set bounty_%{_tuuid}% style progress"
        execute console command "bossbar set bounty_%{_tuuid}% max 100"
        execute console command "bossbar set bounty_%{_tuuid}% value 100"
        execute console command "bossbar set bounty_%{_tuuid}% players @a"

# -------------------------------------------------------
# Bounty commands
# -------------------------------------------------------
command /bounty [<text>] [<offline player>] [<text>] [<integer>]:
    permission: bounty.admin
    permission message: {@msg_prefix}&cᴘᴇʀᴍɪssɪᴏɴ ᴅᴇɴɪᴇᴅ.
    trigger:
        if arg-1 is not set:
            send "{@msg_prefix}&f/bounty set <user> <reward> <amount>" to sender
            send "{@msg_prefix}&f/bounty remove <user>" to sender
            send "{@msg_prefix}&f/bounty list" to sender
            stop

        if arg-1 is "list":
            if sender is console:
                send "{@msg_prefix}&cᴏɴʟʏ ᴘʟᴀʏᴇʀs ᴄᴀɴ ᴏᴘᴇɴ ᴛʜᴇ ʙᴏᴜɴᴛʏ ʟɪsᴛ." to sender
                stop

            set {_gui} to chest inventory with 6 rows named "{@gui_name}"
            set {_slot} to 0

            loop {bounty::*}:
                if {_slot} is less than 54:
                    set {_tuuid} to loop-index
                    set {_pname} to {bounty_name::%{_tuuid}%}
                    set {_item_name} to {bounty_item_name::%{_tuuid}%}
                    set {_amt} to {bounty_amount::%{_tuuid}%}

                    set {_offline_target} to {_pname} parsed as offline player
                    set {_head} to skull of {_offline_target}
                    set name of {_head} to "&f%{_pname}%"
                    set lore of {_head} to "&fʀᴇᴡᴀʀᴅ: &7%{_amt}%x %{_item_name}%" and "" and "&7ʟᴇꜰᴛ-ᴄʟɪᴄᴋ ᴛᴏ ᴛᴇʟᴇᴘᴏʀᴛ" and "&7ʀɪɢʜᴛ-ᴄʟɪᴄᴋ ᴛᴏ ᴠɪᴇᴡ ʀᴇᴡᴀʀᴅ"
                    set slot {_slot} of {_gui} to {_head}
                    add 1 to {_slot}

            if {_slot} is 0:
                set slot 22 of {_gui} to paper named "&fɴᴏ ᴀᴄᴛɪᴠᴇ ʙᴏᴜɴᴛɪᴇs" with lore "&7ᴛʜᴇʀᴇ ᴀʀᴇ ɴᴏ ᴀᴄᴛɪᴠᴇ ʙᴏᴜɴᴛɪᴇs."

            open {_gui} to player
            stop

        if arg-1 is "set":
            if arg-2 is not set:
                send "{@msg_prefix}&cᴜsᴀɢᴇ: &f/bounty set <user> <reward> <amount>" to sender
                stop

            if arg-3 is not set:
                send "{@msg_prefix}&cᴘʟᴇᴀsᴇ sᴘᴇᴄɪꜰʏ ᴀ ʀᴇᴡᴀʀᴅ ɪᴛᴇᴍ. ᴜsᴇ &f_ &cꜰᴏʀ sᴘᴀᴄᴇs." to sender
                stop

            if arg-4 is not set:
                send "{@msg_prefix}&cᴘʟᴇᴀsᴇ sᴘᴇᴄɪꜰʏ ᴀɴ ɪᴛᴇᴍ ᴀᴍᴏᴜɴᴛ." to sender
                stop

            set {_target_name} to name of arg-2
            set {_tuuid} to uuid of arg-2

            if {bounty::%{_tuuid}%} is set:
                send "{@msg_prefix}&cᴛʜᴇʀᴇ ɪs ᴀʟʀᴇᴀᴅʏ ᴀɴ ᴀᴄᴛɪᴠᴇ ʙᴏᴜɴᴛʏ ᴏɴ &f%{_target_name}%&c." to sender
                stop

            set {_item_name} to arg-3
            replace all "_" with " " in {_item_name}
            set {_item} to {_item_name} parsed as item type

            if {_item} is not set:
                send "{@msg_prefix}&cɪɴᴠᴀʟɪᴅ ɪᴛᴇᴍ ᴛʏᴘᴇ: &f%{_item_name}%" to sender
                stop

            if {_item} is air:
                send "{@msg_prefix}&cᴀɪʀ ᴄᴀɴɴᴏᴛ ʙᴇ ᴜsᴇᴅ ᴀs ᴀ ʀᴇᴡᴀʀᴅ." to sender
                stop

            set {_amt} to arg-4
            if {_amt} <= 0:
                send "{@msg_prefix}&cᴛʜᴇ ᴀᴍᴏᴜɴᴛ ᴍᴜsᴛ ʙᴇ ɢʀᴇᴀᴛᴇʀ ᴛʜᴀɴ 0." to sender
                stop

            set {bounty::%{_tuuid}%} to true
            set {bounty_name::%{_tuuid}%} to {_target_name}
            set {bounty_item::%{_tuuid}%} to {_item}
            set {bounty_item_name::%{_tuuid}%} to {_item_name}
            set {bounty_amount::%{_tuuid}%} to {_amt}

            execute console command "bossbar remove bounty_%{_tuuid}%"
            execute console command "bossbar add bounty_%{_tuuid}% {""text"":""⚔ %{_target_name}%"",""color"":""white"",""bold"":false}"
            execute console command "bossbar set bounty_%{_tuuid}% color white"
            execute console command "bossbar set bounty_%{_tuuid}% style progress"
            execute console command "bossbar set bounty_%{_tuuid}% max 100"
            execute console command "bossbar set bounty_%{_tuuid}% value 100"
            execute console command "bossbar set bounty_%{_tuuid}% players @a"

            set {_target} to {_target_name} parsed as player
            if {_target} is online:
                apply glowing 1 to {_target} for 999 days

            broadcast "{@msg_prefix}%{_target_name}% ʜᴀs ʀᴇᴄᴇɪᴠᴇᴅ ᴀ ʙᴏᴜɴᴛʏ."
            broadcast "{@msg_prefix}&7ʀᴇᴡᴀʀᴅ: &f%{_amt}%x %{_item_name}%"
            stop

        if arg-1 is "remove":
            if arg-2 is not set:
                send "{@msg_prefix}&cᴜsᴀɢᴇ: &f/bounty remove <user>" to sender
                stop

            set {_target_name} to name of arg-2
            set {_tuuid} to uuid of arg-2

            if {bounty::%{_tuuid}%} is not set:
                send "{@msg_prefix}&cᴛʜᴇʀᴇ ɪs ɴᴏ ᴀᴄᴛɪᴠᴇ ʙᴏᴜɴᴛʏ ᴏɴ &f%{_target_name}%&c." to sender
                stop

            delete {bounty::%{_tuuid}%}
            delete {bounty_name::%{_tuuid}%}
            delete {bounty_item::%{_tuuid}%}
            delete {bounty_item_name::%{_tuuid}%}
            delete {bounty_amount::%{_tuuid}%}

            execute console command "bossbar remove bounty_%{_tuuid}%"

            set {_target} to {_target_name} parsed as player
            if {_target} is online:
                remove glowing from {_target}

            broadcast "{@msg_prefix}%{_target_name}% ʜᴀs ʜᴀᴅ ᴛʜᴇɪʀ ʙᴏᴜɴᴛʏ ʀᴇᴍᴏᴠᴇᴅ."
            stop

        send "{@msg_prefix}&f/bounty set <user> <reward> <amount>" to sender
        send "{@msg_prefix}&f/bounty remove <user>" to sender
        send "{@msg_prefix}&f/bounty list" to sender

# -------------------------------------------------------
# Re-apply target visibility and broadcast coordinates
# -------------------------------------------------------
every 1 second:
    loop {bounty::*}:
        set {_tuuid} to loop-index
        set {_target_name} to {bounty_name::%{_tuuid}%}
        set {_target} to {_target_name} parsed as player

        if {_target} is online:
            if {_target} does not have glowing:
                apply glowing 1 to {_target} for 999 days

every 8 seconds:
    loop {bounty::*}:
        set {_tuuid} to loop-index
        set {_target_name} to {bounty_name::%{_tuuid}%}
        set {_target} to {_target_name} parsed as player

        if {_target} is online:
            if {_target} does not have glowing:
                apply glowing 1 to {_target} for 999 days

            set {_x} to x-coordinate of {_target}
            set {_y} to y-coordinate of {_target}
            set {_z} to z-coordinate of {_target}

            broadcast "{@msg_prefix}%{_target_name}% ɪs ᴀᴛ %{_x}% %{_y}% %{_z}%"

# -------------------------------------------------------
# Totem protection
# -------------------------------------------------------
on resurrect:
    if event-entity is a player:
        set {_tuuid} to uuid of event-entity

        if {bounty::%{_tuuid}%} is set:
            apply glowing 1 to event-entity for 999 days

# -------------------------------------------------------
# Keep active bossbars visible after players join