Class WebFinder


  • public class WebFinder
    extends java.lang.Object
    Web pathfinding class, generally shouldn't need to be accessed directly
    • Method Detail

      • getWebFinder

        public static WebFinder getWebFinder()
      • loadWebNodes

        public static void loadWebNodes()
      • isLoaded

        public static boolean isLoaded()
        Checks if the base web nodes have been loaded into the client
        Returns:
        true if loaded, false if still loading
      • setWebNodeVersion

        public static void setWebNodeVersion​(java.lang.String version)
        This can be used to load web nodes from a prior version, allowing you to ensure any future node updates don't affect your custom web nodes. This method will do a full reset of the WebFinder and then load the nodes, any customization to any walking related methods will need to happen AFTER calling this method.
        Parameters:
        version - The string version, "latest" is default and will grab the newest available nodes. All versions can be found in the Discord's #client-updates channel.
      • getWebNodeVersion

        public static java.lang.String getWebNodeVersion()
      • calculate

        public GlobalPath<AbstractWebNode> calculate​(AbstractWebNode start,
                                                     AbstractWebNode destination,
                                                     int maxDepth)
        Calculates a web path with a given start node, destination node, and a maximum depth
        Parameters:
        start - Starting node
        destination - Destination node
        maxDepth - Maximum depth, -1 if no max
        Returns:
        GlobalPath if found, null if not found or maximum depth reached
      • disableTeleport

        public void disableTeleport​(Teleport teleport)
        Disables a teleport from being used in the pathfinder
        Parameters:
        teleport - the Teleport to disable
      • enableTeleport

        public void enableTeleport​(Teleport teleport)
        Re-enables a previously disabled teleport to be used in the pathfinder
        Parameters:
        teleport - the Teleport to re-enable
      • disableWebNodeType

        public void disableWebNodeType​(WebNodeType type)
        Disables a type of web nodes from being used in the pathfinder
        Parameters:
        type - the WebNodeType to disable
      • isWebNodeTypeEnabled

        public boolean isWebNodeTypeEnabled​(WebNodeType type)
      • enableWebNodeType

        public void enableWebNodeType​(WebNodeType type)
        Re-enables a previously disabled type of web nodes to be used in the pathfinder
        Parameters:
        type - the WebNodeType to re-enable
      • canEquipTeleports

        public boolean canEquipTeleports()
      • disableEquippingTeleports

        public void disableEquippingTeleports()
      • enableEquippingTeleports

        public void enableEquippingTeleports()
      • canUseInventoryTeleports

        public boolean canUseInventoryTeleports()
      • canUseEquipmentTeleports

        public boolean canUseEquipmentTeleports()
      • disableInventoryTeleports

        public void disableInventoryTeleports()
      • enableInventoryTeleports

        public void enableInventoryTeleports()
      • disableEquipmentTeleports

        public void disableEquipmentTeleports()
      • enableEquipmentTeleports

        public void enableEquipmentTeleports()
      • getNearest

        public AbstractWebNode getNearest​(AbstractWebNode target)
        Gets the closest BasicWebNode to the given AbstractWebNode that's within five tiles of the given node
        Parameters:
        target - the target you wish to find the nearest web node of.
        Returns:
        the closest basic web node to the given tile if found, otherwise null.
      • getNearest

        public AbstractWebNode getNearest​(Tile target,
                                          int threshold)
        Gets the closest BasicWebNode to the given tile within the threshold

        To find AbstractWebNode's of any type, you can use getNodesWithin(int, Tile)

        Note: If the target tile is local (in your current region), this will return the nearest node based on the actual path distance. If you want the nearest based on straight distance, use getNearestGlobal(Tile, int) instead.

        Parameters:
        target - the target you wish to find the nearest web node of.
        threshold - the threshold of search you would like to perform.
        Returns:
        the closest basic web node to the given tile if found, otherwise null.
      • addNode

        public boolean addNode​(Tile newNodeTarget)
        Creates and adds a new BasicWebNode at the provided tile and connects it to the nearest web node in our web
        Parameters:
        newNodeTarget - The tile to create a BasicWebNode at
        Returns:
        true if successful
      • createAndAddNode

        public AbstractWebNode createAndAddNode​(Tile newNodeTarget)
        Creates and adds a new BasicWebNode at the provided tile and connects it to the nearest web node in our web
        Parameters:
        newNodeTarget - The tile to create a BasicWebNode at
        Returns:
        the created AbstractWebNode if it successfully finds a nearby node to connect to, null otherwise
      • getNodesWithin

        public java.util.ArrayList<AbstractWebNode> getNodesWithin​(int distance,
                                                                   Tile tile)
        Returns a list of all AbstractWebNode's within the given distance on any plane
        Parameters:
        distance - the furthest a node can be from the tile
        tile - the tile to check against
        Returns:
        a list of all AbstractWebNode's that are within the distance in no particular order
      • removeNode

        public void removeNode​(int idx)
      • addCustomWebPath

        public void addCustomWebPath​(CustomWebPath customWebPath)
      • addBlacklistedNode

        public void addBlacklistedNode​(AbstractWebNode node)
      • clearBlacklist

        public void clearBlacklist()
      • clearCustomNodes

        public void clearCustomNodes()
      • addWebNode

        public void addWebNode​(AbstractWebNode node)
        This adds a custom web node to our standard web nodes without adding any connections automatically
        Parameters:
        node - The web node to add to our web
      • addWebNodes

        public void addWebNodes​(AbstractWebNode... nodes)
        This just calls addWebNode for each web node passed in
        Parameters:
        nodes - the web nodes to add
      • get

        public AbstractWebNode get​(int index)

        Returns the web node with the given index

        NOTE: You shouldn't be connecting to our web nodes using this method, as the index can change at any time. You should use getNearest(Tile, int) to find the correct node.

        Parameters:
        index - the index of the web node
        Returns:
        The web node if it exists, null if the nodes haven't been loaded or if it's not found
      • resetWebNodes

        public void resetWebNodes()
      • setPathRandomization

        public void setPathRandomization​(double randomization)
        Sets the randomization factor used when web pathfinding.

        A value of 0.0 will disable any randomization, and any positive value will allow for less optimal paths to be generated. The default value of this is 0, meaning we'll only return the most optimal path.

        Parameters:
        randomization - the randomization factor
      • getPathRandomization

        public double getPathRandomization()
      • getCurrentPathQuery

        public WebPathQuery getCurrentPathQuery()
      • setCurrentPathQuery

        public void setCurrentPathQuery​(WebPathQuery currentPathQuery)