Skip to content

Advanced Features

The Custom Commands plugin includes powerful advanced features that allow you to create complex command structures with nested subcommands, argument validation, player-specific arguments, and flexible command execution types.

The nested subcommands feature allows you to create hierarchical command structures where subcommands can have their own subcommands, creating unlimited depth levels.

Subcommands can contain their own subcommands section, allowing you to build complex command trees like /admin player kick <player> or /admin server restart.

commands:
admin:
permission: "customcommands.admin"
subcommands:
player: # /admin player
permission: "customcommands.admin.player"
subcommands: # Nested subcommands!
kick: # /admin player kick
permission: "customcommands.admin.player.kick"
message:
- "&cKicking player..."
ban: # /admin player ban
permission: "customcommands.admin.player.ban"
message:
- "&cBanning player..."
server: # /admin server
permission: "customcommands.admin.server"
subcommands: # More nested subcommands!
restart: # /admin server restart
permission: "customcommands.admin.server.restart"
message:
- "&cRestarting server..."

Permissions follow a hierarchical structure matching the command path:

customcommands.admin # Main command
customcommands.admin.player # First level subcommand
customcommands.admin.player.kick # Second level subcommand
customcommands.admin.server.restart # Another second level subcommand
commands:
admin:
permission: "customcommands.admin"
alias: ["a", "adm"]
description: "Admin command with nested subcommands"
enabled: true
cooldown: 0
type: "Console"
message:
- "&c&l=== Admin Panel ==="
- "&7Use &e/admin help &7to see available commands"
subcommands:
player: # /admin player
permission: "customcommands.admin.player"
message:
- "&6&lPlayer Management"
- "&7Use &e/admin player help &7for more options"
subcommands: # Nested!
kick: # /admin player kick <player>
permission: "customcommands.admin.player.kick"
message:
- "&cKicking player: {args}"
arguments:
whitelist: []
whitelist-only: false
no-arguments: false
player-args: [0] # First argument must be player
invalid-message: "&cUsage: /admin player kick <player>"
commands:
- "kick {args} Kicked by {player}"
ban: # /admin player ban <player>
permission: "customcommands.admin.player.ban"
message:
- "&cBanning player: {args}"
arguments:
whitelist: []
whitelist-only: false
no-arguments: false
player-args: [0] # First argument must be player
invalid-message: "&cUsage: /admin player ban <player>"
commands:
- "ban {args} Banned by {player}"
server: # /admin server
permission: "customcommands.admin.server"
message:
- "&6&lServer Management"
- "&7Use &e/admin server help &7for more options"
subcommands: # More nested subcommands!
restart: # /admin server restart
permission: "customcommands.admin.server.restart"
message:
- "&c&lRestarting server in 10 seconds..."
commands:
- "say Server restarting in 10 seconds!"
- "schedule function minecraft:load 10s"
reload: # /admin server reload
permission: "customcommands.admin.server.reload"
message:
- "&eReloading server..."
commands:
- "reload"
/admin player kick Steve → Kicks player "Steve"
/admin player ban Alex → Bans player "Alex"
/admin server restart → Restarts the server
/admin server reload → Reloads the server

The arguments system allows you to accept and validate arguments passed to your custom commands, with support for whitelisting, validation, and custom error messages.

arguments:
whitelist: [] # List of allowed arguments
whitelist-only: false # Only allow whitelisted arguments
no-arguments: true # Allow command without arguments
invalid-message: "&cInvalid arguments." # Custom error message
player-args: [] # Arguments that must be player names (0-based)
required-args: [] # Arguments that are required (0-based)
OptionTypeDescription
whitelistList<String>List of allowed arguments for autocomplete
whitelist-onlybooleantrue = only whitelisted args, false = any args
no-argumentsbooleantrue = allow without args, false = require args
invalid-messageStringMessage shown when arguments are invalid
player-argsList<Integer>Argument indices that must be player names (0-based)
required-argsList<Integer>Argument indices that are required (0-based)

