crwdns150047:0crwdne150047:0
crwdns150049:0crwdne150049:0
crwdns150051:0:javadoc:crwdnd150051:0:javadoc:crwdne150051:0
import org.spongepowered.api.command.args.GenericArguments;
import org.spongepowered.api.command.spec.CommandSpec;
CommandSpec myCommand = CommandSpec.builder()
.executor(new MyCommand())
.arguments(GenericArguments.flags().flag("s").buildWith(GenericArguments.none()))
.build();
crwdns150053:0:javadoc:crwdnd150053:0:javadoc:crwdne150053:0
crwdns150055:0:javadoc:crwdne150055:0
import org.spongepowered.api.text.Text;
if (args.hasAny("s")) {
src.sendMessage(Text.of("The command flag s was specified!"));
}
crwdns150057:0crwdne150057:0
crwdns150059:0:javadoc:crwdne150059:0
CommandSpec myCommand = CommandSpec.builder()
.executor(new MyCommand())
.arguments(GenericArguments.flags().permissionFlag("myplugin.command.flag",
"s").buildWith(GenericArguments.none()))
.build();
crwdns150061:0crwdne150061:0
crwdns150063:0crwdne150063:0
crwdns150065:0:javadoc:crwdne150065:0
CommandSpec myCommand = CommandSpec.builder()
.executor(new MyCommand())
.arguments(GenericArguments.flags().valueFlag(GenericArguments
.integer(Text.of("value")), "s").buildWith(GenericArguments.none()))
.build();
crwdns150067:0:javadoc:crwdnd150067:0:javadoc:crwdne150067:0
crwdns150069:0crwdne150069:0
import java.util.Optional;
Optional<Integer> optional = args.<Integer>getOne("value");
if (optional.isPresent()) {
int value = optional.get().intValue();
} else {
src.sendMessage(Text.of("The value flag was not specified."));
}
crwdns150071:0crwdne150071:0
crwdns150073:0crwdne150073:0
CommandSpec myCommand = CommandSpec.builder()
.executor(new MyCommand())
.arguments(GenericArguments.flags().flag("-myflag")
.buildWith(GenericArguments.none()))
.build();
crwdns150075:0crwdne150075:0
Optional<String> optional = args.<String>getOne("myflag");
if (optional.isPresent()) {
String value = optional.get();
}
crwdns150077:0crwdne150077:0
crwdns150079:0crwdne150079:0
crwdns150081:0crwdne150081:0
import org.spongepowered.api.command.args.CommandFlags;
CommandSpec myCommand = CommandSpec.builder()
.executor(new MyCommand())
.arguments(GenericArguments.flags()
.setUnknownShortFlagBehavior(
CommandFlags.UnknownFlagBehavior.ACCEPT_VALUE)
.buildWith(GenericArguments.none()))
.build();
crwdns150083:0crwdne150083:0