CommandTree - Command (Structure) — SkBriggy

Addon: SkBriggy · Category: Structure · Since: 1.4.0

Syntax

brig[(gy|adier)] command[ ]tree /<.+>

Description

Command trees are similar to regular commands with the difference being the arguments are in a tree. By having a tree, each argument can have sub args as well as their own triggers. See [**SkBriggy Wiki**](https://github.com/ShaneBeee/SkBriggy/wiki/Command-Tree) for more detailed info.

Command names can include namespaces, ex: `brig command tree /mycommands:somecommand`. Defaults to `minecraft` when excluded.

**Entries/Sections**: `executor_type` = What types of execturs can run this command (Optional, defaults to `all`). `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. `override` = Whether to completely wipe out other commands with the same name, such as vanilla Minecraft commands (Defaults to false). `register arg` = Register another subcommand within this one. Supports multiple. `trigger` = Like any other command, this is what will execute when the command is run.

Examples

# Example with optional arg that can be bypassed
brig command tree /legamemode:
	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}

# 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

# Example showing off suggestions with tooltips
brig command tree /lewarp:
	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}%"

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}

View source