use of org.spongepowered.api.command.args.CommandArgs in project Nucleus by NucleusPowered.
the class NicknameArgumentTests method testWhenTwoPlayersWithTheSameNameAreInTheUserDatabaseWithNoExactMatchReturnsOneReturnsIfOnlyOneMatches.
@Test
public void testWhenTwoPlayersWithTheSameNameAreInTheUserDatabaseWithNoExactMatchReturnsOneReturnsIfOnlyOneMatches() throws ArgumentParseException {
List<?> list = getParser().accept("testt", mockSource(), new CommandArgs("", new ArrayList<>()));
Assert.assertEquals(1, list.size());
Assert.assertEquals("testtest", ((User) list.get(0)).getName());
}
use of org.spongepowered.api.command.args.CommandArgs in project Nucleus by NucleusPowered.
the class PlayerConsoleArgumentTest method testWhenTwoPlayersWithTheSameNameAreInTheUserDatabaseWithNoExactMatchReturnsOneReturnsIfOnlyOneMatches.
@Test
public void testWhenTwoPlayersWithTheSameNameAreInTheUserDatabaseWithNoExactMatchReturnsOneReturnsIfOnlyOneMatches() throws ArgumentParseException {
List<?> list = getParser().parseInternal("testt", mockSource(), new CommandArgs("", new ArrayList<>()));
Assert.assertEquals(1, list.size());
Assert.assertEquals("testtest", ((User) list.get(0)).getName());
}
use of org.spongepowered.api.command.args.CommandArgs in project Nucleus by NucleusPowered.
the class PlayerConsoleArgumentTest method testWhenTwoPlayersWithTheSameNameAreInTheUserDatabaseOnlyAnExactMatchIsReturned.
@Test
public void testWhenTwoPlayersWithTheSameNameAreInTheUserDatabaseOnlyAnExactMatchIsReturned() throws ArgumentParseException {
List<?> list = getParser().parseInternal("test", mockSource(), new CommandArgs("", new ArrayList<>()));
Assert.assertEquals(1, list.size());
Assert.assertEquals("test", ((User) list.get(0)).getName());
}
use of org.spongepowered.api.command.args.CommandArgs in project SpongeAPI by SpongePowered.
the class CommandSpec method process.
@Override
public CommandResult process(CommandSource source, String arguments) throws CommandException {
checkPermission(source);
final CommandArgs args = new CommandArgs(arguments, getInputTokenizer().tokenize(arguments, false));
final CommandContext context = new CommandContext();
this.populateContext(source, args, context);
return getExecutor().execute(source, context);
}
use of org.spongepowered.api.command.args.CommandArgs in project AdamantineShield by Karanum.
the class TimeStringArgument method parseValue.
@Override
protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
CommandArgs oldState = args;
String input = args.next();
try {
return TimeUtils.timeStringToLong(input);
} catch (NumberFormatException e) {
throw oldState.createError(Text.of(TextColors.RED, "Invalid time format: " + input));
}
}
Aggregations