Search in sources :

Example 56 with Command

use of net.citizensnpcs.api.command.Command in project Citizens2 by CitizensDev.

the class TemplateCommands method delete.

@Command(aliases = { "template", "tpl" }, usage = "delete [template name]", desc = "Deletes a template", modifiers = { "delete" }, min = 2, max = 2, permission = "citizens.templates.delete")
public void delete(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
    String name = args.getString(1);
    if (Template.byName(name) == null)
        throw new CommandException(Messages.TEMPLATE_MISSING);
    Template.byName(name).delete();
    Messaging.sendTr(sender, Messages.TEMPLATE_DELETED, name);
}
Also used : CommandException(net.citizensnpcs.api.command.exception.CommandException) Command(net.citizensnpcs.api.command.Command)

Example 57 with Command

use of net.citizensnpcs.api.command.Command in project Citizens2 by CitizensDev.

the class WaypointCommands method provider.

@Command(aliases = { "waypoints", "waypoint", "wp" }, usage = "provider [provider name] (-d)", desc = "Sets the current waypoint provider", modifiers = { "provider" }, min = 1, max = 2, flags = "d", permission = "citizens.waypoints.provider")
public void provider(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
    Waypoints waypoints = npc.getTrait(Waypoints.class);
    if (args.argsLength() == 1) {
        if (args.hasFlag('d')) {
            waypoints.describeProviders(sender);
        } else {
            Messaging.sendTr(sender, Messages.CURRENT_WAYPOINT_PROVIDER, waypoints.getCurrentProviderName());
        }
        return;
    }
    boolean success = waypoints.setWaypointProvider(args.getString(1));
    if (!success)
        throw new CommandException("Provider not found.");
    Messaging.sendTr(sender, Messages.WAYPOINT_PROVIDER_SET, args.getString(1));
}
Also used : Waypoints(net.citizensnpcs.trait.waypoint.Waypoints) CommandException(net.citizensnpcs.api.command.exception.CommandException) Command(net.citizensnpcs.api.command.Command)

Example 58 with Command

use of net.citizensnpcs.api.command.Command in project Citizens2 by CitizensDev.

the class AdminCommands method reload.

@Command(aliases = { "citizens" }, usage = "reload", desc = "Reload Citizens", modifiers = { "reload" }, min = 1, max = 1, permission = "citizens.admin")
public void reload(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
    Messaging.sendTr(sender, Messages.CITIZENS_RELOADING);
    try {
        plugin.reload();
        Messaging.sendTr(sender, Messages.CITIZENS_RELOADED);
    } catch (NPCLoadException ex) {
        ex.printStackTrace();
        throw new CommandException(Messages.CITIZENS_RELOAD_ERROR);
    }
}
Also used : CommandException(net.citizensnpcs.api.command.exception.CommandException) NPCLoadException(net.citizensnpcs.api.exception.NPCLoadException) Command(net.citizensnpcs.api.command.Command)

Example 59 with Command

use of net.citizensnpcs.api.command.Command in project Citizens2 by CitizensDev.

the class EditorCommands method path.

@Command(aliases = { "npc" }, usage = "path", desc = "Toggle the waypoint editor", modifiers = { "path" }, min = 1, max = 1, flags = "*", permission = "citizens.npc.edit.path")
@Requirements(selected = true, ownership = true)
public void path(CommandContext args, CommandSender player, NPC npc) {
    Editor editor = npc.getTrait(Waypoints.class).getEditor(player, args);
    if (editor == null)
        return;
    Editor.enterOrLeave((Player) player, editor);
}
Also used : Waypoints(net.citizensnpcs.trait.waypoint.Waypoints) Editor(net.citizensnpcs.editor.Editor) EquipmentEditor(net.citizensnpcs.editor.EquipmentEditor) CopierEditor(net.citizensnpcs.editor.CopierEditor) Command(net.citizensnpcs.api.command.Command) Requirements(net.citizensnpcs.api.command.Requirements)

Example 60 with Command

use of net.citizensnpcs.api.command.Command 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)66 Requirements (net.citizensnpcs.api.command.Requirements)45 CommandException (net.citizensnpcs.api.command.exception.CommandException)40 ServerCommandException (net.citizensnpcs.api.command.exception.ServerCommandException)27 Location (org.bukkit.Location)13 Player (org.bukkit.entity.Player)13 NPC (net.citizensnpcs.api.npc.NPC)10 CurrentLocation (net.citizensnpcs.trait.CurrentLocation)9 DyeColor (org.bukkit.DyeColor)8 BarColor (org.bukkit.boss.BarColor)5 NoPermissionsException (net.citizensnpcs.api.command.exception.NoPermissionsException)4 Owner (net.citizensnpcs.api.trait.trait.Owner)4 Anchors (net.citizensnpcs.trait.Anchors)4 CommandUsageException (net.citizensnpcs.api.command.exception.CommandUsageException)3 MobType (net.citizensnpcs.api.trait.trait.MobType)3 Paginator (net.citizensnpcs.api.util.Paginator)3 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)3 ScriptTrait (net.citizensnpcs.trait.ScriptTrait)3 SheepTrait (net.citizensnpcs.trait.SheepTrait)3 LocationTag (com.denizenscript.denizen.objects.LocationTag)2