// Hand-written examples for Docs entries that no example elsewhere in the documentation covers.
// An entry starts with '@ ' followed by the entry's syntax exactly as the Docs page shows it.
// Every example here is compiled when the documentation is checked, so it has to be real code.

@ %server.max_players%
send "&7%server.online_players% of %server.max_players% players online"

@ %server.time%
set {%player%.last_seen} to server.time

@ %event.world%, %event.x%, %event.y%, %event.z%
on block break:
    log "%player.name% broke a block at %event.x%, %event.y%, %event.z% in %event.world%"

@ %discord.user%
on discord command "/hello":
    reply "Hello, %discord.user%!"

@ %discord.channel%
on discord command "/where":
    reply "You are in #%discord.channel%"

@ <amount> in front
give 16 bread to player

@ ( )
set _total to (_price + _tax) * _amount

@ random integer between A and B
set _roll to random integer between 1 and 6

@ random number between A and B
set _chance to random number between 0 and 1

@ > < >= <=
if {%player%.coins} >= 100:
    send "&aYou can afford it."

@ is a number / is not a number
if arg.1 is not a number:
    send "&cUsage: /pay <amount>"
    stop

@ {_list.<n>}
set _parts to split "Coins:500" by ":"
send "You have %{_parts.2}% coins"

@ remove <value> from <variable>
remove player.name from {winners}

@ join <list> with <separator>
send "Online: " + join server.players with ", "

@ trimmed <text>
set _name to trimmed args

@ replace <a> with <b> in <text>
set _pretty to replace "_" with " " in "diamond_sword"

@ last <n> characters of <text>
set _ending to last 3 characters of player.name

@ characters <a> to <b> of <text>
set _middle to characters 2 to 4 of "Hello"

@ length of <text>
if length of args > 50:
    send "&cThat is too long."

@ rounded <number>
send "TPS: " + rounded server.tps

@ append <text> to file at <path>
append "\n%player.name% joined" to file at "plugins/HyperScript/log.txt"

@ delete file at <path>
delete file at "plugins/HyperScript/notes/old.txt"

@ execute player command <text>
execute player command "spawn"

@ give <who> <item> or give <item> to <who>
give player 3 diamond
give 16 bread to player

@ attacker
on entity damage:
    if attacker is set and victim is "villager":
        cancel event

@ %event.click_type%
on inventory click:
    if event.click_type is "SHIFT_LEFT":
        cancel event

@ %event.recipients%
on player chat:
    log "%player.name% wrote to: %event.recipients%"

@ %event.location%
on block break:
    spawn particle "flame" at event's location

@ permission: value
command /fly:
    permission: "server.fly"
    trigger:
        execute console command "fly %player.name%"

@ permission <who> remove <node>
permission player remove "server.fly"

@ delete line <n> of <who>'s scoreboard
delete line 3 of player's scoreboard

@ headers <text>, <text>, ...
async:
    send post request to "https://api.example.com/v1/events" with body "{\"type\":\"join\"}" headers "Authorization: Bearer abc123"

@ hide player count
on server ping:
    hide player count

@ set server icon to <path>
on server ping:
    set server icon to "plugins/HyperScript/icon.png"

@ set quit message to <text>
on player quit:
    set quit message to "&c- &f%player.name%"

@ hide join message / hide quit message
on player join:
    hide join message

@ set chat message to <text>
on player chat:
    if message contains "badword":
        set chat message to "(removed)"

// ---- Entries where the automatic match picked a line that shows something else ----

@ /
set _average to {%player%.total} / {%player%.games}

@ %
if {%player%.blocks} % 50 == 0:
    send "&bAnother 50 blocks mined!"

@ -
set _left to {%player%.coins} - 50

@ *
set _double to {%player%.coins} * 2

@ and, or, not
if {%player%.coins} >= 50 and not {shop_closed}:
    send "&aThe shop is open."

@ is / is not
if event.cause is "FALL":
    cancel event

@ <list> + <value>
set _everyone to server.players + "Console"

@ <text> + <text>
set _greeting to "Hello, " + player.name

