2020-04-15 14:22:03 +02:00
|
|
|
package com.minelittlepony.unicopia.command;
|
2020-01-27 11:05:22 +01:00
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
2020-04-15 14:22:03 +02:00
|
|
|
import com.minelittlepony.unicopia.Race;
|
2020-01-27 11:05:22 +01:00
|
|
|
import com.mojang.brigadier.StringReader;
|
|
|
|
import com.mojang.brigadier.arguments.ArgumentType;
|
|
|
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
|
|
|
|
|
|
class RaceArgument implements ArgumentType<Race> {
|
|
|
|
static final Collection<String> EXAMPLES = Arrays.stream(Race.values())
|
|
|
|
.filter(Race::isUsable)
|
|
|
|
.map(Race::name)
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Race parse(StringReader reader) throws CommandSyntaxException {
|
|
|
|
return Race.fromName(reader.readUnquotedString(), Race.EARTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Collection<String> getExamples() {
|
|
|
|
return EXAMPLES;
|
|
|
|
}
|
|
|
|
}
|