Cheat sheet
The most-used syntax on one page. Everything here, and everything else, is on the Docs page with examples.
A script file
# Notes about the script
options:
prefix: "&8[&6Shop&8] "
command /hello <target:player>:
permission: "hello.use"
cooldown: 10 seconds
trigger:
send "{@prefix}&aHello!" to arg.1
on player join:
send "&aWelcome, %player.name%!"
every 5 minutes:
broadcast "&7Remember to vote!"
function double({_n}):
return {_n} * 2
Variables and values
| Write | Meaning |
{name} | Saved, shared by every script |
{%player%.name} | Saved, each player's own |
{_name} | For this run only |
{@name} | A setting from options: |
"%player.name% has %{%player%.coins}%" | Values inside text |
set, add ... to, subtract ... from, delete | Change a variable |
[1, 2, 3], append x to, size of, item 1 of | Lists |
5 minutes, now, player's location, 1 diamond sword | Durations, dates, places, items |
Deciding and repeating
| Write | Meaning |
if ...: / else if ...: / else: | Choose |
unless ...: | The opposite of if |
switch arg.1: with case "a": and default: | One of many |
randomly: with 70%:, 30%: | One of several, by chance |
loop 5 times: / for each {_x} in <list>: / while ...: | Repeat; else: under a loop runs when it never went round |
loop from 1 to 10: / loop from 10 to 0 by 2: / loop {_list}: | Count, or go through a list |
loop-value / loop-index | What the loop is on, and which round it is; in a loop inside a loop loop-value-1, loop-value-2 |
loop all players: with loop-player (or loop player) | Everyone online |
loop all players with permission "staff": / loop {_list} where ...: | Some of them only |
loop blocks within 3 blocks of player: | Every block around a place |
break / continue / stop | Leave a loop, skip a round, end the trigger |
stop if ... / continue if ... / break unless ... | The same, on one line with its condition |
after 5 seconds: | Run a block later and carry on now |
wait 5 seconds / wait until ... | Pause |
try: / on error: | Deal with a failure |
Common conditions
| Write | Meaning |
== != < > is is not | Compare |
is set / is not set | Has a value |
contains, starts with, is in <list> | Text and lists |
player has permission "x" | Permissions |
player has 5 diamond | Inventory |
player is sneaking, is op, is online | Player state |
chance of 25% | At random |
and, or, not | Combine |
Common effects
| Write | Meaning |
send "..." [to <who>] / broadcast "..." | Chat |
send title "...", send action bar "..." | On screen |
give 1 diamond to player / remove 1 diamond from player | Items |
teleport player to <location> | Move |
heal player, feed player, kill player | Health |
apply speed 2 to player for 30 seconds | Potion effects |
set gamemode of player to creative | Game mode |
play sound "..." at player's location | Sound |
execute console command "..." | Any other command |
cancel event | Stop what the event is about |
open gui with title "..." for player: with slot 1 is "diamond": | Menus |