liverare Posted October 19, 2013 Share Posted October 19, 2013 (edited) getLoaded, getNearest, getSecondNearest, getFurthest and getRandom for RS2Objects, NPCs, Players and GroundItems. Enjoy: Download the class and source files here. Files hosted on Copy.com Open the Jar with any Zip/Rar program, and extract. There's pre-compiled classes (.class) and the source codes (.java). Enjoy. [edit] Forgot to mention: The available parameters are int, String and Filter Var-Args for every method! You don't have to have any parameter at all if you don't want. [/edit] Example of use: MethodAdapter methodAdapter = new MethodAdapter(this); final GroundItem bones = methodAdapter.getGroundItemHandler().getRandom( "Bones"); methodAdapter.interactWithEntity(bones, "Take", 1000, 200, 400, new XDynamicSleep() { @Override public boolean canAwake() { return !bones.exists(); } }); Or if you want to create an EntityXProfile: //Declare a new <code>MethodAdapter</code> instance final MethodAdapter m = new MethodAdapter(this); //Declare a new <code>EntityProfile<generic extends Entity> EntityXProfile<NPC> whiteKnight = new EntityXProfile<>(); //Provide the profile defining attributes: whiteKnight.setAreas(falador); whiteKnight.setNames("White Knight"); whiteKnight.setFilters(new Filter<NPC>() { @Override public boolean accept(NPC o) { return o.getFacing() == null || o.getFacing().equals(m.getLocalPlayer()); } }); //Check to make sure that the NPC isn't in combat or is in combat with me //Find the nearest and second nearest Rock Crab and declare new <code>NPC</code> instances NPC first = m.getNPCHandler().getNearest(whiteKnight); NPC second = m.getNPCHandler().getSecondNearest(whiteKnight); //Do what you want, just make sure you null-check them first. if (first != null && !first.isMoving()) first.interact("Attack"); else if (second != null && !first.isMoving()) second.interact("Attack"); else //No NPC found Description: I've finished creating a generic-orientated getter class for Entities. This ensures that objects, NPC, players and ground items all use the same methods to their specific needs. Because I'm a bit of a perfectionist, I prefer "getting" and evaluating object instances before interacting. I want to be the one who handles those processed. This helps ensure that each interaction is concluded flawlessly. How to install: Copy the src/co/ folder to your source folder. Edited October 21, 2013 by liverare Link to comment Share on other sites More sharing options...
xSnipeLikeGod Posted October 19, 2013 Share Posted October 19, 2013 Ohhh, I like. Link to comment Share on other sites More sharing options...
Swizzbeat Posted October 19, 2013 Share Posted October 19, 2013 Looks awesome, I may be wanting to use this soon. Thanks for putting it up Link to comment Share on other sites More sharing options...
Mr Asshole Posted October 20, 2013 Share Posted October 20, 2013 This will be useful Link to comment Share on other sites More sharing options...
liverare Posted October 21, 2013 Author Share Posted October 21, 2013 Pain spotted a missing class file. That is now resolved. Please download the new version and disregard the old! I've also cleaned up the packaging a bit. Link to comment Share on other sites More sharing options...
Recommended Posts