Arguments can be accessed in two ways:

Use {args} to get all arguments as a single string:

message:
- "&eYou said: {args}" # Shows all arguments
commands:
- "say {player}: {args}" # Broadcasts arguments

Use {arg:1}, {arg:2}, {arg:3}, etc. to access individual arguments (1-based index):

message:
- "&eFirst: {arg:1}, Second: {arg:2}" # Individual arguments
commands:
- "tellraw {player} [\"\",{\"text\":\"Price: \",\"color\":\"gold\"},{\"text\":\"{arg:1}\",\"color\":\"green\"}]"

Variable Index System:

  • {arg:1} = First argument (index 0)
  • {arg:2} = Second argument (index 1)
  • {arg:3} = Third argument (index 2)
  • {arg:N} = Nth argument
  • {args} = All arguments as string (backward compatible)
tellraw:
permission: "customcommands.tellraw"
alias: ["tr", "raw"]
description: "Send a raw JSON message"
enabled: true
cooldown: 0
type: "Console"
arguments:
whitelist: [] # Empty = any arguments allowed
whitelist-only: false # Allow any arguments
no-arguments: false # Arguments required
invalid-message: "&cUsage: /tellraw <message>"
message:
- "&6&lTellraw Command"
- "&eMessage sent: &7{args}"
commands:
- "tellraw {player} [\"\",{\"text\":\"[Tellraw] \",\"color\":\"gold\"},{\"text\":\"{args}\",\"color\":\"yellow\"}]"

Usage:

/tellraw Hello World! → Valid (sends "Hello World!")
/tellraw → Invalid (shows error message)
say:
permission: "customcommands.say"
message:
- "&eYou said: {args}"
arguments:
whitelist: ["hello", "goodbye", "help"] # Only these allowed
whitelist-only: true # Only whitelisted
no-arguments: true # Can be used without args
commands:
- "say {player}: {args}"

Usage:

/say hello → Valid
/say goodbye → Valid
/say test → Invalid (not in whitelist)
/say → Valid (no-arguments: true)
broadcast:
permission: "customcommands.broadcast"
message:
- "&6Broadcasting: {args}"
arguments:
whitelist: ["Server restart in 5 minutes", "Maintenance starting soon", ""]
whitelist-only: true
no-arguments: true
commands:
- "say {args}"

Usage:

/broadcast Server restart in 5 minutes → Valid
/broadcast Maintenance starting soon → Valid
/broadcast → Valid (empty string in whitelist)

Example 4: Required and Optional Arguments

Section titled “Example 4: Required and Optional Arguments”
ah:
permission: "customcommands.ah"
subcommands:
sell: # /ah sell <price> [amount]
permission: "customcommands.ah.sell"
arguments:
required-args: [0] # First argument (price) is REQUIRED
no-arguments: false # Arguments required
invalid-message: "&cUsage: /ah sell <price> [amount]"
commands:
- "tellraw {player} [\"\",{\"text\":\"Price: \",\"color\":\"gold\"},{\"text\":\"{arg:1}\",\"color\":\"green\"},{\"text\":\", Amount: \",\"color\":\"gold\"},{\"text\":\"{arg:2}\",\"color\":\"yellow\"}]"
# {arg:1} = price (required)
# {arg:2} = amount (optional, empty string if not provided)

Usage:

/ah sell 100 → Valid: {arg:1} = "100", {arg:2} = ""
/ah sell 100 64 → Valid: {arg:1} = "100", {arg:2} = "64"
/ah sell → Invalid: Shows error message
transfer:
permission: "customcommands.transfer"
arguments:
required-args: [0, 1] # First AND second arguments required
no-arguments: false
invalid-message: "&cUsage: /transfer <player1> <player2>"
commands:
- "transfer {arg:1} {arg:2}" # Use individual arguments

Usage:

