@Command(
     aliases = {"waypoint", "wp"},
     desc = "The main waypoint command",
     max = 1)
 @NestedCommand(value = WaypointSubCommands.class, ignoreBody = false)
 public void waypoint(CommandSource source, CommandArguments args) throws CommandException {
   if (source instanceof Player && args.length() == 1) {
     source.processCommand("waypoint", "tpto", args.getString(0));
   }
 }
Exemplo n.º 2
0
 public static Material popMaterial(String argName, CommandArguments args)
     throws ArgumentParseException {
   String arg = args.currentArgument(argName);
   Material mat;
   try {
     mat = VanillaMaterials.getMaterial((short) Integer.parseInt(arg));
   } catch (NumberFormatException ex) {
     mat = MaterialRegistry.get(arg);
   }
   if (mat == null) {
     throw args.failure(argName, "Unknown material: " + arg, false);
   }
   return args.success(argName, mat);
 }
Exemplo n.º 3
0
 public static GameMode popGameMode(String argName, CommandArguments args)
     throws ArgumentParseException {
   String raw = args.currentArgument(argName);
   if (raw.length() == 1) {
     GameMode mode = null;
     if (raw.equalsIgnoreCase("s")) {
       mode = GameMode.SURVIVAL;
     } else if (raw.equalsIgnoreCase("c")) {
       mode = GameMode.CREATIVE;
     } else if (raw.equalsIgnoreCase("a")) {
       mode = GameMode.ADVENTURE;
     }
     if (mode != null) {
       return args.success(argName, mode);
     }
   }
   return args.popEnumValue(argName, GameMode.class);
 }
 @Command(
     aliases = {"remove", "rm"},
     desc = "Removes an existing waypoint",
     min = 1,
     max = 1)
 @Permissible("plugintest.waypoint.remove")
 public void remove(CommandSource source, CommandArguments args) throws CommandException {
   String name = args.getString(0);
   if (this.waypoints.containsKey(name)) {
     throw new CommandException("The \"" + name + "\" waypoint does not exist.");
   }
   this.waypoints.remove(name);
   source.sendMessage("Waypoint \"" + name + "\" has been removed.");
 }
    @Command(
        aliases = {"create", "make", "mk"},
        desc = "Creates a new waypoint",
        min = 1,
        max = 1)
    @Permissible("plugintest.waypoint.create")
    public void create(CommandSource source, CommandArguments args) throws CommandException {
      if (!(source instanceof Player)) {
        throw new CommandException("Only players may create waypoints.");
      }

      String name = args.getString(0);
      Player player = (Player) source;

      if (this.waypoints.containsKey(name)) {
        throw new CommandException("The \"" + name + "\" waypoint already exists.");
      }

      this.waypoints.put(name, player.getScene().getPosition());
      player.sendMessage("Waypoint \"" + name + "\" has been created.");
    }
    @Command(
        aliases = {"teleportto", "tpto"},
        desc = "Teleports the player to the waypoint",
        min = 1,
        max = 1)
    @Permissible("plugintest.waypoint.tpto")
    public void tpto(CommandSource source, CommandArguments args) throws CommandException {
      if (!(source instanceof Player)) {
        throw new CommandException("Only players may teleport to waypoints, silly.");
      }

      String name = args.getString(0);
      Player player = (Player) source;
      Point destination = this.waypoints.get(name);

      if (destination == null) {
        throw new CommandException("The \"" + name + "\" waypoint does not exist.");
      }

      player.teleport(destination);
      player.sendMessage("Teleported to waypoint.");
    }