-
-
Notifications
You must be signed in to change notification settings - Fork 2
Command Tree
A command tree is just like any other command, but comes with an easier way to handle arguments.
Arguments can be registered within a command tree as well as within other arguments.
Each argument can have more arguments and their own triggers, as well as their own permissions.
brig[(gy|adier)] command[ ]tree /<.+>:
brig command tree /leban:
-
permission
= Just like Skript, the permission the player will require for this command. -
description
= Just like Skript, this is a string that will be used in the help command. -
usages
= This is the usage which is shown in the specific/help <command>
page. Separate multiple usages by comma. -
aliases
= Aliases for this command.
Both of these are optional, but you will require one or the other.
-
register arg
= Register another subcommand within this one. Supports multiple. [Optional] -
trigger
= Like any other command, this is what will execute when the command is run. [Optional]
-
permission
= Each subcommand can have its own permission.
Just like the command tree, arguments and triggers are optional, but you will require one or the other.
-
suggestions
= You can apply suggestions (with tooltips) to a subcommand. Seeapply suggestion
effect, and examples. [Optional] -
register arg
= Register another subcommand within this one. Supports multiple. [Optional] -
trigger
= Like any other command, this is what will execute when the command is run. [Optional]
Gamemode command example with optional arg that can be bypassed.
This was designed to match the vanilla gamemode command.
brig command tree /gamemode:
literal arg "gamemode" using "adventure", "creative", "spectator", "survival":
# When optional, the trigger will still run but the arg is ignored
optional players arg "players":
trigger:
# if the player arg is not used, we will default to the command sender
set {_players::*} to {_players::*} ? player
set {_gamemode} to {_gamemode} parsed as gamemode
set gamemode of {_players::*} to {_gamemode}
This example shows how to use 2 different triggers in one command.
# Example similar to above but using 2 different triggers
brig command tree /spawn:
world arg "world":
trigger:
teleport player to spawn of {_world}
# if the argument isn't entered, this will execute
trigger:
teleport player to spawn of world of player
This is a simple example to showing using multiple sub args to create a ban command.
brig command tree /leban:
description: &bThis allows you to ban players
usages: /leban &7<&bplayers&7> &7<&btimespan&7>
players arg "players":
int arg "time":
string arg "span" using "minutes", "hours", "days":
# When optional, the trigger will still run but the arg is ignored
optional greedy string arg "reason":
trigger:
set {_timespan} to "%{_time}% %{_span}%" parsed as timespan
set {_reason} to {_reason} ? "Unknown Reason"
ban {_players::*} due to "&c" + {_reason} for {_timespan}
kick {_players::*} due to "&c" + {_reason}
This example shows of how to use the suggestions
section along with applying suggestions with tooltips.
# Example showing off suggestions with tooltips
brig command tree /warp:
string arg "warp":
suggestions:
loop {warps::*}:
set {_s} to "&7x: &b%x coord of loop-value% &7y: &b%y coord of loop-value% &7z: &b%z coord of loop-value% &7world: &a%world of loop-value%"
apply suggestion loop-index with tooltip {_s}
trigger:
if {warps::%{_warp}%} is set:
teleport player to {warps::%{_warp}%}
else:
send "No warp available for %{_warp}%"
This example shows a similar warp command, but with subcommands that each have their own permissions
brig command tree /warps:
description: All your warpin needs!
# We use literal args to make sure the player can only type these options
literal arg "set":
# Each subcommand can have its own permission
permission: warps.set
string arg "warp":
trigger:
if {warps::%{_warp}%} is set:
send "&7[&bWarps&7] &6Warp already set &r'&c%{_warp}%&r'"
else:
set {warps::%{_warp}%} to location of player
send "&7[&bWarps&7] &6Created new warp &r'&b%{_warp}%&r'"
literal arg "delete":
permission: warps.delete
string arg "warp":
suggestions:
apply suggestions (indexes of {warps::*})
trigger:
if {warps::%{_warp}%} is set:
delete {warps::%{_warp}%}
send "&7[&bWarps&7] &6Deleted warp &r'&b%{_warp}%&r'"
else:
send "&7[&bWarps&7] &6Unknown warp &r'&c%{_warp}%&r'"
literal arg "warp":
permission: warps.warp
string arg "warp":
suggestions:
loop {warps::*}:
set {_s} to "&7x: &b%x coord of loop-value% &7y: &b%y coord of loop-value% &7z: &b%z coord of loop-value% &7world: &a%world of loop-value%"
apply suggestion loop-index with tooltip {_s}
players arg "players":
permission: warps.warp.other
trigger:
if {warps::%{_warp}%} is set:
teleport {_players::*} to {warps::%{_warp}%}
else:
send "&7[&bWarps&7] &6Unknown warp &r'&c%{_warp}%&r'"
trigger:
if {warps::%{_warp}%} is set:
teleport player to {warps::%{_warp}%}
else:
send "&7[&bWarps&7] &6Unknown warp &r'&c%{_warp}%&r'"