/transfer Steve Alex → Valid: {arg:1} = "Steve", {arg:2} = "Alex"
/transfer Steve → Invalid: Missing second required argument
/transfer → Invalid: Missing both required arguments

You can mark specific arguments as required using required-args. This allows you to create commands where some arguments are required and others are optional.

Example: /ah sell &lt;price&gt; [amount] - price is required, amount is optional

ah:
subcommands:
sell:
arguments:
required-args: [0] # First argument (index 0) is REQUIRED
no-arguments: false # Command requires arguments
invalid-message: "&cUsage: /ah sell <price> [amount]"
commands:
- "tellraw {player} [\"\",{\"text\":\"Price: \",\"color\":\"gold\"},{\"text\":\"{arg:1}\",\"color\":\"green\"}]"
# {arg:1} = price (required)
# {arg:2} = amount (optional, empty string if not provided)

Usage:

  • /ah sell 100{arg:1} = "100", {arg:2} = ""
  • /ah sell 100 64{arg:1} = "100", {arg:2} = "64"
  • /ah sell → Error: “Usage: /ah sell <price> [amount]”

If no arguments section is specified:

  • Commands don’t accept any arguments
  • Default whitelist contains one empty string (command can be used without arguments)
  • Default whitelist-only is true
  • Default no-arguments is true
  • No arguments are required by default

The player-args feature allows you to specify which arguments must be valid player names, with automatic validation and tab-completion.

When you specify player-args, the plugin:

  1. Validates that the specified argument positions contain valid player names
  2. Checks if the player exists and is online
  3. Provides tab-completion showing all online players
  4. Shows clear error messages for invalid players

Arguments are indexed starting from 0:

  • Index 0 = First argument after command/subcommand
  • Index 1 = Second argument
  • Index 2 = Third argument
  • etc.
arguments:
player-args: [0] # First argument (index 0) must be a player name
player-args: [0, 2] # First (0) and third (2) arguments must be player names
player-args: [1] # Second argument (index 1) must be a player name
kick:
permission: "customcommands.kick"
message:
- "&cKicking player: {args}"
arguments:
whitelist: []
whitelist-only: false
no-arguments: false
player-args: [0] # First argument = player name
invalid-message: "&cUsage: /kick <player>"
commands:
- "kick {args} Kicked by {player}"

Usage:

/kick Steve → Valid (if Steve is online)
/kick InvalidPlayer → Error: "Player InvalidPlayer is not online or does not exist!"
/kick → Error: "Usage: /kick <player>"

Tab Completion: After typing /kick , all online players are shown.

Example 2: Teleport with Player + Coordinates

Section titled “Example 2: Teleport with Player + Coordinates”
teleport:
permission: "customcommands.teleport"
message:
- "&6Teleporting player..."
arguments:
whitelist: []
whitelist-only: false
no-arguments: false
player-args: [0] # First argument = player name
invalid-message: "&cUsage: /teleport <player> [x] [y] [z]"
commands:
- "tp {args}" # {args} = "Steve 100 64 200"

Usage:

/teleport Steve 100 64 200 → Valid (if Steve is online)
/teleport InvalidPlayer 100 64 200 → Error: "Player InvalidPlayer is not online or does not exist!"

Tab Completion: After typing /teleport , all online players are shown.

Example 3: Transfer with Two Player Arguments

Section titled “Example 3: Transfer with Two Player Arguments”
transfer:
permission: "customcommands.transfer"
message:
- "&6Transferring player..."
arguments:
whitelist: []
whitelist-only: false
no-arguments: false
player-args: [0, 1] # First AND second = player names
invalid-message: "&cUsage: /transfer <player1> <player2>"
commands:
- "transfer {args}" # {args} = "Steve Alex"

Usage:

/transfer Steve Alex → Valid (if both are online)
/transfer Steve InvalidPlayer → Error: "Player InvalidPlayer is not online or does not exist!"
/transfer InvalidPlayer Alex → Error: "Player InvalidPlayer is not online or does not exist!"

