Exemplo n.º 1
0
 @Command(
     aliases = "npc",
     usage = "move",
     desc = "move an NPC",
     modifiers = "move",
     min = 1,
     max = 1)
 @CommandPermissions("basic.modify.move")
 public static void move(CommandContext args, Player player, HumanNPC npc) {
   if (npc.getWorld() != player.getWorld()
       && !PermissionManager.hasPermission(player, "citizens.basic.modify.move.multiworld")) {
     player.sendMessage(ChatColor.GRAY + "You don't have permission to move NPCs between worlds.");
     return;
   }
   player.sendMessage(StringUtils.wrap(npc.getName()) + " is en route to your location!");
   npc.teleport(player.getLocation());
   npc.getNPCData().setLocation(player.getLocation());
 }
Exemplo n.º 2
0
 @Command(
     aliases = "npc",
     usage = "moveto [x y z] (world pitch yaw)",
     desc = "move an NPC to a location",
     modifiers = "moveto",
     min = 4,
     max = 7)
 @CommandPermissions("basic.modify.moveto")
 public static void moveTo(CommandContext args, Player player, HumanNPC npc) {
   double x = 0, y = 0, z = 0;
   float yaw = npc.getLocation().getYaw(), pitch = npc.getLocation().getPitch();
   String world = npc.getWorld().getName();
   switch (args.argsLength()) {
     case 7:
       yaw = Float.parseFloat(args.getString(6));
     case 6:
       pitch = Float.parseFloat(args.getString(5));
     case 5:
       world = args.getString(4);
       if (Bukkit.getServer().getWorld(world) == null) {
         Messaging.sendError(player, "Invalid world.");
         return;
       }
     case 4:
       x = Double.parseDouble(args.getString(1));
       y = Double.parseDouble(args.getString(2));
       z = Double.parseDouble(args.getString(3));
   }
   Location loc = new Location(Bukkit.getServer().getWorld(world), x, y, z, pitch, yaw);
   npc.teleport(loc);
   npc.getNPCData().setLocation(loc);
   player.sendMessage(
       StringUtils.wrap(npc.getName())
           + " moved to the coordinates "
           + StringUtils.wrap(x)
           + ", "
           + StringUtils.wrap(y)
           + ", "
           + StringUtils.wrap(z)
           + " in the world "
           + StringUtils.wrap(world)
           + ".");
 }