/CommandInterpreter

Plugin tool for defining and interpreting simple console commands

Primary LanguageJava

CommandInterpreter

Easy to use plugin tool for defining and interpreting simple console commands

Usage

Define a command:
SheepCMD cmd = new SheepCMD("/watchlist add <Player> [String:reason=Toxicity] [Time:time=time1d]");

/watchlist Name of command
add Sub-command
<Player> Required Player argument
[String:reason=Toxicity] Optional String argument named reason and default value "Toxicity"
[Time:time=time1d] Optional Time argument named time and default value 1d (1 day)

Define command's function:

cmd.setFunction(args -> {
    System.out.println(args[0] + " , " + args[1] + " , " + args[2]);
});

Add command to executor:

SheepCMDTree commands = new SheepCMDTree();
commands.addCommand(cmd);

Execute a command:

SheepCMDTree commands = new SheepCMDTree();
commands.addCommand(cmd);

commands.execute("/watchlist add Bob reason:\"grief\" time:3d");