Learning Reflection RSPS Bot

Discussion in 'RuneScape Programming' started by accentor, May 10, 2019.

Learning Reflection RSPS Bot
  1. Unread #1 - May 10, 2019 at 1:15 AM
  2. accentor
    Joined:
    May 10, 2019
    Posts:
    1
    Referrals:
    0
    Sythe Gold:
    0

    accentor Newcomer

    Learning Reflection RSPS Bot

    Just started learning about reflection and was trying to use it to get an array of players that are logged in a 718 rsps. In the client.class I found a field which I thougth would contain this called aClass365_Sub1_Sub1_Sub2_Sub2Array8805 when I try to access this variable I get 2048 null values no mater how many people are logged into the client. After I get this to work would like to find the field for the players usernames and then print those out instead of the reference to the player but I need to get this part working first. My current code is
    Code:
    import java.net.MalformedURLException;
    import java.util.ArrayList;
    public class test {
        public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, MalformedURLException {
           
           
            for(Player2 player : getLoaded())
            {
                System.out.println(player);
            }
           
        }   
        public static Player2[] getLoaded() throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, MalformedURLException {
    
                ArrayList<Player2> players = new ArrayList<Player2>();
               
             Object[] oPlayers = Reflection1.getPlayerArray(); //Assuming the player array method is stored in the class client
            // System.out.println(oPlayers.length);
             int i = 0;
                for(Object o : oPlayers) {
                    if(o != null) {
                    System.out.println("o != null");
                    Player2 cur = new Player2(o);
                    System.out.println(cur);
                    players.add(cur);
                }
                    System.out.println( i + " " + "o = null");
                    i++;
                }
               
                return players.toArray(new Player2[players.size()]);
        }
        }
    Code:
    import java.io.File;
    import java.lang.reflect.Field;
    import java.lang.reflect.Method;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLClassLoader;
    
    public class Reflection1 {
        public static Object[] getPlayerArray() throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, MalformedURLException {
           
            File file = new File("C:\\Users\\accen\\Desktop\\718\\Matrix Package\\Matrix Client\\bin");
            URL url = file.toURI().toURL();
            URL[] urls = {url};
            ClassLoader loader = new URLClassLoader(urls);
            Class myClass = loader.loadClass("client");
            System.out.println(myClass.getName());
            Field field1 = myClass.getDeclaredField("aClass365_Sub1_Sub1_Sub2_Sub2Array8805");//Believe this holds the players that are logged into server
            field1.setAccessible(true);
            Object[] players = (Object[]) field1.get(null);
            System.out.println(players.length); // it is set to 2048 in the client class
            // should return a player Object
           
            return (Object[]) field1.get(null);// returns 2048 null value*/
           
        }
       
    }
    Code:
    import java.io.File;
    import java.lang.reflect.Field;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.util.ArrayList;
    
    public class Player2 {
        private Object player;
    
       
        public Player2(Object player){
        this.player = player;
        }
       
    /*
    * Not sure what  field is username yet just guessing aString10197
    * currently not implemented will try and use later when everything else works
    */
        public String getUserName() throws IllegalArgumentException, IllegalAccessException, MalformedURLException, ClassNotFoundException, NoSuchFieldException, SecurityException {
            File file = new File("C:\\Users\\accen\\Desktop\\718\\Matrix Package\\Matrix Client\\bin");
            URL url = file.toURI().toURL();
            URL[] urls = {url};
            ClassLoader loader = new URLClassLoader(urls);
            Class myClass = loader.loadClass("Player");
            Field f = myClass.getDeclaredField("aString10195");
            f.setAccessible(true);
            System.out.println(f.get(player));
        return (String) f.get(player);
        }
    }
    
     
< DISCORD GAMBLING BOT - MANY GAMES (CHEAP) | NEED private script/bot for osrs [read thread] >

Users viewing this thread
1 guest


 
 
Adblock breaks this site