Skip to content

Command File

Redempt edited this page May 28, 2020 · 11 revisions

The command file is a custom format parsed by CommandParser. The idea behind this is that much of what you end up writing code for to make your commands work is extremely repetitive and serves little purpose. So instead of having you write code to specify the behavior of the command, almost all of this is removed from your code and put into the command file as metadata.

The format of the command file is simple: A command is like a code body, but with metadata instead of code.

commandname {
	//Command info here
}

This is the basic structure of it. If you want to create child commands, you can do so like this:

basecommand {
	//Base command info here
	childcommand {
		//Child command info here
	}
}

The resulting commands created from this structure would be /basecommand and /basecommand childcommand.

Inside the command body, you put command tags. Tags specify information about the command, and it's the stuff you'd expect: Help messages, permissions, and who can use it (console/player).

commandname {
	permission command.permission.name
	help This is a help message
	user player
}

This command will now only be runnable by players who have the permission command.permission.name. Its help message is This is a help message, and it can only be used by players.

But this command doesn't actually do anything yet. Command Manager works by hooking into annotated methods in your code. You'll read more about that in the wiki page for Command Hooks, but for now, just know that in order for your command to execute any code, it needs the hook tag to be specified.

commandname {
	permission command.permission.name
	help This is a help message
	user player
	hook hookname
}

Now this command will hook into an annotated method with the hook hookname.

That's all for the extremely basic functionality of command manager. Continue reading about Command Hooks from here.

Clone this wiki locally