Search in sources :

Example 1 with Color

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);
    }
}
Also used : BarColor(org.bukkit.boss.BarColor) Color(org.bukkit.entity.Llama.Color) DyeColor(org.bukkit.DyeColor) CommandException(net.citizensnpcs.api.command.exception.CommandException) Command(net.citizensnpcs.api.command.Command) Requirements(net.citizensnpcs.api.command.Requirements)

Example 2 with Color

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);
    }
}
Also used : BarColor(org.bukkit.boss.BarColor) Color(org.bukkit.entity.Llama.Color) DyeColor(org.bukkit.DyeColor) 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)2 Requirements (net.citizensnpcs.api.command.Requirements)2 CommandException (net.citizensnpcs.api.command.exception.CommandException)2 DyeColor (org.bukkit.DyeColor)2 BarColor (org.bukkit.boss.BarColor)2 Color (org.bukkit.entity.Llama.Color)2