Project cleanup pre merge.

This commit is contained in:
2023-07-15 09:23:48 -04:00
parent 134b651df8
commit 9bbdef224d
747 changed files with 99704 additions and 101200 deletions
+83 -82
View File
@@ -19,105 +19,106 @@ import java.net.InetAddress;
public class CSSession extends AbstractGameObject {
private String sessionID;
private PlayerCharacter playerCharacter;
private Account account;
private String sessionID;
private PlayerCharacter playerCharacter;
private Account account;
private String machineID;
private String machineID;
public CSSession(String sessionID, Account acc, PlayerCharacter pc, String machineID) {
super();
this.sessionID = sessionID;
this.playerCharacter = pc;
this.account = acc;
this.machineID = machineID;
public CSSession(String sessionID, Account acc, PlayerCharacter pc, String machineID) {
super();
this.sessionID = sessionID;
this.playerCharacter = pc;
this.account = acc;
this.machineID = machineID;
if (this.playerCharacter != null)
PlayerCharacter.initializePlayer(this.playerCharacter);
}
if (this.playerCharacter != null)
PlayerCharacter.initializePlayer(this.playerCharacter);
}
public PlayerCharacter getPlayerCharacter() {
return this.playerCharacter;
}
/*
* Database
*/
public static boolean addCrossServerSession(String secKey, Account acc, InetAddress inet, String machineID) {
return DbManager.CSSessionQueries.ADD_CSSESSION(secKey, acc, inet, machineID);
// PreparedStatementShared ps = null;
// try {
// ps = prepareStatement("INSERT INTO sessions (secretKey, accountID, vbID, sessionIP) VALUES (?,?,?,INET_ATON(?))");
// ps.setString(1, secKey);
// ps.setInt(2, acc.getUUID(), true);
// ps.setInt(3, acc.getVBID());
// ps.setString(4, StringUtils.InetAddressToClientString(inet));
// if (ps.executeUpdate() > 0)
// return true;
// } catch (SQLException e) {
// Logger.error("CSSession", "Failed to create cross server session");
// } finally {
// ps.release();
// }
// return false;
}
public void setPlayerCharacter(PlayerCharacter pc) {
this.playerCharacter = pc;
}
public static boolean deleteCrossServerSession(String secKey) {
return DbManager.CSSessionQueries.DELETE_CSSESSION(secKey);
// PreparedStatementShared ps = null;
// try {
// ps = prepareStatement("DELETE FROM sessions WHERE secretKey = ?");
// ps.setString(1, secKey);
// if (ps.executeUpdate() > 0)
// return true;
// } catch (SQLException e) {
// Logger.error("CSSession", "Failed to delete cross server session");
// } finally {
// ps.release();
// }
// return false;
}
public Account getAccount() {
return this.account;
}
public static boolean updateCrossServerSession(String secKey, int charID) {
return DbManager.CSSessionQueries.UPDATE_CSSESSION(secKey, charID);
}
public void setAccount(Account acc) {
this.account = acc;
}
public static CSSession getCrossServerSession(String secKey) {
@Override
public void removeFromCache() {}
CSSession sessionInfo;
/*
* Database
*/
public static boolean addCrossServerSession(String secKey, Account acc, InetAddress inet, String machineID) {
return DbManager.CSSessionQueries.ADD_CSSESSION(secKey, acc, inet, machineID);
// PreparedStatementShared ps = null;
// try {
// ps = prepareStatement("INSERT INTO sessions (secretKey, accountID, vbID, sessionIP) VALUES (?,?,?,INET_ATON(?))");
// ps.setString(1, secKey);
// ps.setInt(2, acc.getUUID(), true);
// ps.setInt(3, acc.getVBID());
// ps.setString(4, StringUtils.InetAddressToClientString(inet));
// if (ps.executeUpdate() > 0)
// return true;
// } catch (SQLException e) {
// Logger.error("CSSession", "Failed to create cross server session");
// } finally {
// ps.release();
// }
// return false;
}
try {
sessionInfo = DbManager.CSSessionQueries.GET_CSSESSION(secKey);
} catch (Exception e) {
sessionInfo = null;
}
public static boolean deleteCrossServerSession(String secKey) {
return DbManager.CSSessionQueries.DELETE_CSSESSION(secKey);
// PreparedStatementShared ps = null;
// try {
// ps = prepareStatement("DELETE FROM sessions WHERE secretKey = ?");
// ps.setString(1, secKey);
// if (ps.executeUpdate() > 0)
// return true;
// } catch (SQLException e) {
// Logger.error("CSSession", "Failed to delete cross server session");
// } finally {
// ps.release();
// }
// return false;
}
return sessionInfo;
}
public static boolean updateCrossServerSession(String secKey, int charID) {
return DbManager.CSSessionQueries.UPDATE_CSSESSION(secKey, charID);
}
public PlayerCharacter getPlayerCharacter() {
return this.playerCharacter;
}
public static CSSession getCrossServerSession(String secKey) {
public void setPlayerCharacter(PlayerCharacter pc) {
this.playerCharacter = pc;
}
CSSession sessionInfo;
public Account getAccount() {
return this.account;
}
try {
sessionInfo = DbManager.CSSessionQueries.GET_CSSESSION(secKey);
} catch (Exception e) {
sessionInfo = null;
}
public void setAccount(Account acc) {
this.account = acc;
}
return sessionInfo;
}
@Override
public void removeFromCache() {
}
public String getMachineID() {
return machineID;
}
public String getMachineID() {
return machineID;
}
@Override
public void updateDatabase() {
// TODO Auto-generated method stub
@Override
public void updateDatabase() {
// TODO Auto-generated method stub
}
}
}
+40 -40
View File
@@ -7,7 +7,7 @@
// www.magicbane.com
package engine.session;
package engine.session;
import engine.Enum;
import engine.gameManager.DbManager;
@@ -18,54 +18,54 @@ import engine.objects.PlayerCharacter;
public class Session {
private SessionID sessionID;
private PlayerCharacter playerCharacter;
private Account account;
private ClientConnection conn;
private SessionID sessionID;
private PlayerCharacter playerCharacter;
private Account account;
private ClientConnection conn;
public Session(SessionID sessionID, Account acc, ClientConnection conn) {
super();
this.sessionID = sessionID;
this.playerCharacter = null;
this.account = acc;
this.conn = conn;
}
public Session(SessionID sessionID, Account acc, ClientConnection conn) {
super();
this.sessionID = sessionID;
this.playerCharacter = null;
this.account = acc;
this.conn = conn;
}
public PlayerCharacter getPlayerCharacter() {
if (this.playerCharacter != null) {
public PlayerCharacter getPlayerCharacter() {
if (this.playerCharacter != null) {
if (DbManager.inCache(Enum.GameObjectType.PlayerCharacter, this.playerCharacter.getObjectUUID()))
this.playerCharacter = (PlayerCharacter) DbManager.getFromCache(Enum.GameObjectType.PlayerCharacter, this.playerCharacter.getObjectUUID());
}
return this.playerCharacter;
}
if (DbManager.inCache(Enum.GameObjectType.PlayerCharacter, this.playerCharacter.getObjectUUID()))
this.playerCharacter = (PlayerCharacter) DbManager.getFromCache(Enum.GameObjectType.PlayerCharacter, this.playerCharacter.getObjectUUID());
}
return this.playerCharacter;
}
public void setPlayerCharacter(PlayerCharacter pc) {
this.playerCharacter = pc;
}
public void setPlayerCharacter(PlayerCharacter pc) {
this.playerCharacter = pc;
}
public SessionID getSessionID() {
return this.sessionID;
}
public SessionID getSessionID() {
return this.sessionID;
}
public void setSessionID(SessionID sessionID) {
this.sessionID = sessionID;
}
public void setSessionID(SessionID sessionID) {
this.sessionID = sessionID;
}
public Account getAccount() {
return this.account;
}
public Account getAccount() {
return this.account;
}
public void setAccount(Account acc) {
this.account = acc;
}
public void setAccount(Account acc) {
this.account = acc;
}
public ClientConnection getConn() {
return this.conn;
}
public ClientConnection getConn() {
return this.conn;
}
public void setConn(ClientConnection conn) {
this.conn = conn;
}
public void setConn(ClientConnection conn) {
this.conn = conn;
}
}
+29 -29
View File
@@ -13,38 +13,38 @@ import engine.util.ByteUtils;
public class SessionID {
private final byte[] data;
private final String dataAsString;
private final byte[] data;
private final String dataAsString;
public SessionID(byte[] data) {
super();
this.data = data;
this.dataAsString = ByteUtils.byteArrayToStringHex(data);
}
public SessionID(byte[] data) {
super();
this.data = data;
this.dataAsString = ByteUtils.byteArrayToStringHex(data);
}
@Override
public boolean equals(Object obj) {
boolean out = false;
if(obj instanceof SessionID) {
out = true;
SessionID id = (SessionID) obj;
for (int i = 0; out && i < id.data.length; ++i) {
if (id.data[i] != this.data[i]) {
out = false;
}
}
}
return out;
}
@Override
public boolean equals(Object obj) {
boolean out = false;
if (obj instanceof SessionID) {
out = true;
SessionID id = (SessionID) obj;
for (int i = 0; out && i < id.data.length; ++i) {
if (id.data[i] != this.data[i]) {
out = false;
}
}
}
@Override
public String toString() {
return this.dataAsString;
}
return out;
}
public final byte[] getData() {
return data;
}
@Override
public String toString() {
return this.dataAsString;
}
public final byte[] getData() {
return data;
}
}