Aeonx Posted June 13, 2016 Posted June 13, 2016 (edited) 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 June 14, 2016 by Aeonx 3 1
Aeonx Posted June 13, 2016 Author Posted June 13, 2016 Great code! Might be using this in the future. Thanks! I'm adding Remove friend later as well ;)
Aeonx Posted June 13, 2016 Author Posted June 13, 2016 Ok I rewrote the whole API as previous one was pretty much a dev. version. Added Remove Friend method and pretty much fixed all the possible bugs and so it's reliable. Enjoy