crwdns120135:0crwdne120135:0

crwdns120137:0crwdne120137:0

crwdns120139:0:javadoc:crwdnd120139:0:javadoc:crwdne120139: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();

crwdns120141:0:javadoc:crwdnd120141:0:javadoc:crwdne120141:0

crwdns120143:0:javadoc:crwdne120143:0

import org.spongepowered.api.text.Text;

if (args.hasAny("s")) {
    src.sendMessage(Text.of("The command flag s was specified!"));
}

crwdns120145:0crwdne120145:0

crwdns120147:0:javadoc:crwdne120147:0

CommandSpec myCommand = CommandSpec.builder()
        .executor(new MyCommand())
        .arguments(GenericArguments.flags().permissionFlag("myplugin.command.flag",
            "s").buildWith(GenericArguments.none()))
        .build();

crwdns120149:0crwdne120149:0

crwdns120151:0crwdne120151:0

crwdns120153:0:javadoc:crwdne120153:0

CommandSpec myCommand = CommandSpec.builder()
        .executor(new MyCommand())
        .arguments(GenericArguments.flags().valueFlag(GenericArguments
                .integer(Text.of("value")), "s").buildWith(GenericArguments.none()))
        .build();

crwdns120155:0:javadoc:crwdnd120155:0:javadoc:crwdne120155:0

crwdns120157:0crwdne120157: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."));
}

crwdns120159:0crwdne120159:0

crwdns120161:0crwdne120161:0

CommandSpec myCommand = CommandSpec.builder()
        .executor(new MyCommand())
        .arguments(GenericArguments.flags().flag("-myflag")
            .buildWith(GenericArguments.none()))
        .build();

crwdns120163:0crwdne120163:0

Optional<String> optional = args.<String>getOne("myflag");
if (optional.isPresent()) {
    String value = optional.get();
}

crwdns120165:0crwdne120165:0

crwdns120167:0crwdne120167:0

crwdns120169:0crwdne120169: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();

crwdns120171:0crwdne120171:0