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);
}
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));
}
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);
}
}
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);
}
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);
}
}
Aggregations