1.4.5
- Added CommandArguments#sendMessage(String, Object[]) method to send message as formatted.
- Added
@Param
and@Default
annotations to create custom parameters with the same type. - Removed
CommandFramework#getColorFormatter
method.
Detailed informations about how to create custom parameters.
Example usage of @Param
and @Default
public class ExampleClass extends JavaPlugin {
@Override
public void onEnable() {
CommandFramework commandFramework = new CommandFramework(this);
commandFramework.registerCommands(this);
commandFramework.addCustomParameter("arg", arguments -> arguments.getArgument(0));
commandFramework.addCustomParameter("secondAsInt", arguments -> arguments.getLength() > 1 ? arguments.getArgumentAsInt(1) : null);
}
// /example - Output will be "Value: default value of the argument"
// /example test - Output will be "Value: test"
@Command(name = "example")
public void exampleCommand(CommandArguments arguments, @Default("default value of the argument") @Param("arg") String value) {
arguments.sendMessage("Value: " + value);
}
// /example firstArg 123 - Output will be "Second argument as int is 123"
// /example firstArg - Output will be "Second argument as int is 100" (100 is the value from default annotation)
@Command(name = "intExample")
public void exampleCommand(CommandArguments arguments, @Default("100") @Param("secondAsInt") int secondArg) {
arguments.sendMessage("Second argument as int is " + secondArg);
}
}
Full Changelog: 1.4.4...1.4.5