Jump to content

Friends List control


Aeonx

Recommended Posts

Hey, just wrote a few methods to control your friends list so thought to share.

RandomSleep(); // Your sleeping methods

    private void AddFriend(String name) throws InterruptedException
    {
        if(tabs.getOpen() != Tab.FRIENDS)
        {
            tabs.open(Tab.FRIENDS);
            RandomSleep();
        }

        if(IsFriend(name)) return;

        RS2Widget widget = widgets.get(429, 7);
        if(widget == null) return;

        if(widget.isVisible()) widget.interact();
        RandomSleep();

        widget = widgets.get(162, 33);
        if(widget != null && widget.isVisible())
        {
            keyboard.typeString(name);
            keyboard.pressKey(13);
        }
    }

    private boolean RemoveFriend(String name) throws InterruptedException
    {
        if(tabs.getOpen() != Tab.FRIENDS)
        {
            tabs.open(Tab.FRIENDS);
            RandomSleep();
        }

        if(!IsFriend(name)) return false;

        RS2Widget widget = widgets.get(429, 3);
        if(widget == null) return false;

        RS2Widget[] friends;
        if((friends = widget.getChildWidgets()) != null)
        {
            for(RS2Widget w : friends)
            {
                if(w.getMessage().equals(name) && w.isVisible())
                    return w.interact("Delete");
            }
        }

        return false;
    }

    private void MessageFriend(String name, String message) throws InterruptedException
    {
        if(tabs.getOpen() != Tab.FRIENDS)
        {
            tabs.open(Tab.FRIENDS);
            RandomSleep();
        }

        RS2Widget widget = widgets.get(429, 3);
        if(widget == null) return;

        RS2Widget[] friends;
        if((friends = widget.getChildWidgets()) == null)
            return;


        for(RS2Widget w : friends)
        {
            if(w.getMessage().equals(name) && w.isVisible())
                w.interact("Message");
        }
        RandomSleep();


        widget = widgets.get(162, 33);
        if(widget != null && widget.isVisible())
        {
            keyboard.typeString(message);
            keyboard.pressKey(13);
        }
    }

    private boolean IsFriend(String name)
    {
        RS2Widget widget = widgets.get(429, 3);
        if(widget == null) return false;

        RS2Widget[] friends;
        if((friends =  widget.getChildWidgets()) != null)
        {
            for(RS2Widget w : friends)
            {
                if(w.getMessage().equals(name))
                    return true;
            }
        }

        return false;
    }

    private boolean IsFriendOnline(String name)
    {
        if(!IsFriend(name)) return false;

        RS2Widget widget = widgets.get(429, 3);
        if(widget == null) return false;

        RS2Widget[] friends;
        int child = 0;

        if((friends = widget.getChildWidgets()) != null)
        {
            for(RS2Widget w : friends)
            {
                if(w.getMessage().equals(name))
                    return (!friends[child + 1].getMessage().equals("Offline"));

                child++;
            }
        }

        return false;
    }
Edited by Aeonx
  • Like 3
  • Boge 1
Link to comment
Share on other sites

  • 3 months 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...