Search in sources :

Example 1 with RabbitType

use of net.citizensnpcs.trait.RabbitType in project Citizens2 by CitizensDev.

the class NPCCommands method rabbitType.

@Command(aliases = { "npc" }, usage = "rabbittype [type]", desc = "Set the Type of a Rabbit NPC", modifiers = { "rabbittype", "rbtype" }, min = 2, permission = "citizens.npc.rabbittype")
@Requirements(selected = true, ownership = true, types = { EntityType.RABBIT })
public void rabbitType(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
    Rabbit.Type type;
    try {
        type = Rabbit.Type.valueOf(args.getString(1).toUpperCase());
    } catch (IllegalArgumentException ex) {
        throw new CommandException(Messages.INVALID_RABBIT_TYPE, StringUtils.join(Rabbit.Type.values(), ","));
    }
    npc.getTrait(RabbitType.class).setType(type);
    Messaging.sendTr(sender, Messages.RABBIT_TYPE_SET, npc.getName(), type.name());
}
Also used : RabbitType(net.citizensnpcs.trait.RabbitType) Rabbit(org.bukkit.entity.Rabbit) ServerCommandException(net.citizensnpcs.api.command.exception.ServerCommandException) 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 ServerCommandException (net.citizensnpcs.api.command.exception.ServerCommandException)1 RabbitType (net.citizensnpcs.trait.RabbitType)1 Rabbit (org.bukkit.entity.Rabbit)1