Class WebFinder
- java.lang.Object
-
- org.dreambot.api.methods.walking.pathfinding.impl.web.WebFinder
-
public class WebFinder extends java.lang.Object
Web pathfinding class, generally shouldn't need to be accessed directly
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addBlacklistedNode(@NonNull AbstractWebNode node)
void
addCustomWebPath(@NonNull CustomWebPath customWebPath)
boolean
addNode(@NonNull Tile newNodeTarget)
Creates and adds a new BasicWebNode at the provided tile and connects it to the nearest web node in our webvoid
addWebNode(@NonNull AbstractWebNode node)
This adds a custom web node to our standard web nodes without adding any connections automaticallyvoid
addWebNodes(@NonNull AbstractWebNode... nodes)
This just calls addWebNode for each web node passed inGlobalPath<AbstractWebNode>
calculate(int x1, int y1, int z1, int x2, int y2, int z2)
@Nullable GlobalPath<AbstractWebNode>
calculate(@Nullable AbstractWebNode start, @NonNull AbstractWebNode destination)
@Nullable GlobalPath<AbstractWebNode>
calculate(@Nullable AbstractWebNode start, @NonNull AbstractWebNode destination, int maxDepth)
Calculates a web path with a given start node, destination node, and a maximum depthGlobalPath<AbstractWebNode>
calculate(Tile start, Tile destination)
GlobalPath<AbstractWebNode>
calculate(WebPathQuery query)
boolean
canEquipTeleports()
boolean
canUseEquipmentTeleports()
boolean
canUseInventoryTeleports()
void
clearBlacklist()
void
clearCustomNodes()
@Nullable AbstractWebNode
createAndAddNode(@NonNull Tile newNodeTarget)
Creates and adds a new BasicWebNode at the provided tile and connects it to the nearest web node in our webvoid
disableEquipmentTeleports()
void
disableEquippingTeleports()
void
disableInventoryTeleports()
void
disableTeleport(@NonNull Teleport teleport)
Disables a teleport from being used in the pathfindervoid
disableWebNodeType(@NonNull WebNodeType type)
Disables a type of web nodes from being used in the pathfindervoid
enableEquipmentTeleports()
void
enableEquippingTeleports()
void
enableInventoryTeleports()
void
enableTeleport(@NonNull Teleport teleport)
Re-enables a previously disabled teleport to be used in the pathfindervoid
enableWebNodeType(@NonNull WebNodeType type)
Re-enables a previously disabled type of web nodes to be used in the pathfinder@Nullable AbstractWebNode
get(int index)
Returns the web node with the given index@NonNull java.util.List<AbstractWebNode>
getAll()
WebPathQuery
getCurrentPathQuery()
int
getId(@NonNull AbstractWebNode abstractWebNode)
@Nullable GlobalPath<AbstractWebNode>
getLastCalculatedPath()
Deprecated.@Nullable AbstractWebNode
getNearest(@NonNull Tile target, int threshold)
Gets the closestBasicWebNode
to the given tile within the threshold@Nullable AbstractWebNode
getNearest(@NonNull AbstractWebNode target)
Gets the closestBasicWebNode
to the givenAbstractWebNode
that's within five tiles of the given node@Nullable AbstractWebNode
getNearest(@NonNull AbstractWebNode target, int threshold)
Gets the closestBasicWebNode
to the givenAbstractWebNode
within the threshold@Nullable AbstractWebNode
getNearestGlobal(@NonNull Tile target, int threshold)
@NonNull java.util.ArrayList<AbstractWebNode>
getNodesWithin(int distance, @NonNull Tile tile)
Returns a list of allAbstractWebNode
's within the given distance on any planedouble
getPathRandomization()
static WebFinder
getWebFinder()
static @NonNull java.lang.String
getWebNodeVersion()
static boolean
isLoaded()
Checks if the base web nodes have been loaded into the clientstatic boolean
isWebNodeDebugEnabled()
boolean
isWebNodeTypeEnabled(@NonNull WebNodeType type)
static boolean
isWebNodeVersionAtLeast(@NonNull java.lang.String version)
static void
loadWebNodes()
void
removeNode(int idx)
void
removeNode(@NonNull AbstractWebNode node)
void
resetWebNodes()
void
setCurrentPathQuery(WebPathQuery currentPathQuery)
void
setPathRandomization(double randomization)
Sets the randomization factor used when web pathfinding.static void
setWebNodeVersion(@NonNull 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.static void
toggleWebNodeDebug(boolean enable)
-
-
-
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(@NonNull 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 @NonNull java.lang.String getWebNodeVersion()
-
isWebNodeVersionAtLeast
public static boolean isWebNodeVersionAtLeast(@NonNull java.lang.String version)
-
calculate
public GlobalPath<AbstractWebNode> calculate(WebPathQuery query)
-
calculate
public GlobalPath<AbstractWebNode> calculate(int x1, int y1, int z1, int x2, int y2, int z2)
-
calculate
public GlobalPath<AbstractWebNode> calculate(Tile start, Tile destination)
-
calculate
public @Nullable GlobalPath<AbstractWebNode> calculate(@Nullable AbstractWebNode start, @NonNull AbstractWebNode destination)
-
calculate
public @Nullable GlobalPath<AbstractWebNode> calculate(@Nullable AbstractWebNode start, @NonNull AbstractWebNode destination, int maxDepth)
Calculates a web path with a given start node, destination node, and a maximum depth- Parameters:
start
- Starting nodedestination
- Destination nodemaxDepth
- Maximum depth, -1 if no max- Returns:
- GlobalPath if found, null if not found or maximum depth reached
-
disableTeleport
public void disableTeleport(@NonNull Teleport teleport)
Disables a teleport from being used in the pathfinder- Parameters:
teleport
- theTeleport
to disable
-
enableTeleport
public void enableTeleport(@NonNull Teleport teleport)
Re-enables a previously disabled teleport to be used in the pathfinder- Parameters:
teleport
- theTeleport
to re-enable
-
disableWebNodeType
public void disableWebNodeType(@NonNull WebNodeType type)
Disables a type of web nodes from being used in the pathfinder- Parameters:
type
- theWebNodeType
to disable
-
isWebNodeTypeEnabled
public boolean isWebNodeTypeEnabled(@NonNull WebNodeType type)
-
enableWebNodeType
public void enableWebNodeType(@NonNull WebNodeType type)
Re-enables a previously disabled type of web nodes to be used in the pathfinder- Parameters:
type
- theWebNodeType
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 @Nullable AbstractWebNode getNearest(@NonNull AbstractWebNode target)
Gets the closestBasicWebNode
to the givenAbstractWebNode
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 @Nullable AbstractWebNode getNearest(@NonNull AbstractWebNode target, int threshold)
Gets the closestBasicWebNode
to the givenAbstractWebNode
within the thresholdTo find
AbstractWebNode
's of any type, you can usegetNodesWithin(int, Tile)
- 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.
-
getNearest
public @Nullable AbstractWebNode getNearest(@NonNull Tile target, int threshold)
Gets the closestBasicWebNode
to the given tile within the thresholdTo find
AbstractWebNode
's of any type, you can usegetNodesWithin(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(@NonNull 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 @Nullable AbstractWebNode createAndAddNode(@NonNull 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
-
getNearestGlobal
public @Nullable AbstractWebNode getNearestGlobal(@NonNull Tile target, int threshold)
-
getNodesWithin
public @NonNull java.util.ArrayList<AbstractWebNode> getNodesWithin(int distance, @NonNull Tile tile)
Returns a list of allAbstractWebNode
's within the given distance on any plane- Parameters:
distance
- the furthest a node can be from the tiletile
- 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)
-
removeNode
public void removeNode(@NonNull AbstractWebNode node)
-
addCustomWebPath
public void addCustomWebPath(@NonNull CustomWebPath customWebPath)
-
addBlacklistedNode
public void addBlacklistedNode(@NonNull AbstractWebNode node)
-
clearBlacklist
public void clearBlacklist()
-
clearCustomNodes
public void clearCustomNodes()
-
getId
public int getId(@NonNull AbstractWebNode abstractWebNode)
-
addWebNode
public void addWebNode(@NonNull 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(@NonNull AbstractWebNode... nodes)
This just calls addWebNode for each web node passed in- Parameters:
nodes
- the web nodes to add
-
get
public @Nullable 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()
-
getLastCalculatedPath
@Deprecated public @Nullable GlobalPath<AbstractWebNode> getLastCalculatedPath()
Deprecated.
-
getAll
public @NonNull java.util.List<AbstractWebNode> getAll()
-
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
-
toggleWebNodeDebug
public static void toggleWebNodeDebug(boolean enable)
-
isWebNodeDebugEnabled
public static boolean isWebNodeDebugEnabled()
-
getPathRandomization
public double getPathRandomization()
-
getCurrentPathQuery
public WebPathQuery getCurrentPathQuery()
-
setCurrentPathQuery
public void setCurrentPathQuery(WebPathQuery currentPathQuery)
-
-