Jump to content

IP Display Changer


Purple

Recommended Posts

  • 2 weeks later...

can someone do a massive solid for me and compile this? It'll save me the hour or two figuring it out :D 

 

Really? All you do is go to the tutorials section, find the script skeleton. Than add the code to the onStart() method. Not hard, id recommend learning some java if you wish to handle scripts, look on youtube for the boston or something like that. He teaches everything from variables to polymorphism, and abstract classes.

Link to comment
Share on other sites

  • 1 month later...

Here's the proper way of doing it : 

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import javax.swing.*;
import java.awt.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

@ScriptManifest(author = "Purple", name = "IP Display Changer", version = 1.01, info = "Changes the title of your osbot to display your bots IP address.", logo = "")
public class Display extends Script {

    @Override
    public void onStart() {
        changeFrameTitle("OSBot (" + getCurrentIPAddress() + ")");
        stop(false);
    }

    public void changeFrameTitle(final String title) {
        for(Frame frame : Frame.getFrames()) {
            if(frame.isVisible() && frame.getTitle().startsWith("OSBot")) {
                SwingUtilities.invokeLater(() -> frame.setTitle(title));
                break;
            }
        }
    }
    
    public int onLoop() throws InterruptedException {
        
        return 0;
    }

    public String getCurrentIPAddress() {
        try {
            URL url = new URL("http://myip.dnsomatic.com/");
            BufferedReader b = new BufferedReader(new InputStreamReader(url.openStream()));
            String ip = b.readLine();
            b.close();
            return ip;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "null";
    }
}

 

Edited by Jeune Padawan
Link to comment
Share on other sites

  • 5 months later...
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...