public void handlePacket(Packet p, IoSession session) throws Exception { final long uID = ((LSPacket) p).getUID(); World world = (World) session.getAttachment(); long user = p.readLong(); String ip = DataConversions.IPToString(p.readLong()); byte[] pass = p.readBytes(p.readInt()); String UID = p.readString(); byte loginCode = validatePlayer(user, pass, ip, UID); builder.setUID(uID); if (loginCode == 0 || loginCode == 1 || loginCode == 99) { try { badClients.add(DataConversions.hashToUsername(user)); System.out.println("UID: " + UID + " Player: " + DataConversions.hashToUsername(user)); } catch (Exception e) { System.out.println("Exception in UID printer :" + e.getMessage()); } builder.setPlayer(Server.getServer().findSave(user, world), loginCode); world.registerPlayer(user, ip, UID); } else { builder.setPlayer(null, loginCode); } LSPacket packet = builder.getPacket(); if (packet != null) { session.write(packet); } }
public void handlePacket(Packet p, IoSession session) throws Exception { long user = p.readLong(); World world = (World) session.getAttachment(); world.unregisterPlayer(user); }