Thread: Newplayerclient

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Newplayerclient 
    Registered Member
    Join Date
    Aug 2014
    Posts
    259
    Thanks given
    2
    Thanks received
    6
    Rep Power
    11
    https://prnt.sc/gv2f72 << i have this problem.. how to solve this?

    Thank you.
    Owner of ThamenX
    Reply With Quote  
     

  2. #2  
    Donator

    Join Date
    Dec 2014
    Posts
    289
    Thanks given
    160
    Thanks received
    56
    Rep Power
    37
    Basically the newPlayerClient method does not exist... check your source to see if it still exists, if not remove the check for it.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Aug 2014
    Posts
    259
    Thanks given
    2
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by mikey96 View Post
    Basically the newPlayerClient method does not exist... check your source to see if it still exists, if not remove the check for it.
    thanks for the help? you only say that it dont exist? i already knew that lol
    Owner of ThamenX
    Reply With Quote  
     

  4. #4  
    Blurite

    Corey's Avatar
    Join Date
    Feb 2012
    Age
    26
    Posts
    1,491
    Thanks given
    1,245
    Thanks received
    1,729
    Rep Power
    5000
    Quote Originally Posted by blaxe View Post
    thanks for the help? you only say that it dont exist? i already knew that lol
    Make the method then.
    Also use an IDE, makes developing and fixing bugs 100x easier.

    Also, stop being a pos to people who go out their way to help you.
    Attached image
    Reply With Quote  
     

  5. #5  
    Registered Member Kairon's Avatar
    Join Date
    Feb 2017
    Posts
    202
    Thanks given
    54
    Thanks received
    45
    Rep Power
    33
    Quote Originally Posted by blaxe View Post
    thanks for the help? you only say that it dont exist? i already knew that lol
    Then remove the check for it as mikey said.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Aug 2014
    Posts
    259
    Thanks given
    2
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by Tesla View Post
    Make the method then.
    Also use an IDE, makes developing and fixing bugs 100x easier.

    Also, stop being a pos to people who go out their way to help you.
    Ppl say im missing the ''lib folder'', idk how to add that thats problem.
    Owner of ThamenX
    Reply With Quote  
     

  7. #7  
    Blurite

    Corey's Avatar
    Join Date
    Feb 2012
    Age
    26
    Posts
    1,491
    Thanks given
    1,245
    Thanks received
    1,729
    Rep Power
    5000
    Quote Originally Posted by blaxe View Post
    Ppl say im missing the ''lib folder'', idk how to add that thats problem.
    By using an IDE you can add your libraries to the build path easily.

    https://stackoverflow.com/questions/...jar-in-eclipse
    Attached image
    Reply With Quote  
     

  8. #8  
    The One And Only

    01053's Avatar
    Join Date
    Apr 2011
    Age
    28
    Posts
    2,887
    Thanks given
    417
    Thanks received
    885
    Rep Power
    856
    You aren't missing a library lol, please post your RS2LoginProtocolDecoder here in code tags.


    Reply With Quote  
     

  9. #9  
    Registered Member
    Join Date
    Aug 2014
    Posts
    259
    Thanks given
    2
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by 01053 View Post
    You aren't missing a library lol, please post your RS2LoginProtocolDecoder here in code tags.
    package server.net;

    import org.apache.mina.common.ByteBuffer;
    import org.apache.mina.common.IoFuture;
    import org.apache.mina.common.IoFutureListener;
    import org.apache.mina.common.IoSession;
    import org.apache.mina.filter.codec.CumulativeProtocolDec oder;
    import org.apache.mina.filter.codec.ProtocolCodecFilter;
    import org.apache.mina.filter.codec.ProtocolDecoderOutput ;

    import server.Config;
    import server.Connection;
    import server.Server;
    import server.world.map.*;
    import server.model.players.Client;
    import server.model.players.PlayerHandler;
    import server.model.players.PlayerSave;
    import server.util.ISAACRandomGen;

    /**
    * Login protocol decoder.
    * @author Graham
    * @author Ryan / Lmctruck30 <- login Protocol fixes
    *
    */
    @SuppressWarnings("unused")
    public class RS2LoginProtocolDecoder extends CumulativeProtocolDecoder {

    /**
    * Parses the data in the provided byte buffer and writes it to
    * <code>out</code> as a <code>Packet</code>.
    *
    * @param session The IoSession the data was read from
    * @param in The buffer
    * @param out The decoder output stream to which to write the <code>Packet</code>
    * @return Whether enough data was available to create a packet
    */
    @Override
    public boolean doDecode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) {
    synchronized(session) {
    Object loginStageObj = session.getAttribute("LOGIN_STAGE");
    int loginStage = 0;
    if(loginStageObj != null) {
    loginStage = (Integer)loginStageObj;
    }
    //Logger.log("recv login packet, stage: "+loginStage);
    switch(loginStage) {
    case 0:
    if(2 <= in.remaining()) {
    int protocol = in.get() & 0xff;
    int nameHash = in.get() & 0xff;
    if(protocol == 14) {
    long serverSessionKey = ((long) (java.lang.Math.random() * 99999999D) << 32) + (long) (java.lang.Math.random() * 99999999D);
    StaticPacketBuilder s1Response = new StaticPacketBuilder();
    s1Response.setBare(true).addBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }).addByte((byte) 0).addLong(serverSessionKey);
    session.setAttribute("SERVER_SESSION_KEY", serverSessionKey);
    session.write(s1Response.toPacket());
    session.setAttribute("LOGIN_STAGE", 1);
    }
    return true;
    } else {
    in.rewind();
    return false;
    }
    case 1:
    int loginType = -1, loginPacketSize = -1, loginEncryptPacketSize = -1;
    if(2 <= in.remaining()) {
    loginType = in.get() & 0xff; //should be 16 or 18
    loginPacketSize = in.get() & 0xff;
    loginEncryptPacketSize = loginPacketSize-(36+1+1+2);
    if(loginPacketSize <= 0 || loginEncryptPacketSize <= 0) {
    System.out.println("Zero or negative login size.");
    session.close();
    return false;
    }
    } else {
    in.rewind();
    return false;
    }
    if(loginPacketSize <= in.remaining()) {
    int magic = in.get() & 0xff;
    int version = in.getUnsignedShort();
    if(magic != 255) {
    //System.out.println("Wrong magic id.");
    session.close();
    return false;
    }
    if(version != 1) {
    //Dont Add Anything
    }
    int lowMem = in.get() & 0xff;
    for(int i = 0; i < 9; i++) {
    in.getInt();
    }
    loginEncryptPacketSize--;
    if(loginEncryptPacketSize != (in.get() & 0xff)) {
    System.out.println("Encrypted size mismatch.");
    session.close();
    return false;
    }
    if((in.get() & 0xff) != 10) {
    System.out.println("Encrypted id != 10.");
    session.close();
    return false;
    }
    long clientSessionKey = in.getLong();
    long serverSessionKey = in.getLong();
    int uid = in.getInt();

    if(uid == 0 || uid == 99735086) {
    session.close();
    return false;
    }
    if(uid != 123456) {
    session.close();
    return false;
    }

    String name = readRS2String(in);
    String pass = readRS2String(in);
    int sessionKey[] = new int[4];
    sessionKey[0] = (int)(clientSessionKey >> 32);
    sessionKey[1] = (int)clientSessionKey;
    sessionKey[2] = (int)(serverSessionKey >> 32);
    sessionKey[3] = (int)serverSessionKey;
    ISAACRandomGen inC = new ISAACRandomGen(sessionKey);
    for(int i = 0; i < 4; i++) sessionKey[i] += 50;
    ISAACRandomGen outC = new ISAACRandomGen(sessionKey);
    load(session, uid, name, pass, inC, outC, version);
    // WorkerThread.load(session, name, pass, inC, outC);
    session.getFilterChain().remove("protocolFilter");
    session.getFilterChain().addLast("protocolFilter", new ProtocolCodecFilter(new GameCodecFactory(inC)));
    return true;
    } else {
    in.rewind();
    return false;
    }
    }
    }
    return false;
    }

    private synchronized void load(final IoSession session, final int uid, String name, String pass, final ISAACRandomGen inC, ISAACRandomGen outC, int version) {
    session.setAttribute("opcode", -1);
    session.setAttribute("size", -1);
    int loginDelay = 1;
    int returnCode = 2;

    name = name.trim();
    name = name.toLowerCase();
    pass = pass.toLowerCase();

    if(!name.matches("[A-Za-z0-9 ]+")) {
    returnCode = 4;
    }

    if(name.length() > 12) {
    returnCode = 8;
    }

    Client cl = new Client(session, -1);
    cl.playerName = name;
    cl.playerName2 = cl.playerName;
    cl.playerPass = pass;
    cl.setInStreamDecryption(inC);
    cl.setOutStreamDecryption(outC);
    cl.outStream.packetEncryption = outC;

    cl.saveCharacter = false;

    char first = name.charAt(0);
    cl.properName = Character.toUpperCase(first)+ name.substring(1, name.length());

    if(Connection.isNamedBanned(cl.playerName)) {
    returnCode = 4;
    }

    if(PlayerHandler.isPlayerOn(name)) {
    returnCode = 5;
    }

    //if(Config.CLIENT_VERSION != version) {
    // returnCode = 6;
    //}

    if(PlayerHandler.playerCount >= Config.MAX_PLAYERS) {
    returnCode = 7;
    }

    // Login Limit Exceeded
    // if() {
    // returnCode = 9;
    // }

    if(Server.UpdateServer) {
    returnCode = 14;
    }

    // if(Connection.checkLoginList(loginIp)) {
    // returnCode = 16;
    // }

    // Just Left World Login Delay Included
    // if() {
    // returnCode = 21;
    // }

    if(returnCode == 2) {
    int load = PlayerSave.loadGame(cl, cl.playerName, cl.playerPass);
    if (load == 0)
    cl.addStarter = true;
    if(load == 3) {
    returnCode = 3;
    cl.saveFile = false;
    } else {
    for(int i = 0; i < cl.playerEquipment.length; i++) {
    if(cl.playerEquipment[i] == 0) {
    cl.playerEquipment[i] = -1;
    cl.playerEquipmentN[i] = 0;
    }
    }
    if(!Server.playerHandler.newPlayerClient(cl)) {
    returnCode = 7;
    cl.saveFile = false;
    } else {
    cl.saveFile = true;
    }
    }
    }


    cl.packetType = -1;
    cl.packetSize = 0;

    StaticPacketBuilder bldr = new StaticPacketBuilder();
    bldr.setBare(true);
    bldr.addByte((byte) returnCode);
    if(returnCode == 2) {
    cl.saveCharacter = true;
    if(cl.playerRights == 10) {
    bldr.addByte((byte) 2);
    } else {
    bldr.addByte((byte) cl.playerRights);
    }
    } else if(returnCode == 21) {
    bldr.addByte((byte) loginDelay);
    } else {
    bldr.addByte((byte) 0);
    }
    cl.isActive = true;
    bldr.addByte((byte) 0);
    Packet pkt = bldr.toPacket();
    final Client fcl = cl;
    session.setAttachment(cl);
    //I.IOSessionManager(cl, cl.playerName, cl.playerPass, true);
    session.write(pkt).addListener(new IoFutureListener() {
    @Override
    public void operationComplete(IoFuture arg0) {
    session.getFilterChain().remove("protocolFilter");
    session.getFilterChain().addFirst("protocolFilter" , new ProtocolCodecFilter(new GameCodecFactory(inC)));
    }
    });
    }

    private synchronized String readRS2String(ByteBuffer in) {
    StringBuilder sb = new StringBuilder();
    byte b;
    while((b = in.get()) != 10) {
    sb.append((char) b);
    }
    return sb.toString();
    }



    /**
    * Releases the buffer used by the given session.
    *
    * @param session The session for which to release the buffer
    * @throws Exception if failed to dispose all resources
    */
    @Override
    public void dispose(IoSession session) throws Exception {
    super.dispose(session);
    }

    }
    there u go
    Owner of ThamenX
    Reply With Quote  
     

  10. #10  
    Registered Member

    Join Date
    Sep 2016
    Posts
    384
    Thanks given
    1
    Thanks received
    117
    Rep Power
    311
    Quote Originally Posted by blaxe View Post
    there u go
    Man said code tags.
    Reply With Quote  
     

  11. Thankful user:


Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •