Tutorials - DrexHD/MeliusCommands GitHub Wiki
This page will cover some of the basic concepts on how this mod could be used to improve your server. You should make yourself familiar with the online generator for commands and modifiers, because it can drastically help you understand the file format and available options! All examples include a link to example loaded in the online generator for you to toy around.
It is often desired to create a short version of a command, because you can type it faster. There are two different concepts to create shorter commands: simple and redirect
s. Both approaches create new commands, so these files should be placed in your config/melius-commands/commands
folder!
This is the simple approach. It works by creating your (short) custom command and making it run the command you want to execute. An example for this would be a /rain
, which executes /weather rain
.
{
"id": "rain",
"require": {
"type": "permission",
"permission": "shortcut.rain",
"operator": 2
},
"executes": [
"weather rain"
]
}
Click to check out the example online!
A simple explanation of all fields:
-
id
is part of the command creation and will be the command you need to type out. -
require
allows you to define, who should be able to see and execute your command (use the online editor to check out all available options) -
executes
is a list of commands that will get executed when your command is run. Commands are run silently and as console by default. This can be changed (use the online editor to see all options).
Redirects are a bit more complicated and should be used if you want to create shortcuts for complicated (commands with arguments) commands. We will use the /gamemode
command as an example and create a shortcut /gm
for it. This will allow us to run commands like /gm survival @a
{
"id": "gm",
"require": {
"type": "permission",
"permission": "shortcut.gm",
"operator": 2
},
"redirect": "gamemode"
}
Click to check out the example online!
The id
and require
field work as above. The interesting part is the redirect
field. This field expects a command node path of the command you want to redirect to. To figure out the path of a command you can use /melius-commands path <command>
in-game, in our case /melius-commands path gamemode
.
Contrary to command shortcuts, requirements and cooldowns are using command modifiers to modify existing commands. Any files for this should be placed in config/melius-commands/modifiers
!
There are two different kind of requirements you can add to commands: execution
and node
.
This will still show the command in suggestion, but prevent anyone, who doesn't meet the requirement, from executing the command. Optionally a list of commands can be specified that should be run on failure to inform the player, why the command currently isn't available. In this example we will require players to be in the overworld to run a /home <something>
command from another mod.
{
"type": "node:starts_with",
"paths": "home",
"execution_modifiers": [
{
"type": "predicate:add",
"predicate": {
"type": "entity",
"value": {
"location": {
"dimension": "minecraft:overworld"
}
}
},
"failure": "tellraw @s [{\"text\":\"You need to be in the overworld to use this commands!\",\"color\":\"red\"}]"
}
]
}
Click to check out the example online!
[TODO]
[TODO]