Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Resource Cache Pathing

Bot Author
Joined
Jan 29, 2016
Messages
1,294
I've noticed alot of people having issues with their bots recently and I thought I would share this to assist new developers coming into the scene.

Tutorial - Tutorial - Understanding Runemate's Pathing Systems, and Utilizing Them DON'T USE THIS

When you're making a webPath you would usually do something like

Code:
WebPath path = WebPathRequest.builder().setDestination(x).build();
if (path != null) { path.step(true);

You should ideally be using this kind of format.
Code:
 private static final Map<String, WebPath> pathCache = new HashMap<>();

    public static WebPath getPathDestination(Locatable destination, boolean usingTeleports) {
        String key = destination.toString() + usingTeleports;
        WebPath cachedPath = pathCache.get(key);

        if (cachedPath == null) {
            cachedPath = WebPathRequest.builder()
                .setDestination(destination)
                .setUsingTeleports(usingTeleports)
                .build();
            pathCache.put(key, cachedPath);
        }
        return cachedPath;
    }

If you're wanting to use it for Landmarks, you can change this to this format
Code:
    public static WebPath getPathLandmark(Landmark landmark, boolean usingTeleports) {
        String key = landmark.toString() + usingTeleports;
        WebPath cachedPath = pathCache.get(key);

        if (cachedPath == null) {
            cachedPath = WebPathRequest.builder()
                .setLandmark(landmark)
                .setUsingTeleports(usingTeleports)
                .build();
            pathCache.put(key, cachedPath);
        }
        return cachedPath;
    }

To call the path, you would now do

Code:
WebPath path = getPathDestination(X,Y,Z, true/false);
 
Last edited:
Top