Citizens2/main/src/main/java/net/citizensnpcs/commands/WaypointCommands.java

59 lines
2.3 KiB
Java
Raw Normal View History

package net.citizensnpcs.commands;
import net.citizensnpcs.Citizens;
import net.citizensnpcs.api.command.Command;
import net.citizensnpcs.api.command.CommandContext;
import net.citizensnpcs.api.command.Requirements;
import net.citizensnpcs.api.command.exception.CommandException;
2012-09-30 13:36:48 +02:00
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Messaging;
2012-09-30 13:36:48 +02:00
import net.citizensnpcs.trait.waypoint.Waypoints;
import net.citizensnpcs.util.Messages;
import org.bukkit.command.CommandSender;
@Requirements(ownership = true, selected = true)
public class WaypointCommands {
public WaypointCommands(Citizens plugin) {
}
2012-09-30 13:36:48 +02:00
2012-10-23 09:14:54 +02:00
// TODO: refactor into a policy style system
@Command(
aliases = { "waypoints", "waypoint", "wp" },
2014-07-12 21:20:47 +02:00
usage = "disableteleport",
2012-10-23 09:14:54 +02:00
desc = "Disables teleportation when stuck (temporary command)",
modifiers = { "disableteleport" },
min = 1,
max = 1,
permission = "citizens.waypoints.disableteleport")
public void disableTeleporting(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
2012-10-23 09:14:54 +02:00
npc.getNavigator().getDefaultParameters().stuckAction(null);
Messaging.sendTr(sender, Messages.WAYPOINT_TELEPORTING_DISABLED);
}
2012-09-30 13:36:48 +02:00
@Command(
aliases = { "waypoints", "waypoint", "wp" },
2013-03-16 06:28:26 +01:00
usage = "provider [provider name] (-d)",
2012-09-30 13:36:48 +02:00
desc = "Sets the current waypoint provider",
modifiers = { "provider" },
min = 1,
max = 2,
2013-03-16 06:28:26 +01:00
flags = "d",
permission = "citizens.waypoints.provider")
2012-09-30 13:36:48 +02:00
public void provider(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
Waypoints waypoints = npc.getTrait(Waypoints.class);
if (args.argsLength() == 1) {
2013-03-16 06:28:26 +01:00
if (args.hasFlag('d')) {
2012-09-30 13:36:48 +02:00
waypoints.describeProviders(sender);
2013-09-26 17:55:12 +02:00
} else {
Messaging.sendTr(sender, Messages.CURRENT_WAYPOINT_PROVIDER, waypoints.getCurrentProviderName());
2013-09-26 17:55:12 +02:00
}
2012-09-30 13:36:48 +02:00
return;
}
boolean success = waypoints.setWaypointProvider(args.getString(1));
if (!success)
throw new CommandException("Provider not found.");
2012-10-08 09:11:49 +02:00
Messaging.sendTr(sender, Messages.WAYPOINT_PROVIDER_SET, args.getString(1));
2012-09-30 13:36:48 +02:00
}
}