Skip to content

Instantly share code, notes, and snippets.

@aumgn
Last active December 22, 2015 02:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aumgn/6402242 to your computer and use it in GitHub Desktop.
Save aumgn/6402242 to your computer and use it in GitHub Desktop.
Commands addition
public class DemoCommandSet implements CommandSet {
@Command(name="noargs")
public CommandOutcome noargs(CommandSender sender) {
// This command has no argument
return CommandOutcome.SUCCESS;
}
@Command(name="consoleonly")
public CommandOutcome consoleOnly(ConsoleCommandSender sender) {
// This command can only be used with the console
return CommandOutcome.SUCCESS;
}
@Command(name="playeronly")
public CommandOutcome playerOnly(Player sender) {
// This command can only be used by a player
return CommandOutcome.SUCCESS;
}
@Command(name="one", usage="<player>")
public CommandOutcome onearg(CommandSender sender, String playerName) {
// This command has one (no more, no less) argument "playerName"
return CommandOutcome.SUCCESS;
}
@Command(name="nomax", usage="<world> [players...]")
public CommandOutcome nomax(CommandSender sender, String worldName, String... playersName) {
// This command has one mandatory argument "worldName" but no maximum
return CommandOutcome.SUCCESS;
}
@Command(name="zeroToThree", usage="[world] [player1] [player2]", maxArgs = 3)
public CommandOutcome zeroToThree(CommandSender sender, String... args) {
// This command can be called with 0, 1, 2 or 3 arguments
return CommandOutcome.SUCCESS;
}
@Command(name="oneToThree", usage="<world> [player1] [player2]", maxArgs = 3)
public CommandOutcome oneToThree(CommandSender sender, String worldName, String... args) {
// This command can be called with 1, 2 or 3 arguments
return CommandOutcome.SUCCESS;
}
@Command(name={"nested", "command"}, aliases={"cmd", "c"})
public CommandOutcome nestedCommand() {
// This command can be called using :
// `/nested command`
// Aliases only applies to last part of the name :
// `/nested cmd`
// `/nested c`
return CommandOutcome.SUCCESS;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment