Skip to content

Recode an existant command

André edited this page Apr 8, 2019 · 1 revision

In this tutorial we'll see how to remake an existant command, like /kick, which requires arguments.

Config.yml part

Open config.yml file, and add a new YAML list in 'commands' node, like this:

commands:
  kick:
  - ''

Let's add a permission for this command: (optional!)

commands:
  kick:
  - '%permission%mycoolcommand.kick'

Let's add a command usage message (if the command isn't used well, with all arguments, this message will be sent) (optional!)

commands:
  kick:
  - '%permission%mycoolcommand.kick'
  - '%usage%[MyKick] &2Usage: /kick <player> <reason>'

Now we can add the older kick command. If it's the native /kick command from minecraft, we'll simply use it like minecraft:kick. If it's a plugin /kick command, we'll write it like this: pluginName:kick. So we have:

commands:
  kick:
  - '%permission%mycoolcommand.kick'
  - '%usage%[MyKick] &2Usage: /kick <player> <reason>'
  - 'minecraft:kick %arg1% %argAll1%'

We can now, for example, add a broadcast after the kick message:

commands:
  kick:
  - '%permission%mycoolcommand.kick'
  - '%usage%[MyKick] &2Usage: /kick <player> <reason>'
  - 'minecraft:kick %arg1% %argAll1%'
  - '%broadcast%&2%player% just kicked %arg1% for %argAll1%.'

%player% is the command sender name, %arg1% will get argument , and %argAll1% will get all arguments after

Commands.yml part

aliases:
  kick:
  - commandexecutor kick $1-

Your new /kick command is now saved! When you enter /kick, it will execute /commandexecutor kick, and will execute all listed commands in the config.yml.

Clone this wiki locally