Ejemplo n.º 1
0
 @Command(
     aliases = "npc",
     usage = "select [id]",
     desc = "select an NPC by its ID",
     modifiers = "select",
     min = 2,
     max = 2)
 @CommandPermissions("basic.use.select")
 @CommandRequirements()
 public static void select(CommandContext args, Player player, HumanNPC npc) {
   npc = NPCManager.get(args.getInteger(1));
   if (npc == null) {
     player.sendMessage(
         ChatColor.RED
             + "No NPC with ID "
             + StringUtils.wrap(args.getString(1), ChatColor.RED)
             + " exists.");
   } else {
     NPCDataManager.selectNPC(player, npc);
     Messaging.send(player, npc, Settings.getString("SelectionMessage"));
   }
 }
Ejemplo n.º 2
0
 @Command(
     aliases = "npc",
     usage = "[path|waypoints] (reset|index)",
     desc = "toggle waypoint editing",
     modifiers = {"path", "waypoints"},
     min = 1,
     max = 2)
 @CommandPermissions("waypoints.edit")
 public static void waypoints(CommandContext args, Player player, HumanNPC npc) {
   if (args.argsLength() >= 2 && args.getString(1).equalsIgnoreCase("reset")) {
     npc.getWaypoints().resetWaypoints();
     player.sendMessage(ChatColor.GREEN + "Waypoints " + StringUtils.wrap("reset") + ".");
     return;
   }
   if (NPCDataManager.equipmentEditors.containsKey(player)) {
     Messaging.sendError(player, "You can only be in one editor at a time.");
     return;
   }
   int index = npc.getWaypoints().size() - 1;
   if (args.argsLength() == 2 && StringUtils.isNumber(args.getString(1))) {
     index = args.getInteger(1) - 1;
     if (index < 0) index = 0;
     if (npc.getWaypoints().size() != 0 && index >= npc.getWaypoints().size()) {
       player.sendMessage(
           ChatColor.GRAY
               + "Index out of bounds. This NPC only has "
               + StringUtils.wrap(npc.getWaypoints().size())
               + " waypoints.");
       return;
     }
   }
   if (index < 0) index = 0;
   PathEditingSession editing = NPCDataManager.pathEditors.get(player);
   int UID = npc.getUID();
   if (editing == null) {
     player.sendMessage(ChatColor.AQUA + StringUtils.listify("Waypoint Editing Controls"));
     player.sendMessage(
         StringUtils.wrap("Left")
             + " click adds a waypoint, while "
             + StringUtils.wrap("right")
             + " click acts as an undo.");
     player.sendMessage(
         StringUtils.wrap("Right clicking")
             + " the NPC will cause him to restart from the current index.");
     player.sendMessage(StringUtils.wrap("Repeat") + " this command to finish.");
     editing = new PathEditingSession(UID, index);
   } else if (editing.getUID() == UID && args.argsLength() == 1) {
     player.sendMessage(StringUtils.wrap("Finished") + " editing waypoints.");
     NPCDataManager.pathEditors.remove(player);
     return;
   } else if (editing.getUID() != UID) {
     player.sendMessage(
         ChatColor.GRAY + "Now editing " + StringUtils.wrap(npc.getName()) + "'s waypoints.");
     editing = new PathEditingSession(UID, index);
   }
   if (npc.getWaypoints().size() > 0) {
     npc.getWaypoints().setIndex(index);
     npc.teleport(npc.getWaypoints().get(index).getLocation());
   }
   NPCDataManager.pathEditors.put(player, editing);
 }