use of net.citizensnpcs.trait.SheepTrait in project Citizens2 by CitizensDev.
the class NPCCommands method sheep.
@Command(aliases = { "npc" }, usage = "sheep (--color [color]) (--sheared [sheared])", desc = "Sets sheep modifiers", modifiers = { "sheep" }, min = 1, max = 1, permission = "citizens.npc.sheep")
@Requirements(selected = true, ownership = true, types = { EntityType.SHEEP })
public void sheep(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
SheepTrait trait = npc.getTrait(SheepTrait.class);
boolean hasArg = false;
if (args.hasValueFlag("sheared")) {
trait.setSheared(Boolean.valueOf(args.getFlag("sheared")));
hasArg = true;
}
if (args.hasValueFlag("color")) {
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
if (color != null) {
trait.setColor(color);
Messaging.sendTr(sender, Messages.SHEEP_COLOR_SET, color.toString().toLowerCase());
} else {
Messaging.sendErrorTr(sender, Messages.INVALID_SHEEP_COLOR, Util.listValuesPretty(DyeColor.values()));
}
hasArg = true;
}
if (!hasArg) {
throw new CommandException();
}
}
Aggregations