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;
}