@ send <text> to <player name>
send "&e%player.name% says hi!" to arg.1

@ wait <number> seconds
set _delay to 5
wait _delay seconds

@ file at <path> exists
if file at "plugins/HyperScript/notes.txt" exists:
    send read file at "plugins/HyperScript/notes.txt"

@ damage
on entity damage:
    if damage >= 10:
        send "&cThat hit hard!" to victim

@ block
on block break:
    if block is "diamond_ore":
        broadcast "&b%player.name% found diamonds!"

@ slot
on inventory click:
    if slot is 1:
        send "&7You clicked the first slot."

@ item
on right click:
    if item is "compass":
        send "&bYou are in %player.world%"

@ permission <who> add <node> / permission <who> remove <node>
permission player add "server.fly"
permission player remove "server.fly"

@ permission <who> add <node>
permission player add "server.fly"

@ sorted <list>
set _names to sorted server.players

@ reversed <list>
set _newest_first to reversed {winners}

@ x of <location>, y of <location>, z of <location>
set _height to y of player's location

@ world of <location>
send "Your home is in " + world of {%player%.home}

@ set y of <variable> to <number>
set {_loc} to player's location
add 10 to y of {_loc}
teleport player to {_loc}

@ block at <position>
if block at player's location is "water":
    send "&bYou are standing in water."

@ send <text> to player
send "&aSaved." to player

@ send <text> to all players
send "&6The event starts in one minute!" to all players

@ remove <item> from <who>
if player has 5 diamond:
    remove 5 diamond from player

@ has <item>
if player has 5 diamond:
    send "&aYou can afford the upgrade."

@ does not have <item>
if player does not have 1 iron pickaxe:
    send "&cBring a pickaxe."

@ parse <text> as number
set _amount to parse arg.1 as number
if _amount is not set:
    send "&cThat is not a number."

@ parse <text> as integer
set _whole to parse "7.9" as integer

@ parse <value> as text
set _label to parse 52 as text

@ return [<value>]
function double(_n):
    return _n * 2

@ function <name>(<locals>):
function reward(_who, _amount):
    add _amount to {%_who%.coins}
    return {%_who%.coins}

@ local function <name>(<locals>):
local function prefix():
    return "&7[&bShop&7] "

@ command
on player command:
    if command is "plugins":
        cancel event

@ amount
on item pickup:
    send "&7Picked up %event.amount% %event.item%"

@ %event.from%
on world change:
    send "&7You left %event.from% for %player.world%"

@ %hyperscript_<name>%
set {event_active} to true
# Any plugin that uses PlaceholderAPI can now show it:
# "Event running: %hyperscript_event_active%"

@ %hyperscript_player_<name>%
set {%player%.coins} to 100
# Any plugin that uses PlaceholderAPI can now show it to that player:
# "Coins: %hyperscript_player_coins%"

@ min(a, b, ...) / max(a, b, ...)
set _level to max(1, {%player%.level})
set _cheapest to min([30, 12, 45])

@ abs(n)
set _apart to abs(player.y - 64)

@ round(n)
set _whole to round(2.5)

@ floor(n) / ceil(n)
set _pages to ceil(size of {warps} / 9)

@ rounded up <n> / rounded down <n>
set _minutes to rounded up (_seconds / 60)

@ sqrt(n)
set _side to sqrt(25)

@ duration(seconds)
set _left to duration({%player%.ready} - server.time)
send "&cWait %_left%."

@ duration(<seconds>)
send "&7Uptime: " + duration(125)

@ distance between <a> and <b>
if distance between player's location and {spawn} > 100:
    send "&7You are far from spawn."

@ is banned / is not banned
if arg.1 is banned:
    send "&c%arg.1% is banned."

@ items <a> to <b> of <list>
set _top to items 1 to 5 of reversed sorted {scores}

@ index of <value> in <list>
set _place to index of player.name in {queue}

@ random item of <list>
send random item of ["Hello!", "Hi there!", "Welcome!"]

@ keys of {<table>}
for each _name in keys of {warp}:
    send "&7 - &b%_name%"

@ break / continue
for each _name in {queue}:
    if _name is "Steve":
        continue
    send "&7Next: %_name%"
    break

