crwdns130783:0crwdne130783:0
crwdns130785:0crwdne130785:0
crwdns130787:0:javadoc:crwdnd130787:0:javadoc:crwdne130787: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();
crwdns130789:0:javadoc:crwdnd130789:0:javadoc:crwdne130789:0
crwdns130791:0:javadoc:crwdne130791:0
import org.spongepowered.api.text.Text;
if (args.hasAny("s")) {
src.sendMessage(Text.of("The command flag s was specified!"));
}
crwdns130793:0crwdne130793:0
crwdns130795:0:javadoc:crwdne130795:0
CommandSpec myCommand = CommandSpec.builder()
.executor(new MyCommand())
.arguments(GenericArguments.flags().permissionFlag("myplugin.command.flag",
"s").buildWith(GenericArguments.none()))
.build();
crwdns130797:0crwdne130797:0
crwdns130799:0crwdne130799:0
crwdns130801:0:javadoc:crwdne130801:0
CommandSpec myCommand = CommandSpec.builder()
.executor(new MyCommand())
.arguments(GenericArguments.flags().valueFlag(GenericArguments
.integer(Text.of("value")), "s").buildWith(GenericArguments.none()))
.build();
crwdns130803:0:javadoc:crwdnd130803:0:javadoc:crwdne130803:0
crwdns130805:0crwdne130805: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."));
}
crwdns130807:0crwdne130807:0
crwdns130809:0crwdne130809:0
CommandSpec myCommand = CommandSpec.builder()
.executor(new MyCommand())
.arguments(GenericArguments.flags().flag("-myflag")
.buildWith(GenericArguments.none()))
.build();
crwdns130811:0crwdne130811:0
Optional<String> optional = args.<String>getOne("myflag");
if (optional.isPresent()) {
String value = optional.get();
}
crwdns130813:0crwdne130813:0
crwdns130815:0crwdne130815:0
crwdns130817:0crwdne130817: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();
crwdns130819:0crwdne130819:0