Search in sources :

Example 1 with OcelotModifiers

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

the class NPCCommands method ocelot.

@Command(aliases = { "npc" }, usage = "ocelot (--type type) (-s(itting), -n(ot sitting))", desc = "Set the ocelot type of an NPC and whether it is sitting", modifiers = { "ocelot" }, min = 1, max = 1, requiresFlags = true, flags = "sn", permission = "citizens.npc.ocelot")
@Requirements(selected = true, ownership = true, types = { EntityType.OCELOT })
public void ocelot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
    OcelotModifiers trait = npc.getTrait(OcelotModifiers.class);
    if (args.hasFlag('s')) {
        trait.setSitting(true);
    } else if (args.hasFlag('n')) {
        trait.setSitting(false);
    }
    if (args.hasValueFlag("type")) {
        Ocelot.Type type = Util.matchEnum(Ocelot.Type.values(), args.getFlag("type"));
        if (type == null) {
            String valid = Util.listValuesPretty(Ocelot.Type.values());
            throw new CommandException(Messages.INVALID_OCELOT_TYPE, valid);
        }
        trait.setType(type);
    }
}
Also used : Ocelot(org.bukkit.entity.Ocelot) ServerCommandException(net.citizensnpcs.api.command.exception.ServerCommandException) CommandException(net.citizensnpcs.api.command.exception.CommandException) OcelotModifiers(net.citizensnpcs.trait.OcelotModifiers) 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 OcelotModifiers (net.citizensnpcs.trait.OcelotModifiers)1 Ocelot (org.bukkit.entity.Ocelot)1