@ send <text> with click command <text>
send "&a[Go home]" with click command "/home"

@ send <text> with hover <text>
send "&e[?]" with hover "&7Hover text can explain things."

@ with click command <text>
send "&a[Accept]" with click command "/accept"

@ with click suggestion <text>
send "&7[Reply]" with click suggestion "/msg Alex "

@ with click url <text>
send "&b[Website]" with click url "https://example.com"

@ with hover <text>
send "&6Rules" with hover "&7Be kind.\n&7No griefing."

@ set helmet of <who> to <item>
set helmet of player to 1 diamond helmet enchanted with protection 4

@ clear inventory of <who>
clear inventory of player

@ helmet, chestplate, leggings, boots
set chestplate of player to 1 iron chestplate
delete boots of player

@ tool
if tool of player is not set:
    send "&7Your hand is empty."

@ offhand
set offhand of player to 1 shield

@ inventory slot <n>
set inventory slot 1 of player to 1 compass named "&bMenu"

@ kick, ban, unban
kick arg.1 because "&cPlease calm down."
ban arg.1 for 7 days because "&cGriefing"

@ kick <who> [because <text>]
kick arg.1 because "&cPlease calm down."

@ ban <who> [for <duration>] [because <text>]
ban arg.1 for 7 days because "&cGriefing"

@ unban <who>
unban arg.1

@ <who> is banned / is not banned
if arg.1 is not banned:
    send "&7%arg.1% is not banned."

@ refuse login [because <text>]
on player login:
    if {maintenance}:
        refuse login because "&eBack soon!"

@ add <who> to team <name>
add player to team "red"

@ remove <who> from team
remove player from team

@ remove <who> from team <name>
remove player from team "red"

@ set color of team <name> to <colour>
set color of team "red" to red

@ set prefix of team <name> to <text> / set suffix of team <name> to <text>
set prefix of team "red" to "&c[Red] "

@ set friendly fire of team <name> to <true or false>
set friendly fire of team "red" to false

@ delete team <name>
delete team "red"

@ team of <who>
if team of player is "red":
    send "&cGo red!"

@ players of team <name>
for each _mate in players of team "red":
    send "&cRed team, assemble!" to _mate

@ <on|off>, <red|blue|green>
command /event <on|off>:
    trigger:
        send "&7You chose %arg.1%."

@ <player> or <target>
command /greet <player>:
    trigger:
        send "&aHello from %player.name%!" to arg.1

@ %event.name%
on player login:
    log "%event.name% is connecting from %event.address%"

@ %event.uuid%
on player login:
    log "%event.name% has the id %event.uuid%"


@ %event.address%
on player login:
    log "%event.name% is connecting from %event.address%"

@ heal <who> / feed <who>
heal player
feed player

@ health of <who>
if health of player < 6:
    send "&cYou are badly hurt!"

@ max health of <who>
set max health of player to 40

@ food of <who>
set food of player to 20

@ level of <who>
add 5 to level of player

@ gamemode of <who>
set gamemode of player to creative

@ flight of <who>
set flight of player to true

@ apply <effect> [<level>] to <who> [for <duration>]
apply speed 2 to player for 30 seconds

@ clear effects of <who> / clear <effect> effect of <who>
clear effects of player
clear speed effect of player

@ ignite <who> [for <duration>] / extinguish <who>
ignite arg.1 for 3 seconds
extinguish player

@ freeze <who> / unfreeze <who>
freeze arg.1
send "&cYou have been frozen." to arg.1

@ vanish <who> / unvanish <who>
vanish player
send "&7Nobody can see you now."

@ <who> has effect <effect> / does not have effect <effect>
if player has effect speed:
    send "&bYou are fast."

@ has effect / does not have effect
if player does not have effect night vision:
    apply night vision to player for 5 minutes

@ <who> is frozen / is vanished / is flying
if arg.1 is frozen:
    send "&7%arg.1% is frozen."

@ is frozen / is vanished / is flying
if player is flying:
    send "&7Enjoy the view."

@ is tagged / is not tagged
if tool of player is tagged "wand":
    send "&dThe wand hums."

