Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Download item icons or anything from the wiki to the data folder.

Featured Replies

Non-SDN scripts are troublesome with resources. You have to download the resources externally. That's why I made some code which can be used to download any image from the oldschool runescape wiki or any other website for that matter.
 

    public static CompletableFuture<BufferedImage> getImage(File imageFolder, String fileName, String url) {
        File imageFile = new File(imageFolder, fileName);

//AccessController.doPrivileged gives the new thread permission to read the image from the data directory

        return CompletableFuture.supplyAsync(() -> AccessController.doPrivileged((PrivilegedAction<BufferedImage>) () -> {
            try {
                if (!imageFile.exists()) {
                    downloadImage(url, imageFile);
                }
                return ImageIO.read(imageFile);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }));
    }

    private static boolean downloadImage(String urlString, File destination) throws IOException {
        URL url = new URL(urlString);
        InputStream in = url.openStream();
        FileOutputStream fos = new FileOutputStream(destination);
        ReadableByteChannel rbc = Channels.newChannel(in);
        fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
        fos.close();
        in.close();
        return true;
    }

Example usage:

        //Somwhere in your class
        private BufferedImage coinIcon;
        //In your paint method
        if(coinIcon != null) {
            g.drawImage(coinsIcon, x, y, null);//Use original dimensions
            g.drawImage(coinsIcon, x, y, width, height, null);
        }

        File imageFolder = new File(getDirectoryData() + File.seperator + "scriptname", "images");
        String fileName = "coinstack.png";
        String url = "https://oldschool.runescape.wiki/images/Coins_10000.png";
        Function<Throwable, Void> errorHandler = e -> {
            script.log(e);
            return null;
        };

        ResourceManager.getImage(imageFolder, fileName, url).thenAccept(image -> {
            coinIcon = image;
            //Note: this is off the main thread, if youre inserting into lists or maps from multiple of these calls, use synchronized or concurrent collentions and maps.
        }).exceptionally(errorHandler);

The fileName is the name for how it is saved in the data folder. This code spawns a new thread that reads or downloads the image. Then the thenAccept function is called with the buffered image.

 

 

Edited by Bobbey

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.