Search in sources :

Example 1 with Variant

use of org.bukkit.entity.Parrot.Variant in project Citizens2 by CitizensDev.

the class Commands method parrot.

@Command(aliases = { "npc" }, usage = "parrot (--variant variant)", desc = "Sets parrot modifiers", modifiers = { "parrot" }, min = 1, max = 1, permission = "citizens.npc.parrot")
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
    ParrotTrait trait = npc.getTrait(ParrotTrait.class);
    String output = "";
    if (args.hasValueFlag("variant")) {
        String variantRaw = args.getFlag("variant");
        Variant variant = Util.matchEnum(Variant.values(), variantRaw);
        if (variant == null) {
            String valid = Util.listValuesPretty(Variant.values());
            throw new CommandException(Messages.INVALID_PARROT_VARIANT, valid);
        }
        trait.setVariant(variant);
        output += Messaging.tr(Messages.PARROT_VARIANT_SET, Util.prettyEnum(variant));
    }
    if (!output.isEmpty()) {
        Messaging.send(sender, output);
    }
}
Also used : Variant(org.bukkit.entity.Parrot.Variant) CommandException(net.citizensnpcs.api.command.exception.CommandException) Command(net.citizensnpcs.api.command.Command) Requirements(net.citizensnpcs.api.command.Requirements)

Aggregations

Command (net.citizensnpcs.api.command.Command)1 Requirements (net.citizensnpcs.api.command.Requirements)1 CommandException (net.citizensnpcs.api.command.exception.CommandException)1 Variant (org.bukkit.entity.Parrot.Variant)1