Tab Completion:

  • After /transfer → Shows all online players (for first player)
  • After /transfer Steve → Shows all online players (for second player)

Example 6: Nested Subcommand with Player Argument

Section titled “Example 6: Nested Subcommand with Player Argument”
admin:
permission: "customcommands.admin"
subcommands:
player:
permission: "customcommands.admin.player"
subcommands:
kick:
permission: "customcommands.admin.player.kick"
message:
- "&cKicking: {args}"
arguments:
whitelist: []
whitelist-only: false
no-arguments: false
player-args: [0] # First argument after "kick" = player name
invalid-message: "&cUsage: /admin player kick <player>"
commands:
- "kick {args} Kicked by admin"

Usage:

/admin player kick Steve → Valid (if Steve is online)
/admin player kick InvalidPlayer → Error: "Player InvalidPlayer is not online or does not exist!"

Tab Completion: After typing /admin player kick , all online players are shown.

The command execution type feature allows you to control whether commands are executed as the server console or as the player who used the command.

TypeDescriptionUse Case
ConsoleCommands executed as server consoleAdmin commands, effects, teleportation
PlayerCommands executed as the playerPlayer commands like /home, /warp

Commands executed as console have full permissions and bypass player restrictions.

example:
permission: "customcommands.example"
type: "Console" # Executed as console
commands:
- "effect give {player} minecraft:glowing 10 1 true" # Works without player permission
- "teleport {player} 0 64 0" # Works without player permission
- "kick {player} You were kicked!" # Works without player permission

Benefits:

  • ✅ Full permission access
  • ✅ Bypasses player restrictions
  • ✅ Works for admin commands
  • ✅ Can execute any server command

Commands executed as player respect player permissions and restrictions.

home:
permission: "customcommands.home"
type: "Player" # Executed as player
commands:
- "/home" # Player executes /home (needs permission)
- "/warp spawn" # Player executes /warp spawn (needs permission)
- "/spawn" # Player executes /spawn (needs permission)

Benefits:

  • ✅ Respects player permissions
  • ✅ Works with permission-based plugins
  • ✅ Player-specific command execution
  • ✅ Natural command behavior

Subcommands can override the parent command’s type:

admin:
permission: "customcommands.admin"
type: "Console" # Default: Console
subcommands:
kick:
permission: "customcommands.admin.kick"
type: "Console" # Explicitly Console (inherits from parent)
commands:
- "kick {args} Kicked by {player}"
home:
permission: "customcommands.admin.home"
type: "Player" # Override: Player type
commands:
- "/home" # Executed as player
  • If type is not specified, defaults to "Console"
  • If type is "Player" and sender is not a player (e.g., console), commands still execute as console
  • Subcommands inherit parent type unless explicitly overridden
example:
permission: "customcommands.example"
alias: ["ex", "demo"]
description: "Example command with console execution"
enabled: true
cooldown: 5
type: "Console" # Console execution
commands:
- "say {player} used the example command!"
- "tellraw @a [\"\",{\"text\":\"Player \",\"color\":\"yellow\"},{\"text\":\"{player}\",\"color\":\"green\"},{\"text\":\" is at \",\"color\":\"yellow\"},{\"text\":\"{x}, {y}, {z}\",\"color\":\"aqua\"},{\"text\":\" in \",\"color\":\"yellow\"},{\"text\":\"{world}\",\"color\":\"gold\"}]"
- "effect give {player} minecraft:glowing 10 1 true"
- "title {player} title [\"\",{\"text\":\"Example Command!\",\"color\":\"gold\"}]"
- "title {player} subtitle [\"\",{\"text\":\"You are at {x}, {y}, {z}\",\"color\":\"gray\"}]"
message:
- "&6&l=== Example Command ==="
- "&eThis command demonstrates console command execution!"
- "&7Check the console for executed commands!"
- "&7You should see a glowing effect and title!"