@ heal, feed, apply <effect>, freeze, vanish
heal player
apply regeneration 2 to player for 10 seconds

@ top <n> players by {<name>}
set _place to 0
for each _name in top 10 players by {coins}:
    add 1 to _place
    send "&e#%_place% &f%_name%"

@ rank of <who> by {<name>}
set _mine to rank of player by {coins}
send "&7You are #%_mine%"

@ gui page
open gui with title "&8Menu" with 1 rows for player:
    slot 5 is "paper" named "&fPage %gui page%"

@ page <n> of <list> with <k> per page
set _shown to page 2 of {names} with 9 per page

@ pages of <list> with <k> per page
set _count to pages of {names} with 9 per page

@ next page / previous page
open gui with title "&8Menu" with 1 rows for player:
    slot 1 is "arrow" named "&ePrevious":
        previous page
    slot 9 is "arrow" named "&eNext":
        next page

@ set gui page to <n>
open gui with title "&8Menu" with 1 rows for player:
    slot 5 is "compass" named "&eBack to the first page":
        set gui page to 1

@ refresh gui
open gui with title "&8Clicker" with 1 rows for player:
    slot 5 is "gold_ingot" named "&6Clicks: %{%player%.clicks}%":
        add 1 to {%player%.clicks}
        refresh gui

@ every day at <hh:mm>:
every day at 18:00:
    broadcast "&6The evening event starts now!"

@ every monday at <hh:mm>:
every monday at 00:00:
    delete {weekly_winner}

@ %event.region%
on region enter:
    send action bar "&7Entering &f%event.region%" to player

@ %event.lines%
on sign change:
    log "%player.name% wrote: %event.lines%"

@ %event.clicked%
on entity click:
    send "&7You clicked &f%event.clicked%"

@ %event.level%, %event.old_level%
on level up:
    send "&aLevel %event.old_level% -> %event.level%"

@ starts with / ends with
on player chat:
    if message starts with "!":
        cancel event
        send "&7Commands start with / here."

@ matches
if not (arg.1 matches "[a-zA-Z0-9_]{3,16}"):
    send "&cThat is not a valid name."

@ chance of <n>%
on block break:
    if chance of 5%:
        give 1 diamond to player
        send "&bLucky find!"

@ random player
set _winner to random player
broadcast "&6%_winner% wins the draw!"

@ shuffled <list>
set _order to shuffled server.players

@ unique <list>
set _once to unique ["a", "b", "a"]

@ sum of <list> / average of <list>
set _total to sum of [10, 20, 30]
set _mean to average of [10, 20, 30]

@ players within <n> blocks of <location>
for each _near in players within 10 blocks of player:
    send "&7%player.name% waves at you." to _near

@ <text> parsed as number
set _amount to arg.1 parsed as number
if _amount is not set:
    send "&cThat is not a number."

@ now formatted as <pattern>
send "&7It is " + now formatted as "HH:mm"

@ %server.date%
log "Backup finished on %server.date% at %server.clock%"

@ %server.clock%
send "&7Server time: &f%server.clock%"

@ %server.weekday%
if server.weekday is "saturday":
    send "&6Double coins today!"

@ %server.hour%, %server.minute%
if server.hour >= 22:
    send "&7It is late. Good night!"

@ options:
options:
    prefix: "&8[&6Shop&8] "
command /shop:
    trigger:
        send "{@prefix}&7Welcome."

@ command /name:
command /hello:
    trigger:
        send "&aHello!"

@ on <event>:
on player join:
    send "&aWelcome!"

@ on load:
on load:
    if {motd} is not set:
        set {motd} to "&aWelcome!"

@ every <time>:
every 5 minutes:
    broadcast "&7Remember to vote!"

@ function name():
function greet():
    send "&aHello!"

@ # Requires: 1.5.9
# Requires: 1.5.9
on player join:
    send "&aWelcome!"

@ # Tags: chat, welcome
# Tags: chat, welcome
on player join:
    send "&aWelcome!"

@ on server start:
on server start:
    log "The server is up. %server.online_players% player(s) online."

