Class Navigation

java.lang.Object
dev.twilite.game.navigation.Navigation

public class Navigation extends Object
Convenience entry point for server-side path plans.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Clears the cached current route.
    static int
    distance(Coord start, Coord destination, boolean includeTransports)
    Returns the real path distance between two coordinates, or Integer.MAX_VALUE when no route is available.
    distanceAsync(Coord start, Coord destination, boolean includeTransports)
    Returns the real path distance asynchronously, or Integer.MAX_VALUE when no route is available.
    static URI
    Returns the pathfinder server endpoint used by navigation requests.
    static boolean
    execute(dev.twilite.game.navigation.action.NavigationAction action)
    Executes a single navigation action.
    static Optional<Coord>
    nearest(boolean includeTransports, Coord... destinations)
    Returns the nearest reachable destination by path distance, or empty when none are reachable.
    static Optional<Coord>
    nearest(Coord... destinations)
    Returns the nearest reachable destination by path distance, or empty when none are reachable.
    static Optional<Coord>
    nearest(Coord start, boolean includeTransports, Coord... destinations)
    Returns the nearest reachable destination from start by path distance.
    static Optional<dev.twilite.game.navigation.action.NavigationAction>
    next(Coord destination)
    Returns the next action from the local player to destination.
    static Optional<dev.twilite.game.navigation.action.NavigationAction>
    next(Coord start, Coord destination)
    Returns the next action from start to destination.
    static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationAction>>
    nextAsync(Coord destination)
    Returns the next action asynchronously from the local player to destination.
    static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationAction>>
    nextAsync(Coord start, Coord destination)
    Returns the next action asynchronously from start to destination.
    static Optional<dev.twilite.game.navigation.action.NavigationPlan>
    plan(Coord destination)
    Requests a plan from the local player to destination.
    static Optional<dev.twilite.game.navigation.action.NavigationPlan>
    plan(Coord destination, boolean includeWilderness)
    Requests a plan from the local player to destination.
    static Optional<dev.twilite.game.navigation.action.NavigationPlan>
    plan(Coord start, Coord destination)
    Requests a plan from start to destination.
    static Optional<dev.twilite.game.navigation.action.NavigationPlan>
    plan(Coord start, Coord destination, boolean includeWilderness)
    Requests a plan from start to destination.
    static Optional<dev.twilite.game.navigation.action.NavigationPlan>
    plan(Coord start, Coord destination, int padding)
    Requests a plan from start to destination using custom map padding.
    static Optional<dev.twilite.game.navigation.action.NavigationPlan>
    plan(Coord start, Coord destination, int padding, boolean includeWilderness)
    Requests a plan from start to destination using custom map padding.
    static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationPlan>>
    planAsync(Coord destination)
    Requests a plan asynchronously from the local player to destination.
    static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationPlan>>
    planAsync(Coord destination, boolean includeWilderness)
    Requests a plan asynchronously from the local player to destination.
    static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationPlan>>
    planAsync(Coord start, Coord destination)
    Requests a plan asynchronously from start to destination.
    static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationPlan>>
    planAsync(Coord start, Coord destination, boolean includeWilderness)
    Requests a plan asynchronously from start to destination.
    static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationPlan>>
    planAsync(Coord start, Coord destination, int padding)
    Requests a plan asynchronously from start to destination using custom map padding.
    static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationPlan>>
    planAsync(Coord start, Coord destination, int padding, boolean includeWilderness)
    Requests a plan asynchronously from start to destination using custom map padding.
    static boolean
    Returns true when run is enabled.
    static int
    Returns the current run energy percentage.
    static boolean
    Returns true when a stamina effect is active.
    static boolean
    step(Coord destination)
    Executes the next navigation action toward destination.
    static boolean
    step(Coord destination, boolean includeWilderness)
     
    static void
    toggleRun(boolean on)
    Toggles run to the requested state.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Navigation

      public Navigation()
  • Method Details

    • staminaActive

      public static boolean staminaActive()
      Returns true when a stamina effect is active.
    • runEnabled

      public static boolean runEnabled()
      Returns true when run is enabled.
    • runEnergy

      public static int runEnergy()
      Returns the current run energy percentage.
    • toggleRun

      public static void toggleRun(boolean on)
      Toggles run to the requested state.
    • plan

      public static Optional<dev.twilite.game.navigation.action.NavigationPlan> plan(Coord destination)
      Requests a plan from the local player to destination.
    • plan

      public static Optional<dev.twilite.game.navigation.action.NavigationPlan> plan(Coord destination, boolean includeWilderness)
      Requests a plan from the local player to destination.
    • plan

      public static Optional<dev.twilite.game.navigation.action.NavigationPlan> plan(Coord start, Coord destination)
      Requests a plan from start to destination.
    • plan

      public static Optional<dev.twilite.game.navigation.action.NavigationPlan> plan(Coord start, Coord destination, boolean includeWilderness)
      Requests a plan from start to destination.
    • plan

      public static Optional<dev.twilite.game.navigation.action.NavigationPlan> plan(Coord start, Coord destination, int padding)
      Requests a plan from start to destination using custom map padding.
    • plan

      public static Optional<dev.twilite.game.navigation.action.NavigationPlan> plan(Coord start, Coord destination, int padding, boolean includeWilderness)
      Requests a plan from start to destination using custom map padding.
    • endpoint

      public static URI endpoint()
      Returns the pathfinder server endpoint used by navigation requests.
    • planAsync

      public static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationPlan>> planAsync(Coord destination)
      Requests a plan asynchronously from the local player to destination.
    • planAsync

      public static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationPlan>> planAsync(Coord destination, boolean includeWilderness)
      Requests a plan asynchronously from the local player to destination.
    • planAsync

      public static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationPlan>> planAsync(Coord start, Coord destination)
      Requests a plan asynchronously from start to destination.
    • planAsync

      public static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationPlan>> planAsync(Coord start, Coord destination, boolean includeWilderness)
      Requests a plan asynchronously from start to destination.
    • planAsync

      public static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationPlan>> planAsync(Coord start, Coord destination, int padding)
      Requests a plan asynchronously from start to destination using custom map padding.
    • planAsync

      public static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationPlan>> planAsync(Coord start, Coord destination, int padding, boolean includeWilderness)
      Requests a plan asynchronously from start to destination using custom map padding.
    • clearCachedPlan

      public static void clearCachedPlan()
      Clears the cached current route.
    • distance

      public static int distance(Coord start, Coord destination, boolean includeTransports)
      Returns the real path distance between two coordinates, or Integer.MAX_VALUE when no route is available.
    • nearest

      public static Optional<Coord> nearest(Coord... destinations)
      Returns the nearest reachable destination by path distance, or empty when none are reachable.
    • nearest

      public static Optional<Coord> nearest(boolean includeTransports, Coord... destinations)
      Returns the nearest reachable destination by path distance, or empty when none are reachable.
    • nearest

      public static Optional<Coord> nearest(Coord start, boolean includeTransports, Coord... destinations)
      Returns the nearest reachable destination from start by path distance.
    • distanceAsync

      public static CompletableFuture<Integer> distanceAsync(Coord start, Coord destination, boolean includeTransports)
      Returns the real path distance asynchronously, or Integer.MAX_VALUE when no route is available.
    • next

      public static Optional<dev.twilite.game.navigation.action.NavigationAction> next(Coord destination)
      Returns the next action from the local player to destination.
    • next

      public static Optional<dev.twilite.game.navigation.action.NavigationAction> next(Coord start, Coord destination)
      Returns the next action from start to destination.
    • nextAsync

      public static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationAction>> nextAsync(Coord destination)
      Returns the next action asynchronously from the local player to destination.
    • nextAsync

      public static CompletableFuture<Optional<dev.twilite.game.navigation.action.NavigationAction>> nextAsync(Coord start, Coord destination)
      Returns the next action asynchronously from start to destination.
    • step

      public static boolean step(Coord destination)
      Executes the next navigation action toward destination.

      The pathfinder chooses the movement mode from the current game state. If the local player is on a sailing world entity, the request includes boat position, hull, heading, collision, and resistance data, and the server returns sailing actions. Otherwise it returns normal walking or transport actions. This method is therefore the preferred entry point for plugins; callers do not need to choose walking versus sailing themselves.

      Returns:
      true when a cached action was executed, or false while a new path is being requested or if no action is available.
    • step

      public static boolean step(Coord destination, boolean includeWilderness)
    • execute

      public static boolean execute(dev.twilite.game.navigation.action.NavigationAction action)
      Executes a single navigation action.