All variables work in both Console and Player execution types:

commands:
- "say {player} used the command!" # {player} = player name
- "tp {player} {x} {y} {z}" # Location variables
- "tellraw {player} [\"\",{\"text\":\"Hello {player}!\",\"color\":\"green\"}]" # JSON with variables
- "kick {args} Kicked by {player}" # {args} for all arguments
- "say Price: {arg:1}, Amount: {arg:2}" # Individual arguments

Argument Variables:

  • {args} - All arguments as a single string (backward compatible)
  • {arg:1} - First argument (1-based index)
  • {arg:2} - Second argument (empty string if not provided)
  • {arg:N} - Nth argument (empty string if not provided)

Here’s a complete example combining all advanced features:

commands:
admin:
permission: "customcommands.admin"
alias: ["a", "adm"]
description: "Admin command with all advanced features"
enabled: true
cooldown: 0
type: "Console" # Console execution
message:
- "&c&l=== Admin Panel ==="
- "&7Use &e/admin help &7to see available commands"
subcommands: # Nested subcommands
player: # /admin player
permission: "customcommands.admin.player"
type: "Console" # Inherits from parent
message:
- "&6&lPlayer Management"
subcommands: # Nested subcommands!
kick: # /admin player kick <player>
permission: "customcommands.admin.player.kick"
type: "Console"
message:
- "&cKicking player: {args}"
arguments: # Arguments configuration
whitelist: []
whitelist-only: false
no-arguments: false
player-args: [0] # First argument = player name
invalid-message: "&cUsage: /admin player kick <player>"
commands: # Console commands
- "kick {args} Kicked by {player}"
ban: # /admin player ban <player>
permission: "customcommands.admin.player.ban"
type: "Console"
message:
- "&cBanning player: {args}"
arguments:
whitelist: []
whitelist-only: false
no-arguments: false
player-args: [0] # First argument = player name
invalid-message: "&cUsage: /admin player ban <player>"
commands:
- "ban {args} Banned by {player}"
teleport: # /admin player teleport <player> [target]
permission: "customcommands.admin.player.teleport"
type: "Console"
message:
- "&6Teleporting player..."
arguments:
whitelist: []
whitelist-only: false
no-arguments: false
invalid-message: "&cUsage: /admin player teleport <player> [target]"
commands:
- "tp {args}"
server: # /admin server
permission: "customcommands.admin.server"
type: "Console"
message:
- "&6&lServer Management"
subcommands: # More nested subcommands!
restart: # /admin server restart
permission: "customcommands.admin.server.restart"
type: "Console"
message:
- "&c&lRestarting server in 10 seconds..."
commands:
- "say Server restarting in 10 seconds!"
- "schedule function minecraft:load 10s"
reload: # /admin server reload
permission: "customcommands.admin.server.reload"
type: "Console"
message:
- "&eReloading server..."
commands:
- "reload"
broadcast: # /admin server broadcast <message>
permission: "customcommands.admin.server.broadcast"
type: "Console"
message:
- "&6Broadcasting message..."
arguments: # Arguments with message
whitelist: []
whitelist-only: false
no-arguments: false
invalid-message: "&cUsage: /admin server broadcast <message>"
commands:
- "say [Broadcast] {args}"
help: # /admin help
permission: "customcommands.admin.help"
message:
- "&6&l=== Admin Help ==="
- "&eAvailable commands:"
- "&7/admin player kick &lt;player&gt; - Kick a player"
- "&7/admin player ban &lt;player&gt; - Ban a player"
- "&7/admin player teleport &lt;player&gt; [target] - Teleport player"
- "&7/admin server restart - Restart the server"
- "&7/admin server reload - Reload the server"
- "&7/admin server broadcast &lt;message&gt; - Broadcast a message"
- "&7/admin help - Show this help"

Now that you understand the advanced features, check out:

For support and updates, join our Discord server.