@ on server stop:
on server stop:
    set {last_shutdown} to now

@ %server.worlds%
for each _world in server.worlds:
    send "&7 - &f%_world%"

@ %server.operators%, %server.banned%, %server.whitelist%
send "&7Operators: &f%server.operators%"

@ %server.plugins%
send "&7Plugins: &f%server.plugins%"

@ %server.uptime%
send "&7The server has been up for &f%server.uptime%"

@ %server.memory_used%, %server.memory_max%
send "&7Memory: &f%server.memory_used% &7of &f%server.memory_max% &7MB"

@ pow(a, b)
set _cost to 100 * pow(2, {%player%.upgrades})

@ round(n, places)
set _ratio to round({%player%.kills} / max(1, {%player%.deaths}), 2)

@ percent(part, whole)
set _done to percent({%player%.quests_done}, 20)
send "&7Quests: &f%_done%%"

@ commas(n)
set _shown to commas({%player%.coins})
send "&6Balance: &e%_shown% coins"

@ ordinal(n)
set _place to ordinal(rank of player by {coins})
send "&7You are in &f%_place% &7place."

@ roman(n)
set _level to roman({%player%.prestige})
send "&dPrestige %_level%"

@ today / tomorrow
if {%player%.last_vote} < today:
    send "&eYou have not voted today."

@ time since <date>
set _ago to time since {%player%.last_death}
send "&7You last died %_ago% ago."

@ first join date of <who> / last seen of <who>
set _seen to last seen of arg.1
send "&7%arg.1% was last on: &f%_seen%"

@ is between <a> and <b>
if player.y is between 0 and 16:
    send "&bDiamond level!"

@ is in <list>
if arg.1 is in ["on", "off"]:
    send "&aOK."

@ is empty
if {queue} is empty:
    send "&7Nobody is waiting."

@ is a list / a location / an item / a date / an entity / a table / text
if {%player%.home} is a location:
    teleport player to {%player%.home}

@ is a player
if arg.1 is not a player:
    send "&c%arg.1% is not online."

@ is alphanumeric
if arg.1 is not alphanumeric:
    send "&cUse letters and digits only."

@ is sneaking / sprinting / swimming / blocking / sleeping / on ground / in water
on right click:
    if player is sneaking:
        send "&7A sneaky click."

@ is op / is online
if arg.1 is online:
    send "&a%arg.1% is here."

@ has played before
if arg.1 has played before:
    send "&7%arg.1% has been here."

@ is holding <item> / is wearing <item>
if player is holding diamond sword:
    send "&bNice sword."

@ can see <player>
if player can see arg.1:
    send "&7You can see %arg.1%."

@ <world> is raining / is day / is night
if player.world is night:
    send "&7It is dark. Watch out."

