mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-10 09:22:49 +00:00
@@ -1,5 +1,7 @@
|
||||
package com.l2jserver.game.net;
|
||||
|
||||
import com.l2jserver.model.id.AccountID;
|
||||
|
||||
/**
|
||||
* Lineage 2 session with the username and loginserver keys
|
||||
*
|
||||
@@ -7,9 +9,9 @@ package com.l2jserver.game.net;
|
||||
*/
|
||||
public class Lineage2Session {
|
||||
/**
|
||||
* The username
|
||||
* The account ID
|
||||
*/
|
||||
private final String username;
|
||||
private final AccountID accountID;
|
||||
|
||||
/**
|
||||
* The play key, part 1
|
||||
@@ -32,8 +34,8 @@ public class Lineage2Session {
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param username
|
||||
* the username
|
||||
* @param accountID
|
||||
* the account ID
|
||||
* @param playOK1
|
||||
* the play key, part 1
|
||||
* @param playOK2
|
||||
@@ -43,9 +45,9 @@ public class Lineage2Session {
|
||||
* @param loginOK2
|
||||
* the login key, part 2
|
||||
*/
|
||||
public Lineage2Session(String username, int playOK1, int playOK2,
|
||||
public Lineage2Session(AccountID accountID, int playOK1, int playOK2,
|
||||
int loginOK1, int loginOK2) {
|
||||
this.username = username;
|
||||
this.accountID = accountID;
|
||||
this.playKey1 = playOK1;
|
||||
this.playKey2 = playOK2;
|
||||
this.loginKey1 = loginOK1;
|
||||
@@ -53,10 +55,10 @@ public class Lineage2Session {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the username
|
||||
* @return the account ID
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
public AccountID getAccountID() {
|
||||
return accountID;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,6 +10,8 @@ import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.Lineage2Session;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.game.net.packet.server.CharacterEnterWorldPacket;
|
||||
import com.l2jserver.model.id.AccountID;
|
||||
import com.l2jserver.model.id.factory.AccountIDFactory;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.BufferUtils;
|
||||
|
||||
@@ -24,6 +26,7 @@ public class AuthLoginPacket extends AbstractClientPacket {
|
||||
public static final int OPCODE = 0x2b;
|
||||
|
||||
private final CharacterDAO characterDao;
|
||||
private final AccountIDFactory accountIdFactory;
|
||||
|
||||
// packet
|
||||
private String loginName;
|
||||
@@ -33,8 +36,10 @@ public class AuthLoginPacket extends AbstractClientPacket {
|
||||
private int loginKey2;
|
||||
|
||||
@Inject
|
||||
public AuthLoginPacket(CharacterDAO characterDao) {
|
||||
public AuthLoginPacket(CharacterDAO characterDao,
|
||||
AccountIDFactory accountIdFactory) {
|
||||
this.characterDao = characterDao;
|
||||
this.accountIdFactory = accountIdFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,11 +53,11 @@ public class AuthLoginPacket extends AbstractClientPacket {
|
||||
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
conn.setSession(new Lineage2Session(loginName, playKey1, playKey2,
|
||||
final AccountID accountId = accountIdFactory.createID(loginName);
|
||||
conn.setSession(new Lineage2Session(accountId, playKey1, playKey2,
|
||||
loginKey1, loginKey2));
|
||||
|
||||
final List<L2Character> chars = characterDao.selectByAccount(conn
|
||||
.getSession().getUsername());
|
||||
final List<L2Character> chars = characterDao.selectByAccount(accountId);
|
||||
// conn.write(CharacterSelectionListPacket.fromL2Session(
|
||||
// conn.getSession(), chars.toArray(new L2Character[0])));
|
||||
conn.write(new CharacterEnterWorldPacket(chars.get(0), playKey1));
|
||||
|
||||
@@ -35,7 +35,7 @@ public class RequestGotoLobby extends AbstractClientPacket {
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
final List<L2Character> chars = characterDao.selectByAccount(conn
|
||||
.getSession().getUsername());
|
||||
.getSession().getAccountID());
|
||||
conn.write(CharacterSelectionListPacket.fromL2Session(
|
||||
conn.getSession(), chars.toArray(new L2Character[0])));
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class CharacterSelectionListPacket extends AbstractServerPacket {
|
||||
|
||||
public static CharacterSelectionListPacket fromL2Session(
|
||||
Lineage2Session session, L2Character... characters) {
|
||||
return new CharacterSelectionListPacket(session.getUsername(),
|
||||
return new CharacterSelectionListPacket(session.getAccountID().getID(),
|
||||
session.getPlayKey2(), -1, characters);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user