Merge chr name + id wrappers into new CharacterIdentity record
This commit is contained in:
@@ -27,6 +27,7 @@ import constants.id.MapId;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
import model.CharacterIdentity;
|
||||
import net.PacketHandler;
|
||||
import net.PacketProcessor;
|
||||
import net.netty.DisconnectException;
|
||||
@@ -308,8 +309,8 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
public List<Character> loadCharacters(int serverId) {
|
||||
List<Character> chars = new ArrayList<>(15);
|
||||
try {
|
||||
for (CharNameAndId cni : loadCharactersInternal(serverId)) {
|
||||
chars.add(Character.loadCharFromDB(cni.id, this, false));
|
||||
for (CharacterIdentity cni : loadCharactersInternal(serverId)) {
|
||||
chars.add(Character.loadCharFromDB(cni.id(), this, false));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -317,8 +318,8 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
return chars;
|
||||
}
|
||||
|
||||
private List<CharNameAndId> loadCharactersInternal(int worldId) {
|
||||
List<CharNameAndId> chars = new ArrayList<>(15);
|
||||
private List<CharacterIdentity> loadCharactersInternal(int worldId) {
|
||||
List<CharacterIdentity> chars = new ArrayList<>(15);
|
||||
try (Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT id, name FROM characters WHERE accountid = ? AND world = ?")) {
|
||||
ps.setInt(1, this.getAccID());
|
||||
@@ -326,7 +327,7 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
chars.add(new CharNameAndId(rs.getString("name"), rs.getInt("id")));
|
||||
chars.add(new CharacterIdentity(rs.getString("name"), rs.getInt("id")));
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
@@ -1160,18 +1161,6 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
actionsSemaphore.release();
|
||||
}
|
||||
|
||||
private static class CharNameAndId {
|
||||
|
||||
public String name;
|
||||
public int id;
|
||||
|
||||
public CharNameAndId(String name, int id) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkHash(String hash, String type, String password) {
|
||||
try {
|
||||
MessageDigest digester = MessageDigest.getInstance(type);
|
||||
|
||||
Reference in New Issue
Block a user