@ <block> is solid
if block at (location below player's location) is solid:
    send "&7You are on firm ground."

@ numbers from <a> to <b>
for each _n in numbers from 3 to 1:
    send "&e%_n%..."

@ count of <value> in <list>
set _votes to count of "yes" in {votes}

@ min of <list> / max of <list>
set _best to max of {scores}

@ capitalized <text>
send capitalized "hello there"

@ title case <text>
set _nice to title case "diamond_sword"
send "&7You found a %_nice%"

@ uncoloured <text>
log uncoloured "&aGreen text"

@ word <n> of <text>
set _first to word 1 of args

@ <text> repeated <n> times
send "&8" + ("-" repeated 20 times)

@ run <function>(...) in <duration>
function remind(_who):
    send "&eTime is up!" to _who
command /timer:
    trigger:
        run remind(player.name) in 30 seconds

@ console only: true
command /maintenance:
    console only: true
    trigger:
        set {maintenance} to true

@ <name:player>
command /greet <target:player>:
    trigger:
        send "&aHello!" to arg.1

@ <name:number>
command /setprice <price:number>:
    trigger:
        set {price} to arg.1

@ <name:integer>
command /roll <sides:integer>:
    trigger:
        send "&7You rolled " + random integer between 1 and arg.1

@ [name:type]
command /heal [target:player]:
    trigger:
        if arg.1 is set:
            heal arg.1
        else:
            heal player

@ strike lightning at <location>
strike lightning at player's location

@ create explosion at <location> [with power <n>]
create explosion at player's location with power 3 without breaking blocks

@ fill from <location> to <location> with <block>
fill from 0, 64, 0 in "world" to 4, 64, 4 in "world" with stone

@ break block at <location>
break block at location below player's location

@ grow tree at <location>
grow tree at player's location

@ drop <item> at <location>
drop 1 diamond at event's location

@ set spawn of world <name> to <location>
set spawn of world "world" to player's location

@ set world border of world <name> to <size> [over <duration>]
set world border of world "world" to 500 over 5 minutes

@ make <who> say <text>
make player say "I love this server!"

@ open workbench for <who> / open enderchest for <who>
open workbench for player

@ fly speed of <who> / walk speed of <who>
set walk speed of player to 0.4

@ saturation of <who> / air of <who>
if air of player < 3:
    send "&cYou are running out of breath!"

@ held slot of <who>
set held slot of player to 1

@ compass target of <who> / bed spawn of <who>
set compass target of player to {spawn}

@ yaw of <who> / pitch of <who> / direction of <who>
send "&7You are facing &f" + direction of player

@ ip of <who> / locale of <who>
log "%player.name% uses the language " + locale of player

@ time played of <who>
send "&7Played: &f" + time played of player

@ fall distance of <who>
if fall distance of player > 20:
    send "&cBrace yourself!"

@ event entity
on mob spawn:
    set _mob to event entity
    set name of _mob to "&cWild thing"

@ clicked entity
on entity click:
    push clicked entity upward with force 0.6

@ target entity of <who>
set _looking to target entity of player
if _looking is set:
    send "&7You are looking at &f%_looking%"

@ push <who> upward / downward / forward / backward [with force <n>]
push player upward with force 1.2

@ push <who> towards <location> [with force <n>]
push player towards {spawn} with force 0.8

@ remove entity <entity>
summon zombie at player's location
set _mob to last summoned entity
wait 10 seconds
remove entity _mob

@ remove all <type> within <n> blocks of <location>
remove all zombies within 20 blocks of player's location

@ <location> offset by <x>, <y>, <z>
teleport player to player's location offset by 0, 10, 0

@ location above <location> / location below <location>
set block at location below player's location to stone

@ midpoint between <a> and <b>
set _middle to midpoint between {arena.corner1} and {arena.corner2}

@ highest block at <location>
teleport player to location above highest block at player's location

@ biome at <location>
send "&7Biome: &f" + biome at player's location

@ light level at <location>
if light level at player's location < 8:
    send "&7Mobs can spawn here."

@ target block of <who>
set _looked to target block of player
if _looked is set:
    strike fake lightning at _looked

@ <location> is within <n> blocks of <location>
if player's location is within 10 blocks of {spawn}:
    send "&aYou are near spawn."

@ <location> is loaded
if {arena} is loaded:
    summon zombie at {arena}


@ players only: true
command /sethome:
    players only: true
    trigger:
        set {%player%.home} to player's location

@ increase <variable> by <n> / decrease <variable> by <n>
increase {%player%.coins} by 10
decrease {%player%.lives} by 1

@ toggle <variable>
toggle {%player%.pvp_on}
send "&7PvP: %{%player%.pvp_on}%"

@ swap <variable> and <variable>
swap {team.red.score} and {team.blue.score}

@ default <variable> to <value>
on load:
    default {motd} to "&aWelcome!"

@ has space for <item>
if player has space for 5 diamond:
    give 5 diamond to player
else:
    send "&cYour inventory is full."

@ is bedrock / is dead
if player is bedrock:
    send "&7Bedrock players: use /menu instead of the book."

@ <a> if <condition> else <b>
set _state to "&aon" if {%player%.pvp_on} else "&coff"
send "&7PvP is %_state%"

@ <list> without <value>
for each _other in server.players without player.name:
    send "&7%player.name% says hi" to _other

@ <list> sorted by {<name>}
set _richest to server.players sorted by {coins}
send "&6Richest online: &e" + item 1 of _richest

@ map each <list> to <expression>
set _shouted to map each ["red", "blue"] to uppercase it

@ <text> padded to <n>
for each _name in server.players:
    send "&f" + (_name padded to 16) + "&e%{%_name%.coins}%"

@ clamp(n, least, most)
set {%player%.mana} to clamp({%player%.mana} + 5, 0, 100)

@ random(a, b)
set _roll to random(1, 6)
send "&7You rolled a &f%_roll%"

@ run <function>(...) in <duration> as <name>
function end_boost(_who):
    set walk speed of _who to 0.2
command /boost:
    trigger:
        set walk speed of player to 0.4
        run end_boost(player.name) in 30 seconds as "boost %player.name%"

@ cancel run <name>
cancel run "boost %player.name%"

@ respawn <who>
on player death:
    wait 1 tick
    respawn player

@ show <who> a book titled <text> with pages <text>, <text>
show player a book titled "Rules" with pages "&lRules\n\n1. Be kind.", "2. No griefing."

@ hide <who> from <who> / show <who> to <who>
hide player from arg.1
send "&7%arg.1% can no longer see you."

@ clear title of <who>
clear title of player

@ tab name of <who>
set tab name of player to "&6[VIP] &f%player.name%"

@ free slots of <who>
if free slots of player < 3:
    send "&eYour inventory is nearly full."

@ ping of <who>
send "&7Ping of %arg.1%: &f" + ping of arg.1

@ spawn firework at <location>
spawn firework at player's location colored red, yellow shaped star with power 1

@ play effect <name> at <location>
play effect ender_signal at player's location

@ set line <n> of sign at <location> to <text>
set line 1 of sign at {shop.sign} to "&a[Open]"

@ items in chest at <location>
for each _item in items in chest at {reward.chest}:
    give _item to player

@ add <item> to chest at <location> / clear chest at <location>
clear chest at {reward.chest}
add 3 diamond to chest at {reward.chest}

@ set gamerule <name> of world <name> to <value>
set gamerule keepInventory of world "world" to true

@ set difficulty of world <name> to <level>
set difficulty of world "world" to hard

@ set pvp of world <name> to <true or false>
set pvp of world "world" to false

@ set pvp of region <name> to <true or false>
on load:
    set pvp of region "spawn" to false

@ set build of region <name> to <true or false>
on load:
    set build of region "spawn" to false

@ players in region <name>
for each _name in players in region "arena":
    send "&cThe match starts now!" to _name

@ spawn of world <name>
teleport player to spawn of world "world"

@ tab complete: <list>
command /warp <name>:
    tab complete: keys of {warp}
    trigger:
        teleport player to {warp.%arg.1%}

@ disabled: true
command /beta:
    disabled: true
    trigger:
        send "&7Not ready yet."

@ subcommand <name>:
command /team:
    subcommand join <red|blue>:
        trigger:
            add player to team arg.1
    subcommand leave:
        trigger:
            remove player from team

@ on shield block:
on shield block:
    add 1 to {%player%.blocks_made}

@ type of <item>
set _held to tool of player
if type of _held is "diamond_sword":
    send "&bA fine blade."

@ amount of <item>
set _held to tool of player
send "&7You are holding " + amount of _held + " item(s)."

@ send toast <text> [with icon <item>] [as goal] [to <who>]
send toast "&aQuest complete!" with icon diamond as challenge to player

@ give head of <name> to <who>
on player kill:
    give head of victim to player

@ set item cooldown of <item> for <who> to <duration>
on right click:
    if event.item is "blaze_rod":
        if item cooldown of blaze rod for player > 0 seconds:
            stop
        set item cooldown of blaze rod for player to 5 seconds
        strike lightning at target block of player

@ stop sound <name> [for <who>] / stop all sounds [for <who>]
stop sound "music_disc.cat" for player

@ absorption of <who>
set absorption of player to 8

@ protocol version of <who>
if protocol version of player < 765:
    send "&eYou are on an old version; some things may look different."

@ client brand of <who>
log "%player.name% plays with " + client brand of player

@ create hologram <name> at <location> with lines <text>, <text>
command /sethologram:
    permission: "holograms.manage"
    trigger:
        create hologram "welcome" at player's location with lines "&6&lWelcome", "&7Type &f/help &7to begin"

@ set line <n> of hologram <name> to <text>
every 1 minute:
    set line 2 of hologram "welcome" to "&7Online: &f%server.online_players%"

@ delete hologram <name>
delete hologram "welcome"

@ holograms
send "&7Holograms: &f" + join holograms with ", "

@ set item <n> of <variable> to <value>
set {podium} to ["Steve", "Alex", "Bob"]
set item 1 of {podium} to player.name
send "&6First place: &f" + item 1 of {podium}

@ ask <who> <text> into <variable>
command /clan <action>:
    trigger:
        ask player "&eWhat should your clan be called?" into _name for at most 30 seconds
        if _name is not set:
            send "&cToo slow."
            stop
        send "&aClan %_name% created."

@ ask <who> <text> with options <text>, <text> into <variable>
ask player "&ePick a team:" with options "Red", "Blue" into _team
if _team is set:
    add player to team lowercase _team

@ confirm <text>:
command /delhome:
    trigger:
        confirm "&cDelete your home? This cannot be undone.":
            delete {%player%.home}
            send "&eHome deleted."

@ items in ender chest of <who>
send "&7Your ender chest holds " + size of (items in ender chest of player) + " stack(s)."

@ add <item> to ender chest of <who> / clear ender chest of <who>
add 3 diamond to ender chest of player
send "&bA gift is waiting in your ender chest."

@ format(n, pattern)
set _ratio to {%player%.kills} / max({%player%.deaths}, 1)
send "&7K/D: &f" + format(_ratio, "0.00")

@ json of <value>
set {_body.player} to player.name
set {_body.coins} to {%player%.coins} + 0
send post request to "https://example.com/hook" with body json of _body

@ owned by <name>
give 1 player head owned by "Notch" named "&6Notch's head" to player

@ with potion <kind>
give 1 splash potion with potion strong_healing to player

@ with segments <n>
create bossbar "lives" titled "&cLives" with color red with segments 10 with progress 70 for player

@ location of <who>
if distance between player's location and location of arg.1 > 10:
    send "&c%arg.1% is too far away."

@ owned by <name>
open gui with title "&8Online" with 1 rows for player:
    slot 1 is "player_head" owned by player.name named "&f%player.name%"

@ create world <name>
command /makearena:
    permission: "worlds.manage"
    trigger:
        send "&7Making the arena..."
        create world "arena" flat without structures
        teleport player to spawn of world "arena"

@ load world <name> / unload world <name>
command /closearena:
    permission: "worlds.manage"
    trigger:
        unload world "arena"
        send "&7The arena is closed."

@ delete world <name>
command /resetarena:
    permission: "worlds.manage"
    trigger:
        confirm "&cDelete the arena world and everything in it?":
            delete world "arena"
            create world "arena" flat without structures
            send "&aThe arena is new again."

@ created worlds
send "&7Worlds made here: &f" + join created worlds with ", "

@ <who>'s location
loop all players:
    draw particle circle with radius 2 using particle "flame" at loop-player's location

@ fire event <name>
on player kill:
    set _victim to victim
    fire event "kill" with {_victim}

on event "kill":
    add 1 to {%player%.kills}
    send "&7You defeated &f%_victim%"

@ schedule <function>(...) in <duration>
function end_vip(_who):
    delete {%_who%.vip}
    send "&7Your VIP time is over." to _who

command /vip <target:player>:
    permission: "vip.give"
    trigger:
        set {%arg.1%.vip} to true
        schedule end_vip(arg.1) in 30 days as "vip %arg.1%"

@ cancel schedule <name>
cancel schedule "vip %arg.1%"

@ set fake block at <position> to <block>
on right click:
    if event.block is "stone":
        set fake block at event's location to gold block
        send "&6Only you can see that."

@ clear fake block at <position>
command /reveal:
    players only: true
    trigger:
        set fake block at player to glass
        wait 5 seconds
        clear fake block at player
