use of org.bukkit.entity.Llama.Color in project Citizens2 by CitizensDev.
the class Commands method llama.
@Command(aliases = { "npc" }, usage = "llama (--color color) (--strength strength)", desc = "Sets llama modifiers", modifiers = { "llama" }, min = 1, max = 1, permission = "citizens.npc.llama")
@Requirements(selected = true, ownership = true, types = EntityType.LLAMA)
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
LlamaTrait trait = npc.getTrait(LlamaTrait.class);
String output = "";
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
String colorRaw = args.getFlag("color", args.getFlag("colour"));
Color color = Util.matchEnum(Color.values(), colorRaw);
if (color == null) {
String valid = Util.listValuesPretty(Color.values());
throw new CommandException(Messages.INVALID_LLAMA_COLOR, valid);
}
trait.setColor(color);
output += Messaging.tr(Messages.LLAMA_COLOR_SET, Util.prettyEnum(color));
}
if (args.hasValueFlag("strength")) {
trait.setStrength(Math.max(1, Math.min(5, args.getFlagInteger("strength"))));
output += Messaging.tr(Messages.LLAMA_STRENGTH_SET, args.getFlagInteger("strength"));
}
if (!output.isEmpty()) {
Messaging.send(sender, output);
}
}
use of org.bukkit.entity.Llama.Color in project Citizens2 by CitizensDev.
the class Commands method llama.
@Command(aliases = { "npc" }, usage = "llama (--color color) (--strength strength)", desc = "Sets llama modifiers", modifiers = { "llama" }, min = 1, max = 1, permission = "citizens.npc.llama")
@Requirements(selected = true, ownership = true, types = EntityType.LLAMA)
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
LlamaTrait trait = npc.getTrait(LlamaTrait.class);
String output = "";
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
String colorRaw = args.getFlag("color", args.getFlag("colour"));
Color color = Util.matchEnum(Color.values(), colorRaw);
if (color == null) {
String valid = Util.listValuesPretty(Color.values());
throw new CommandException(Messages.INVALID_LLAMA_COLOR, valid);
}
trait.setColor(color);
output += Messaging.tr(Messages.LLAMA_COLOR_SET, Util.prettyEnum(color));
}
if (args.hasValueFlag("strength")) {
trait.setStrength(Math.max(1, Math.min(5, args.getFlagInteger("strength"))));
output += Messaging.tr(Messages.LLAMA_STRENGTH_SET, args.getFlagInteger("strength"));
}
if (!output.isEmpty()) {
Messaging.send(sender, output);
}
}
Aggregations