Module: command_bundle
Overview
This module allows creating
a new command (Called template command
or bundle command
):
-
User-Defined Arguments
: the new command can accept user-defined arguments. -
Command Body
: the body of a new command can consist of a list of existing commands. -
Placeholders
: the body can support placeholder parsing.
It can be used as a generic command template
system.
Color Boxes
◉ The features of this module:
-
Provide a user-friendly DSL, to create
a new custom command
easily. -
Support the inter-operation with
user-defined variable
,placeholders
andvanilla target selectors
. -
Support complex
argument types
:required argument
,literal argument
and evenoptional argument with a specified default value
. -
A powerful
type-system
, to use the built-inargument types
. -
Register and un-register
custom commands
on the fly, without a server re-start.
◉ The purpose
of this module
This module allows you to define
a new command
.
To define
a new command, you need to specify the following things:
-
The
pattern
of this new command: If the pattern isclaim-kit example
, then the new command is/claim-kit example
. -
The
bundle
of this new command: It is thebody
of this new command. It isa list of commands
to be executed.
To define a new bundle command
, you need to specify the pattern
and the bundle
for it.
The pattern
describes: what does your new command
look like?
The bundle
describes: what commands
should we execute when your new command
is executed?
◉ The syntax of the pattern
.
The pattern
is composed by a list of command node
.
For example, the pattern
instance first second third
describes a command /first second third
.
It is composed by 3 command node
, they are all literal arguments
.
In the syntax of pattern
, there are 3 types of arguments
:
-
Literal Argument
: You can write it down directly. For examplefirst
,second
,third
, andclaim-kit
are all literal arguments. -
Required Argument
: It's syntax is<arg-type arg-name>
. For example,<int age>
means arequired argument
whoseargument type is int
andargument name is age
. -
Optional Argument
: It's syntax is[arg-type arg-name default-value]
. It is similar torequired argument
, but you can provide adefault value
if this argument is not specified by thecommand source
.
You can reference
the value of Required Argument
or Optional Argument
in the bundle
component.
For example, you can write down $age
to refer to a variable
named age
defined in the pattern
component.
◉ What is the type system
used by the syntax of pattern
?
Fuji will register an argument type adapter
for a specific argument type
.
You can issue /fuji inspect argument-types
to list all registered adapters
.
You can use any argument type
listed in that GUI.
◉ The syntax of the bundle
.
Actually, the bundle
is just a list of commands
.
You can write Minecraft commands
directly in the bundle
list.
When a bundle command
is executed, we will execute the list of commands
defined by bundle
from up to down.
Commands are executed as console
.
You can use /run as player
or /run as fake-op
to switch the command execution context, if it is needed.
◉ Generate powerful commands using a generator.
You can use command generator to get powerful commands:
https://www.gamergeeks.net/apps/minecraft/particle-command-generator
◉ Use a bundle command
to combine many commands into one command.
In this example, we want to register a new command /composite-heal
.
To decorate
an existed command /heal
.
The decorations are:
-
We will
say
before the execution of/heal
command. -
We will spawn a
heart particle
before the execution of/heal
command. -
We will
say
after the execution of/heal
command.
To define this bundle command
as shown below.
Pattern: composite-heal
Bundle:
-
say before heal %player:name%
-
run as fake-op %player:name% particle minecraft:heart ~ ~2 ~
-
run as player %player:name% heal
-
say after heal %player:name%
◉ Use a bundle command
to transform the form of an existed command.
In this example, we want to register a new command /warn
.
As a shortcut command
to a specific command instance.
Pattern: warn <player player-arg> <greedy greedy-arg>
Bundle:
run as player %player:name% send-message $player-arg <red>You are warned: $greedy-arg
◉ Use a bundle command
to wrap a specific command instance.
In this example, if you want to allow players to use /give @s minecraft:apple
.
You only want to allow the players to get free apples
.
And you didn't want to allow players to use /give
command arbitrarily.
Then, you can define a bundle command
like /free-apple
to wrap
a specific instance of /give
command.
Pattern: free-apple
Bundle:
run as fake-op %player:name% give @s minecraft:apple
◉ Define a bundle command
to wrap a specific /kit give
command instance.
Pattern: kitfood
Bundle:
run as fake-op %player:name% kit give @s kit-food
◉ See more advanced examples.
The default config file contains a set of advanced examples
.
You can see there are many pre-defined bundle commands
.
Their name starts with /my-command
.
Besides, there are also a set of pre-defined bundle commands
for convenience.
For example: /gmc
, /gms
, /day
, /sun
...
◉ Transform the form of a command.
-
/blocknbt
->/data get block
-
/entitynbt
->/data get entity
-
/gm
,/gms
and/gmc
->/gamemode
-
/findbiome
->/locate biome
-
/flyspeed
->/attribute Alice minecraft:generic.flying_speed
-
/walkspeed
->/attribute Alice minecraft:movement_speed
-
/maxhealth
->/attribute Alice minecraft:generic.max_health
-
/groundclean
->/kill @e[type=...]
-
/spawnmob
->/summon
-
/shoot
->/summon
with motion -
/smite
and/thunder
->/summon minecraft:lighting_bolt
◉ Define a /tpw
command to teleport players to a specified dimension.
Pattern: tpw resource-world
Bundle:
run as fake-op %player:name% tppos --centerX 0 --centerZ 0 --maxRange 128 --dimension fuji:overworld
Configurations
The following JSON content is provided for reference only. It must NOT be copied directly into the configuration directory, as it does not represent valid JSON syntax.
- File Name:
config.json
- File Content:
Click to see the default
content...
{
/* Defined `bundle commands`. */
"bundle_commands": [
{
"document": "This command is used to test the `optional argument`.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "my-command a-command-with-optional-arg <int int-arg-name> [str str-arg-name this is the default value]",
"bundle": [
"say hello %player:name%",
"say int is $int-arg-name",
"say str is $str-arg-name"
]
},
{
"document": "This command is used to test the `literal argument` and `required argument`.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "my-command a-command-with-required-arg first-literal second-literal <str str-arg-name>",
"bundle": [
"say hello %player:name%",
"say str is $str-arg-name"
]
},
{
"document": "This command is used to test the `greedy string` argument type.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "my-command a-command-with-a-greedy-string <int int-arg-name> first-literal [greedy-string greedy-string-arg-name this is the default value]",
"bundle": [
"say hello %player:name%",
"say int is $int-arg-name",
"say str is $greedy-string-arg-name"
]
},
{
"document": "This command is used to test the `literal argument`, `required argument` and `optional argument`.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "my-command a-command-with-all-types-of-args <int int-arg-name> first-literal [str str-arg-name the default value can contains placeholder %player:name% in %world:name%]",
"bundle": [
"say hello %player:name%",
"say int is $int-arg-name",
"say str is $str-arg-name"
]
},
{
"document": "This command is an alias for `/gamemode`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "gm <gamemode gamemode-arg>",
"bundle": [
"run as player %player:name% gamemode $gamemode-arg"
]
},
{
"document": "This command is an alias for `/gamemode creative`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "gmc",
"bundle": [
"run as player %player:name% gamemode creative"
]
},
{
"document": "This command is an alias for `/gamemode survival`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "gms",
"bundle": [
"run as player %player:name% gamemode survival"
]
},
{
"document": "This command is an alias for `/gamemode spectator`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "gmsp",
"bundle": [
"run as player %player:name% gamemode spectator"
]
},
{
"document": "This command is an alias for `/weather clear`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "sun",
"bundle": [
"run as player %player:name% weather clear"
]
},
{
"document": "This command is an alias for `/weather rain`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "rain",
"bundle": [
"run as player %player:name% weather rain"
]
},
{
"document": "This command is an alias for `/weather thunder`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "thunder",
"bundle": [
"run as player %player:name% weather thunder"
]
},
{
"document": "This command is an alias for `/time set day`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "day",
"bundle": [
"run as player %player:name% time set day"
]
},
{
"document": "This command is an alias for `/time set night`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "night",
"bundle": [
"run as player %player:name% time set night"
]
},
{
"document": "This command is an alias for `/time set midnight`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "midnight",
"bundle": [
"run as player %player:name% time set midnight"
]
},
{
"document": "This command is an alias for `/time set noon`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "noon",
"bundle": [
"run as player %player:name% time set noon"
]
},
{
"document": "This command is an alias for `/data get entity`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "nbt entity <entity target>",
"bundle": [
"run as fake-op %player:name% data get entity $target"
]
},
{
"document": "This command is an alias for `/data get block`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "nbt block <block-pos target>",
"bundle": [
"run as fake-op %player:name% data get block $target"
]
},
{
"document": "This command is an alias for `/data get entity @s SelectedItem`",
"requirement": {
"level": 4,
"string": null
},
"pattern": "nbt item",
"bundle": [
"run as fake-op %player:name% data get entity %player:name% SelectedItem"
]
},
{
"document": "This command is an easter egg for `/plugins` in Bukkit.",
"requirement": {
"level": 0,
"string": null
},
"pattern": "plugins",
"bundle": [
"send-message %player:name% Server Plugins (0): "
]
},
{
"document": "This command is an easter egg for `/icanhasbukkit` in Bukkit.",
"requirement": {
"level": 0,
"string": null
},
"pattern": "icanhasbukkit",
"bundle": [
"send-message %player:name% <i>Checking version, please wait...",
"delay 2 send-message %player:name% This server is running Bukkit version (MC: %server:version%)",
"delay 3 send-message %player:name% <green>You are running the latest version"
]
},
{
"document": "This command summons an entity with specified entity type, with an initial motion.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "shoot <entity-type entity-type-arg-name>",
"bundle": [
"execute as %player:name% run summon $entity-type-arg-name ~ ~1 ~ {ExplosionPower:4,Motion:[3.0,0.0,0.0]}"
]
},
{
"document": "This command summons a lightning_bolt entity.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "strike",
"bundle": [
"execute as %player:name% at @s run summon lightning_bolt ^ ^ ^32"
]
},
{
"document": "This command applies the `unbreakable` enchantment for the item in hand.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "unbreakable",
"bundle": [
"run as player %player:name% enchant %player:name% minecraft:unbreaking"
]
},
{
"document": "This command modifies your movement_speed attribute.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "move-speed set <double double-arg>",
"bundle": [
"run as player %player:name% attribute %player:name% minecraft:generic.movement_speed base set $double-arg"
]
},
{
"document": "This command modifies your movement_speed attribute.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "move-speed reset",
"bundle": [
"run as player %player:name% attribute %player:name% minecraft:generic.movement_speed base set 0.10000000149011612"
]
},
{
"document": "This command will introduce yourself to others.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "introduce-me",
"bundle": [
"run as fake-op %player:name% me i am %player:name%"
]
},
{
"document": "This command will roll a random dice.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "dice",
"bundle": [
"say %player:name% just roll out %fuji:random 1 6% points."
]
},
{
"document": "This command will give `all` recipes to the player.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "obtain-all-recipes",
"bundle": [
"run as fake-op %player:name% recipe give %player:name% *"
]
},
{
"document": "This command will give the skull of specified player.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "skull <offline-player offline-player-arg>",
"bundle": [
"give %player:name% minecraft:player_head[minecraft:profile=$offline-player-arg]"
]
},
{
"document": "This command will print the UUID of specified player.",
"requirement": {
"level": 4,
"string": null
},
"pattern": "uuid <player target>",
"bundle": [
"run as fake-op $target send-message %player:name% <yellow>The UUID of player $target is %fuji:escape player:uuid 2%"
]
}
]
}
Commands
-
Command Syntax:
/command-bundle list
-
Document: List all registered bundle-commands in server.
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/command-bundle register
-
Document: Register all commands defined in bundle-command configuration file.
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/command-bundle un-register
-
Document: Un-register all bundle-commands registered in server.
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/day
-
Document: This command is an alias for
/time set day
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/gm <GameMode gamemode-arg>
-
Document: This command is an alias for
/gamemode
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/gmc
-
Document: This command is an alias for
/gamemode creative
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/gms
-
Document: This command is an alias for
/gamemode survival
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/gmsp
-
Document: This command is an alias for
/gamemode spectator
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/icanhasbukkit
-
Document: This command is an easter egg for
/icanhasbukkit
in Bukkit. -
Can be executed by console:
true
-
Required Level Permission:
0
-
Required String Permission:
null
-
Command Syntax:
/introduce-me
-
Document: This command will introduce yourself to others.
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/midnight
-
Document: This command is an alias for
/time set midnight
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/move-speed reset
-
Document: This command modifies your movement_speed attribute.
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/move-speed set <double double-arg>
-
Document: This command modifies your movement_speed attribute.
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/my-command a-command-with-a-greedy-string <int int-arg-name> first-literal [GreedyString greedy-string-arg-name]
-
Document: This command is used to test the
greedy string
argument type. -
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/my-command a-command-with-all-types-of-args <int int-arg-name> first-literal [String str-arg-name]
-
Document: This command is used to test the
literal argument
,required argument
andoptional argument
. -
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/my-command a-command-with-optional-arg <int int-arg-name> [String str-arg-name]
-
Document: This command is used to test the
optional argument
. -
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/my-command a-command-with-required-arg first-literal second-literal <String str-arg-name>
-
Document: This command is used to test the
literal argument
andrequired argument
. -
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/nbt block <BlockPos target>
-
Document: This command is an alias for
/data get block
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/nbt entity <Entity target>
-
Document: This command is an alias for
/data get entity
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/nbt item
-
Document: This command is an alias for
/data get entity @s SelectedItem
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/night
-
Document: This command is an alias for
/time set night
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/noon
-
Document: This command is an alias for
/time set noon
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/obtain-all-recipes
-
Document: This command will give
all
recipes to the player. -
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/plugins
-
Document: This command is an easter egg for
/plugins
in Bukkit. -
Can be executed by console:
true
-
Required Level Permission:
0
-
Required String Permission:
null
-
Command Syntax:
/rain
-
Document: This command is an alias for
/weather rain
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/shoot <NotSupportedType entity-type-arg-name>
-
Document: This command summons an entity with specified entity type, with an initial motion.
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/skull <OfflinePlayerName offline-player-arg>
-
Document: This command will give the skull of specified player.
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/strike
-
Document: This command summons a lightning_bolt entity.
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/sun
-
Document: This command is an alias for
/weather clear
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/thunder
-
Document: This command is an alias for
/weather thunder
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/unbreakable
-
Document: This command applies the
unbreakable
enchantment for the item in hand. -
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null
-
Command Syntax:
/uuid <ServerPlayerEntity target>
-
Document: This command will display the UUID of specified player.
-
Can be executed by console:
true
-
Required Level Permission:
4
-
Required String Permission:
null