Project cleanup pre merge.
This commit is contained in:
@@ -25,360 +25,358 @@ import static engine.Enum.RecordEventType;
|
||||
|
||||
public class BaneRecord extends DataRecord {
|
||||
|
||||
private static final LinkedBlockingQueue<BaneRecord> recordPool = new LinkedBlockingQueue<>();
|
||||
private RecordEventType eventType;
|
||||
private String cityHash;
|
||||
private String cityName;
|
||||
private String cityGuildHash;
|
||||
private String cityNationHash;
|
||||
private String baneDropperHash;
|
||||
private String baneGuildHash;
|
||||
private String baneNationHash;
|
||||
private DateTime baneLiveTime;
|
||||
private DateTime baneDropTime;
|
||||
private static final LinkedBlockingQueue<BaneRecord> recordPool = new LinkedBlockingQueue<>();
|
||||
private RecordEventType eventType;
|
||||
private String cityHash;
|
||||
private String cityName;
|
||||
private String cityGuildHash;
|
||||
private String cityNationHash;
|
||||
private String baneDropperHash;
|
||||
private String baneGuildHash;
|
||||
private String baneNationHash;
|
||||
private DateTime baneLiveTime;
|
||||
private DateTime baneDropTime;
|
||||
|
||||
private BaneRecord(Bane bane) {
|
||||
this.recordType = Enum.DataRecordType.BANE;
|
||||
this.eventType = RecordEventType.PENDING;
|
||||
}
|
||||
private BaneRecord(Bane bane) {
|
||||
this.recordType = Enum.DataRecordType.BANE;
|
||||
this.eventType = RecordEventType.PENDING;
|
||||
}
|
||||
|
||||
public static BaneRecord borrow(Bane bane, RecordEventType eventType) {
|
||||
BaneRecord baneRecord;
|
||||
public static BaneRecord borrow(Bane bane, RecordEventType eventType) {
|
||||
BaneRecord baneRecord;
|
||||
|
||||
baneRecord = recordPool.poll();
|
||||
baneRecord = recordPool.poll();
|
||||
|
||||
if (baneRecord == null) {
|
||||
baneRecord = new BaneRecord(bane);
|
||||
baneRecord.eventType = eventType;
|
||||
}
|
||||
else {
|
||||
baneRecord.recordType = Enum.DataRecordType.BANE;
|
||||
baneRecord.eventType = eventType;
|
||||
if (baneRecord == null) {
|
||||
baneRecord = new BaneRecord(bane);
|
||||
baneRecord.eventType = eventType;
|
||||
} else {
|
||||
baneRecord.recordType = Enum.DataRecordType.BANE;
|
||||
baneRecord.eventType = eventType;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
baneRecord.cityHash = bane.getCity().getHash();
|
||||
baneRecord.cityName = bane.getCity().getCityName();
|
||||
baneRecord.cityGuildHash = bane.getCity().getGuild().getHash();
|
||||
baneRecord.cityNationHash = bane.getCity().getGuild().getNation().getHash();
|
||||
baneRecord.cityHash = bane.getCity().getHash();
|
||||
baneRecord.cityName = bane.getCity().getCityName();
|
||||
baneRecord.cityGuildHash = bane.getCity().getGuild().getHash();
|
||||
baneRecord.cityNationHash = bane.getCity().getGuild().getNation().getHash();
|
||||
|
||||
|
||||
if (bane.getOwner() == null) {
|
||||
baneRecord.baneDropperHash = "ERRANT";
|
||||
baneRecord.baneGuildHash = "ERRANT";
|
||||
baneRecord.baneNationHash = "ERRANT";
|
||||
}
|
||||
else {
|
||||
baneRecord.baneDropperHash = DataWarehouse.hasher.encrypt(bane.getOwner().getObjectUUID()); // getPlayerCharacter didn't check hash first? OMFG
|
||||
if (bane.getOwner() == null) {
|
||||
baneRecord.baneDropperHash = "ERRANT";
|
||||
baneRecord.baneGuildHash = "ERRANT";
|
||||
baneRecord.baneNationHash = "ERRANT";
|
||||
} else {
|
||||
baneRecord.baneDropperHash = DataWarehouse.hasher.encrypt(bane.getOwner().getObjectUUID()); // getPlayerCharacter didn't check hash first? OMFG
|
||||
|
||||
|
||||
baneRecord.baneGuildHash = bane.getOwner().getGuild().getHash();
|
||||
baneRecord.baneNationHash = bane.getOwner().getGuild().getNation().getHash();
|
||||
baneRecord.baneGuildHash = bane.getOwner().getGuild().getHash();
|
||||
baneRecord.baneNationHash = bane.getOwner().getGuild().getNation().getHash();
|
||||
|
||||
|
||||
baneRecord.baneLiveTime = bane.getLiveDate();
|
||||
baneRecord.baneDropTime = bane.getPlacementDate();
|
||||
}
|
||||
baneRecord.baneLiveTime = bane.getLiveDate();
|
||||
baneRecord.baneDropTime = bane.getPlacementDate();
|
||||
}
|
||||
|
||||
|
||||
return baneRecord;
|
||||
}
|
||||
return baneRecord;
|
||||
}
|
||||
|
||||
public static PreparedStatement buildBanePushStatement(Connection connection, ResultSet rs) throws SQLException {
|
||||
public static PreparedStatement buildBanePushStatement(Connection connection, ResultSet rs) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_banehistory` (`event_number`, `city_id`, `city_name`, `char_id`, `offGuild_id`, `offNat_id`, `defGuild_id`, `defNat_id`, `dropDatetime`, `liveDateTime`, `resolution`) VALUES(?,?,?,?,?,?,?,?,?,?,?)";
|
||||
java.util.Date sqlDateTime;
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_banehistory` (`event_number`, `city_id`, `city_name`, `char_id`, `offGuild_id`, `offNat_id`, `defGuild_id`, `defNat_id`, `dropDatetime`, `liveDateTime`, `resolution`) VALUES(?,?,?,?,?,?,?,?,?,?,?)";
|
||||
java.util.Date sqlDateTime;
|
||||
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
|
||||
// Bind record data
|
||||
// Bind record data
|
||||
|
||||
outStatement.setInt(1, rs.getInt("event_number"));
|
||||
outStatement.setString(2, rs.getString("city_id"));
|
||||
outStatement.setString(3, rs.getString("city_name"));
|
||||
outStatement.setString(4, rs.getString("char_id"));
|
||||
outStatement.setString(5, rs.getString("offGuild_id"));
|
||||
outStatement.setString(6, rs.getString("offNat_id"));
|
||||
outStatement.setString(7, rs.getString("defGuild_id"));
|
||||
outStatement.setString(8, rs.getString("defNat_id"));
|
||||
outStatement.setInt(1, rs.getInt("event_number"));
|
||||
outStatement.setString(2, rs.getString("city_id"));
|
||||
outStatement.setString(3, rs.getString("city_name"));
|
||||
outStatement.setString(4, rs.getString("char_id"));
|
||||
outStatement.setString(5, rs.getString("offGuild_id"));
|
||||
outStatement.setString(6, rs.getString("offNat_id"));
|
||||
outStatement.setString(7, rs.getString("defGuild_id"));
|
||||
outStatement.setString(8, rs.getString("defNat_id"));
|
||||
|
||||
sqlDateTime = rs.getTimestamp("dropDatetime");
|
||||
sqlDateTime = rs.getTimestamp("dropDatetime");
|
||||
|
||||
if (sqlDateTime == null)
|
||||
outStatement.setNull(9, Types.DATE);
|
||||
else
|
||||
outStatement.setTimestamp(9, rs.getTimestamp("dropDatetime"));
|
||||
if (sqlDateTime == null)
|
||||
outStatement.setNull(9, Types.DATE);
|
||||
else
|
||||
outStatement.setTimestamp(9, rs.getTimestamp("dropDatetime"));
|
||||
|
||||
sqlDateTime = rs.getTimestamp("dropDatetime");
|
||||
sqlDateTime = rs.getTimestamp("dropDatetime");
|
||||
|
||||
if (sqlDateTime == null)
|
||||
outStatement.setNull(10, Types.DATE);
|
||||
else
|
||||
outStatement.setTimestamp(10, rs.getTimestamp("liveDateTime"));
|
||||
if (sqlDateTime == null)
|
||||
outStatement.setNull(10, Types.DATE);
|
||||
else
|
||||
outStatement.setTimestamp(10, rs.getTimestamp("liveDateTime"));
|
||||
|
||||
outStatement.setString(11, rs.getString("resolution"));
|
||||
outStatement.setString(11, rs.getString("resolution"));
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
public static PreparedStatement buildBaneQueryStatement(Connection connection) throws SQLException {
|
||||
public static PreparedStatement buildBaneQueryStatement(Connection connection) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "SELECT * FROM `warehouse_banehistory` WHERE `event_number` > ?";
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setInt(1, WarehousePushThread.baneIndex);
|
||||
return outStatement;
|
||||
}
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "SELECT * FROM `warehouse_banehistory` WHERE `event_number` > ?";
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setInt(1, WarehousePushThread.baneIndex);
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
public static DateTime getLastBaneDateTime(City city) {
|
||||
public static DateTime getLastBaneDateTime(City city) {
|
||||
|
||||
DateTime outDateTime = null;
|
||||
DateTime outDateTime = null;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildDateTimeQueryStatement(connection, city);
|
||||
ResultSet rs = statement.executeQuery()) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildDateTimeQueryStatement(connection, city);
|
||||
ResultSet rs = statement.executeQuery()) {
|
||||
|
||||
while (rs.next()) {
|
||||
while (rs.next()) {
|
||||
|
||||
outDateTime = new DateTime(rs.getTimestamp("endDatetime"));
|
||||
outDateTime = new DateTime(rs.getTimestamp("endDatetime"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
|
||||
return outDateTime;
|
||||
}
|
||||
return outDateTime;
|
||||
}
|
||||
|
||||
|
||||
private static PreparedStatement buildDateTimeQueryStatement (Connection connection, City city) throws SQLException {
|
||||
PreparedStatement outStatement;
|
||||
String queryString = "SELECT `endDatetime` FROM `warehouse_banehistory` WHERE `city_id` = ? ORDER BY `endDatetime` DESC LIMIT 1";
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setString(1, city.getHash());
|
||||
return outStatement;
|
||||
private static PreparedStatement buildDateTimeQueryStatement(Connection connection, City city) throws SQLException {
|
||||
PreparedStatement outStatement;
|
||||
String queryString = "SELECT `endDatetime` FROM `warehouse_banehistory` WHERE `city_id` = ? ORDER BY `endDatetime` DESC LIMIT 1";
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setString(1, city.getHash());
|
||||
return outStatement;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateLiveDate(Bane bane, DateTime dateTime) {
|
||||
public static void updateLiveDate(Bane bane, DateTime dateTime) {
|
||||
|
||||
if (bane == null)
|
||||
return;
|
||||
if (bane == null)
|
||||
return;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildUpdateLiveDateStatement(connection, bane, dateTime)) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildUpdateLiveDateStatement(connection, bane, dateTime)) {
|
||||
|
||||
statement.execute();
|
||||
statement.execute();
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static PreparedStatement buildUpdateLiveDateStatement(Connection connection, Bane bane, DateTime dateTime) throws SQLException {
|
||||
private static PreparedStatement buildUpdateLiveDateStatement(Connection connection, Bane bane, DateTime dateTime) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "UPDATE `warehouse_banehistory` SET `liveDatetime` = ?, `dirty` = 1 WHERE `city_id` = ? AND `resolution` = 'PENDING'";
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "UPDATE `warehouse_banehistory` SET `liveDatetime` = ?, `dirty` = 1 WHERE `city_id` = ? AND `resolution` = 'PENDING'";
|
||||
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setTimestamp(1, new java.sql.Timestamp(dateTime.getMillis()));
|
||||
outStatement.setString(2, bane.getCity().getHash());
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setTimestamp(1, new java.sql.Timestamp(dateTime.getMillis()));
|
||||
outStatement.setString(2, bane.getCity().getHash());
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
private static PreparedStatement buildUpdateResolutionStatement(Connection connection, Bane bane, RecordEventType eventType) throws SQLException {
|
||||
private static PreparedStatement buildUpdateResolutionStatement(Connection connection, Bane bane, RecordEventType eventType) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "UPDATE `warehouse_banehistory` SET `endDatetime` = ?, `resolution` = ?, `dirty` = 1 WHERE `city_id` = ? AND `resolution` = 'PENDING'";
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "UPDATE `warehouse_banehistory` SET `endDatetime` = ?, `resolution` = ?, `dirty` = 1 WHERE `city_id` = ? AND `resolution` = 'PENDING'";
|
||||
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setTimestamp(1, Timestamp.valueOf(LocalDateTime.now()));
|
||||
outStatement.setString(2, eventType.name());
|
||||
outStatement.setString(3, bane.getCity().getHash());
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setTimestamp(1, Timestamp.valueOf(LocalDateTime.now()));
|
||||
outStatement.setString(2, eventType.name());
|
||||
outStatement.setString(3, bane.getCity().getHash());
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
public static void updateResolution(Bane bane, RecordEventType eventType) {
|
||||
public static void updateResolution(Bane bane, RecordEventType eventType) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildUpdateResolutionStatement(connection, bane, eventType)) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildUpdateResolutionStatement(connection, bane, eventType)) {
|
||||
|
||||
statement.execute();
|
||||
statement.execute();
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static String getBaneHistoryString() {
|
||||
public static String getBaneHistoryString() {
|
||||
|
||||
String outString;
|
||||
String queryString;
|
||||
String dividerString;
|
||||
String newLine = System.getProperty("line.separator");
|
||||
outString = "[LUA_BANES() DATA WAREHOUSE]" + newLine;
|
||||
dividerString = "--------------------------------" + newLine;
|
||||
queryString = "CALL `baneHistory`()";
|
||||
String outString;
|
||||
String queryString;
|
||||
String dividerString;
|
||||
String newLine = System.getProperty("line.separator");
|
||||
outString = "[LUA_BANES() DATA WAREHOUSE]" + newLine;
|
||||
dividerString = "--------------------------------" + newLine;
|
||||
queryString = "CALL `baneHistory`()";
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = connection.prepareCall(queryString);
|
||||
ResultSet rs = statement.executeQuery()) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = connection.prepareCall(queryString);
|
||||
ResultSet rs = statement.executeQuery()) {
|
||||
|
||||
while (rs.next()) {
|
||||
while (rs.next()) {
|
||||
|
||||
outString += "Magicbane unresolved banes: " + rs.getInt("PENDING") + '/' + rs.getInt("TOTAL") + newLine;
|
||||
outString += dividerString;
|
||||
outString += "Bane Resolution History" + newLine;
|
||||
outString += dividerString;
|
||||
outString += "Magicbane unresolved banes: " + rs.getInt("PENDING") + '/' + rs.getInt("TOTAL") + newLine;
|
||||
outString += dividerString;
|
||||
outString += "Bane Resolution History" + newLine;
|
||||
outString += dividerString;
|
||||
|
||||
outString += "Destruction: " + rs.getInt("DESTROY") + newLine;
|
||||
outString += "Capture: " + rs.getInt("CAPTURE") + newLine;
|
||||
outString += "Defended: " + rs.getInt("DEFEND") + newLine;
|
||||
}
|
||||
outString += "Destruction: " + rs.getInt("DESTROY") + newLine;
|
||||
outString += "Capture: " + rs.getInt("CAPTURE") + newLine;
|
||||
outString += "Defended: " + rs.getInt("DEFEND") + newLine;
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return outString;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return outString;
|
||||
}
|
||||
|
||||
public static void updateDirtyRecords() {
|
||||
public static void updateDirtyRecords() {
|
||||
|
||||
String queryString = "SELECT * FROM `warehouse_banehistory` where `dirty` = 1";
|
||||
String queryString = "SELECT * FROM `warehouse_banehistory` where `dirty` = 1";
|
||||
|
||||
// Reset character delta
|
||||
// Reset character delta
|
||||
|
||||
WarehousePushThread.baneDelta = 0;
|
||||
WarehousePushThread.baneDelta = 0;
|
||||
|
||||
try (Connection localConnection = DbManager.getConnection();
|
||||
PreparedStatement statement = localConnection.prepareStatement(queryString, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); // Make this an updatable result set as we'll reset the dirty flag as we go along
|
||||
ResultSet rs = statement.executeQuery()) {
|
||||
try (Connection localConnection = DbManager.getConnection();
|
||||
PreparedStatement statement = localConnection.prepareStatement(queryString, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); // Make this an updatable result set as we'll reset the dirty flag as we go along
|
||||
ResultSet rs = statement.executeQuery()) {
|
||||
|
||||
while (rs.next()) {
|
||||
while (rs.next()) {
|
||||
|
||||
// Only update the index and dirty flag
|
||||
// if the remote database update succeeded
|
||||
// Only update the index and dirty flag
|
||||
// if the remote database update succeeded
|
||||
|
||||
if (updateDirtyRecord(rs) == true)
|
||||
WarehousePushThread.baneDelta++;
|
||||
else
|
||||
continue;
|
||||
if (updateDirtyRecord(rs) == true)
|
||||
WarehousePushThread.baneDelta++;
|
||||
else
|
||||
continue;
|
||||
|
||||
// Reset the dirty flag in the local database
|
||||
// Reset the dirty flag in the local database
|
||||
|
||||
rs.updateInt("dirty", 0);
|
||||
rs.updateRow();
|
||||
}
|
||||
rs.updateInt("dirty", 0);
|
||||
rs.updateRow();
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error( e.toString());
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean updateDirtyRecord(ResultSet rs) {
|
||||
private static boolean updateDirtyRecord(ResultSet rs) {
|
||||
|
||||
try (Connection remoteConnection = DataWarehouse.remoteConnectionPool.getConnection();
|
||||
PreparedStatement statement = buildUpdateDirtyStatement(remoteConnection, rs)) {
|
||||
try (Connection remoteConnection = DataWarehouse.remoteConnectionPool.getConnection();
|
||||
PreparedStatement statement = buildUpdateDirtyStatement(remoteConnection, rs)) {
|
||||
|
||||
statement.execute();
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
Logger.error( e.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
statement.execute();
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static PreparedStatement buildUpdateDirtyStatement(Connection connection, ResultSet rs) throws SQLException {
|
||||
private static PreparedStatement buildUpdateDirtyStatement(Connection connection, ResultSet rs) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement;
|
||||
String queryString = "UPDATE `warehouse_banehistory` SET `liveDateTime` = ?, `endDateTime` = ?, `resolution` = ? WHERE `event_number` = ?";
|
||||
java.util.Date sqlDateTime;
|
||||
PreparedStatement outStatement;
|
||||
String queryString = "UPDATE `warehouse_banehistory` SET `liveDateTime` = ?, `endDateTime` = ?, `resolution` = ? WHERE `event_number` = ?";
|
||||
java.util.Date sqlDateTime;
|
||||
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
|
||||
// Bind record data
|
||||
// Bind record data
|
||||
|
||||
sqlDateTime = rs.getTimestamp("liveDateTime");
|
||||
sqlDateTime = rs.getTimestamp("liveDateTime");
|
||||
|
||||
if (sqlDateTime == null)
|
||||
outStatement.setNull(1, Types.DATE);
|
||||
else
|
||||
outStatement.setTimestamp(1, rs.getTimestamp("liveDateTime"));
|
||||
if (sqlDateTime == null)
|
||||
outStatement.setNull(1, Types.DATE);
|
||||
else
|
||||
outStatement.setTimestamp(1, rs.getTimestamp("liveDateTime"));
|
||||
|
||||
sqlDateTime = rs.getTimestamp("endDateTime");
|
||||
sqlDateTime = rs.getTimestamp("endDateTime");
|
||||
|
||||
if (sqlDateTime == null)
|
||||
outStatement.setNull(2, Types.DATE);
|
||||
else
|
||||
outStatement.setTimestamp(2, rs.getTimestamp("endDateTime"));
|
||||
if (sqlDateTime == null)
|
||||
outStatement.setNull(2, Types.DATE);
|
||||
else
|
||||
outStatement.setTimestamp(2, rs.getTimestamp("endDateTime"));
|
||||
|
||||
outStatement.setString(3, rs.getString("resolution"));
|
||||
outStatement.setInt(4, rs.getInt("event_number"));
|
||||
outStatement.setString(3, rs.getString("resolution"));
|
||||
outStatement.setInt(4, rs.getInt("event_number"));
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
this.cityHash = null;
|
||||
this.cityGuildHash = null;
|
||||
this.cityNationHash = null;
|
||||
this.baneDropperHash = null;
|
||||
this.baneGuildHash = null;
|
||||
this.baneNationHash = null;
|
||||
this.baneLiveTime = null;
|
||||
}
|
||||
void reset() {
|
||||
this.cityHash = null;
|
||||
this.cityGuildHash = null;
|
||||
this.cityNationHash = null;
|
||||
this.baneDropperHash = null;
|
||||
this.baneGuildHash = null;
|
||||
this.baneNationHash = null;
|
||||
this.baneLiveTime = null;
|
||||
}
|
||||
|
||||
public void release() {
|
||||
this.reset();
|
||||
recordPool.add(this);
|
||||
}
|
||||
public void release() {
|
||||
this.reset();
|
||||
recordPool.add(this);
|
||||
}
|
||||
|
||||
public void write() {
|
||||
public void write() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildBaneInsertStatement(connection)) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildBaneInsertStatement(connection)) {
|
||||
|
||||
statement.execute();
|
||||
statement.execute();
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private PreparedStatement buildBaneInsertStatement(Connection connection) throws SQLException {
|
||||
private PreparedStatement buildBaneInsertStatement(Connection connection) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_banehistory` (`city_id`, `city_name`, `char_id`, `offGuild_id`, `offNat_id`, `defGuild_id`, `defNat_id`, `dropDatetime`, `liveDateTime`, `resolution`) VALUES(?,?,?,?,?,?,?,?,?,?)";
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_banehistory` (`city_id`, `city_name`, `char_id`, `offGuild_id`, `offNat_id`, `defGuild_id`, `defNat_id`, `dropDatetime`, `liveDateTime`, `resolution`) VALUES(?,?,?,?,?,?,?,?,?,?)";
|
||||
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
|
||||
outStatement.setString(1, this.cityHash);
|
||||
outStatement.setString(2, this.cityName);
|
||||
outStatement.setString(3, this.baneDropperHash);
|
||||
outStatement.setString(4, this.baneGuildHash);
|
||||
outStatement.setString(5, this.baneNationHash);
|
||||
outStatement.setString(6, this.cityGuildHash);
|
||||
outStatement.setString(7, this.cityNationHash);
|
||||
outStatement.setString(1, this.cityHash);
|
||||
outStatement.setString(2, this.cityName);
|
||||
outStatement.setString(3, this.baneDropperHash);
|
||||
outStatement.setString(4, this.baneGuildHash);
|
||||
outStatement.setString(5, this.baneNationHash);
|
||||
outStatement.setString(6, this.cityGuildHash);
|
||||
outStatement.setString(7, this.cityNationHash);
|
||||
|
||||
if (this.baneDropTime == null)
|
||||
outStatement.setNull(8, java.sql.Types.DATE);
|
||||
else
|
||||
outStatement.setTimestamp(8, new java.sql.Timestamp(this.baneDropTime.getMillis()));
|
||||
if (this.baneDropTime == null)
|
||||
outStatement.setNull(8, java.sql.Types.DATE);
|
||||
else
|
||||
outStatement.setTimestamp(8, new java.sql.Timestamp(this.baneDropTime.getMillis()));
|
||||
|
||||
if (this.baneLiveTime == null)
|
||||
outStatement.setNull(9, java.sql.Types.DATE);
|
||||
else
|
||||
outStatement.setTimestamp(9, new java.sql.Timestamp(this.baneLiveTime.getMillis()));
|
||||
if (this.baneLiveTime == null)
|
||||
outStatement.setNull(9, java.sql.Types.DATE);
|
||||
else
|
||||
outStatement.setTimestamp(9, new java.sql.Timestamp(this.baneLiveTime.getMillis()));
|
||||
|
||||
outStatement.setString(10, this.eventType.name());
|
||||
outStatement.setString(10, this.eventType.name());
|
||||
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
return outStatement;
|
||||
}
|
||||
} // END CLASS
|
||||
|
||||
|
||||
@@ -44,8 +44,7 @@ public class CharacterRecord extends DataRecord {
|
||||
|
||||
if (characterRecord == null) {
|
||||
characterRecord = new CharacterRecord(player);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
characterRecord.recordType = Enum.DataRecordType.CHARACTER;
|
||||
characterRecord.player = player;
|
||||
|
||||
|
||||
@@ -19,144 +19,143 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
public class CityRecord extends DataRecord {
|
||||
|
||||
private static final LinkedBlockingQueue<CityRecord> recordPool = new LinkedBlockingQueue<>();
|
||||
private Enum.RecordEventType eventType;
|
||||
private City city;
|
||||
private String cityHash;
|
||||
private String cityGuildHash;
|
||||
private String cityName;
|
||||
private String cityMotto;
|
||||
private float locX;
|
||||
private float locY;
|
||||
private String zoneHash;
|
||||
private java.time.LocalDateTime establishedDatetime;
|
||||
private static final LinkedBlockingQueue<CityRecord> recordPool = new LinkedBlockingQueue<>();
|
||||
private Enum.RecordEventType eventType;
|
||||
private City city;
|
||||
private String cityHash;
|
||||
private String cityGuildHash;
|
||||
private String cityName;
|
||||
private String cityMotto;
|
||||
private float locX;
|
||||
private float locY;
|
||||
private String zoneHash;
|
||||
private java.time.LocalDateTime establishedDatetime;
|
||||
|
||||
private CityRecord(City city) {
|
||||
this.recordType = Enum.DataRecordType.CITY;
|
||||
this.city = city;
|
||||
this.eventType = Enum.RecordEventType.CREATE;
|
||||
private CityRecord(City city) {
|
||||
this.recordType = Enum.DataRecordType.CITY;
|
||||
this.city = city;
|
||||
this.eventType = Enum.RecordEventType.CREATE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static CityRecord borrow(City city, Enum.RecordEventType eventType) {
|
||||
CityRecord cityRecord;
|
||||
public static CityRecord borrow(City city, Enum.RecordEventType eventType) {
|
||||
CityRecord cityRecord;
|
||||
|
||||
cityRecord = recordPool.poll();
|
||||
cityRecord = recordPool.poll();
|
||||
|
||||
if (cityRecord == null) {
|
||||
cityRecord = new CityRecord(city);
|
||||
cityRecord.eventType = eventType;
|
||||
}
|
||||
else {
|
||||
cityRecord.recordType = Enum.DataRecordType.CITY;
|
||||
cityRecord.eventType = eventType;
|
||||
cityRecord.city = city;
|
||||
if (cityRecord == null) {
|
||||
cityRecord = new CityRecord(city);
|
||||
cityRecord.eventType = eventType;
|
||||
} else {
|
||||
cityRecord.recordType = Enum.DataRecordType.CITY;
|
||||
cityRecord.eventType = eventType;
|
||||
cityRecord.city = city;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (cityRecord.city.getHash() == null)
|
||||
cityRecord.city.setHash(DataWarehouse.hasher.encrypt(cityRecord.city.getObjectUUID()));
|
||||
if (cityRecord.city.getHash() == null)
|
||||
cityRecord.city.setHash(DataWarehouse.hasher.encrypt(cityRecord.city.getObjectUUID()));
|
||||
|
||||
cityRecord.cityHash = cityRecord.city.getHash();
|
||||
cityRecord.cityHash = cityRecord.city.getHash();
|
||||
|
||||
|
||||
cityRecord.cityName = cityRecord.city.getCityName();
|
||||
cityRecord.cityMotto = cityRecord.city.getMotto();
|
||||
cityRecord.cityName = cityRecord.city.getCityName();
|
||||
cityRecord.cityMotto = cityRecord.city.getMotto();
|
||||
|
||||
cityRecord.cityGuildHash = cityRecord.city.getGuild().getHash();
|
||||
cityRecord.cityGuildHash = cityRecord.city.getGuild().getHash();
|
||||
|
||||
cityRecord.locX = cityRecord.city.getTOL().getLoc().x;
|
||||
cityRecord.locY = -cityRecord.city.getTOL().getLoc().z; // flip sign on 'y' coordinate
|
||||
cityRecord.locX = cityRecord.city.getTOL().getLoc().x;
|
||||
cityRecord.locY = -cityRecord.city.getTOL().getLoc().z; // flip sign on 'y' coordinate
|
||||
|
||||
cityRecord.zoneHash = cityRecord.city.getParent().getHash();
|
||||
cityRecord.zoneHash = cityRecord.city.getParent().getHash();
|
||||
|
||||
if (cityRecord.eventType.equals(Enum.RecordEventType.CREATE))
|
||||
cityRecord.establishedDatetime = cityRecord.city.established;
|
||||
else
|
||||
cityRecord.establishedDatetime = java.time.LocalDateTime.now();
|
||||
if (cityRecord.eventType.equals(Enum.RecordEventType.CREATE))
|
||||
cityRecord.establishedDatetime = cityRecord.city.established;
|
||||
else
|
||||
cityRecord.establishedDatetime = java.time.LocalDateTime.now();
|
||||
|
||||
return cityRecord;
|
||||
}
|
||||
return cityRecord;
|
||||
}
|
||||
|
||||
public static PreparedStatement buildCityPushStatement(Connection connection, ResultSet rs) throws SQLException {
|
||||
public static PreparedStatement buildCityPushStatement(Connection connection, ResultSet rs) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_cityhistory` (`event_number`, `city_id`, `city_name`, `city_motto`, `guild_id`, `loc_x`, `loc_y`, `zone_id`, `eventType`, `datetime`) VALUES(?,?,?,?,?,?,?,?,?,?)";
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_cityhistory` (`event_number`, `city_id`, `city_name`, `city_motto`, `guild_id`, `loc_x`, `loc_y`, `zone_id`, `eventType`, `datetime`) VALUES(?,?,?,?,?,?,?,?,?,?)";
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
|
||||
// Bind record data
|
||||
// Bind record data
|
||||
|
||||
outStatement.setInt(1, rs.getInt("event_number"));
|
||||
outStatement.setString(2, rs.getString("city_id"));
|
||||
outStatement.setString(3, rs.getString("city_name"));
|
||||
outStatement.setString(4, rs.getString("city_motto"));
|
||||
outStatement.setString(5, rs.getString("guild_id"));
|
||||
outStatement.setInt(1, rs.getInt("event_number"));
|
||||
outStatement.setString(2, rs.getString("city_id"));
|
||||
outStatement.setString(3, rs.getString("city_name"));
|
||||
outStatement.setString(4, rs.getString("city_motto"));
|
||||
outStatement.setString(5, rs.getString("guild_id"));
|
||||
|
||||
outStatement.setFloat(6, rs.getFloat("loc_x"));
|
||||
outStatement.setFloat(7, rs.getFloat("loc_y"));
|
||||
outStatement.setString(8, rs.getString("zone_id"));
|
||||
outStatement.setString(9, rs.getString("eventType"));
|
||||
outStatement.setTimestamp(10, rs.getTimestamp("datetime"));
|
||||
outStatement.setFloat(6, rs.getFloat("loc_x"));
|
||||
outStatement.setFloat(7, rs.getFloat("loc_y"));
|
||||
outStatement.setString(8, rs.getString("zone_id"));
|
||||
outStatement.setString(9, rs.getString("eventType"));
|
||||
outStatement.setTimestamp(10, rs.getTimestamp("datetime"));
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
public static PreparedStatement buildCityQueryStatement(Connection connection) throws SQLException {
|
||||
public static PreparedStatement buildCityQueryStatement(Connection connection) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "SELECT * FROM `warehouse_cityhistory` WHERE `event_number` > ?";
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setInt(1, WarehousePushThread.cityIndex);
|
||||
return outStatement;
|
||||
}
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "SELECT * FROM `warehouse_cityhistory` WHERE `event_number` > ?";
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setInt(1, WarehousePushThread.cityIndex);
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
this.city = null;
|
||||
this.cityHash = null;
|
||||
this.cityGuildHash = null;
|
||||
this.cityMotto = null;
|
||||
this.zoneHash = null;
|
||||
this.establishedDatetime = null;
|
||||
void reset() {
|
||||
this.city = null;
|
||||
this.cityHash = null;
|
||||
this.cityGuildHash = null;
|
||||
this.cityMotto = null;
|
||||
this.zoneHash = null;
|
||||
this.establishedDatetime = null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
this.reset();
|
||||
recordPool.add(this);
|
||||
}
|
||||
public void release() {
|
||||
this.reset();
|
||||
recordPool.add(this);
|
||||
}
|
||||
|
||||
public void write() {
|
||||
public void write() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = this.buildCityInsertStatement(connection)) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = this.buildCityInsertStatement(connection)) {
|
||||
|
||||
statement.execute();
|
||||
statement.execute();
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private PreparedStatement buildCityInsertStatement(Connection connection) throws SQLException {
|
||||
private PreparedStatement buildCityInsertStatement(Connection connection) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_cityhistory` (`city_id`, `city_name`, `city_motto`, `guild_id`, `loc_x`, `loc_y`, `zone_id`, `eventType`, `datetime`) VALUES(?,?,?,?,?,?,?,?,?)";
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_cityhistory` (`city_id`, `city_name`, `city_motto`, `guild_id`, `loc_x`, `loc_y`, `zone_id`, `eventType`, `datetime`) VALUES(?,?,?,?,?,?,?,?,?)";
|
||||
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
|
||||
// Bind character data
|
||||
// Bind character data
|
||||
|
||||
outStatement.setString(1, this.cityHash);
|
||||
outStatement.setString(2, this.cityName);
|
||||
outStatement.setString(3, this.cityMotto);
|
||||
outStatement.setString(4, this.cityGuildHash);
|
||||
outStatement.setString(1, this.cityHash);
|
||||
outStatement.setString(2, this.cityName);
|
||||
outStatement.setString(3, this.cityMotto);
|
||||
outStatement.setString(4, this.cityGuildHash);
|
||||
|
||||
outStatement.setFloat(5, this.locX);
|
||||
outStatement.setFloat(6, this.locY);
|
||||
outStatement.setString(7, this.zoneHash);
|
||||
outStatement.setString(8, this.eventType.name());
|
||||
outStatement.setTimestamp(9, Timestamp.valueOf(this.establishedDatetime));
|
||||
outStatement.setFloat(5, this.locX);
|
||||
outStatement.setFloat(6, this.locY);
|
||||
outStatement.setString(7, this.zoneHash);
|
||||
outStatement.setString(8, this.eventType.name());
|
||||
outStatement.setTimestamp(9, Timestamp.valueOf(this.establishedDatetime));
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
return outStatement;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
|
||||
package engine.db.archive;
|
||||
|
||||
import engine.Enum;
|
||||
|
||||
@@ -35,12 +35,12 @@ public class DataWarehouse implements Runnable {
|
||||
// If WarehousePush is disabled
|
||||
// then early exit
|
||||
|
||||
if ( ConfigManager.MB_WORLD_WAREHOUSE_PUSH.getValue().equalsIgnoreCase("false")) {
|
||||
if (ConfigManager.MB_WORLD_WAREHOUSE_PUSH.getValue().equalsIgnoreCase("false")) {
|
||||
Logger.info("Warehouse Remote Connection disabled along with push");
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.info( "Configuring remote Database Connection Pool...");
|
||||
Logger.info("Configuring remote Database Connection Pool...");
|
||||
configureRemoteConnectionPool();
|
||||
}
|
||||
|
||||
@@ -188,6 +188,24 @@ public class DataWarehouse implements Runnable {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void configureRemoteConnectionPool() {
|
||||
|
||||
HikariConfig config = new HikariConfig();
|
||||
|
||||
config.setMaximumPoolSize(1); // Only the server talks to remote, so yeah.
|
||||
config.setJdbcUrl(ConfigManager.MB_WAREHOUSE_ADDR.getValue());
|
||||
config.setUsername(ConfigManager.MB_WAREHOUSE_USER.getValue());
|
||||
config.setPassword(ConfigManager.MB_WAREHOUSE_PASS.getValue());
|
||||
config.addDataSourceProperty("characterEncoding", "utf8");
|
||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||
|
||||
remoteConnectionPool = new HikariDataSource(config); // setup the connection pool
|
||||
|
||||
Logger.info("remote warehouse connection configured");
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
// Working variable set
|
||||
@@ -201,7 +219,7 @@ public class DataWarehouse implements Runnable {
|
||||
RealmRecord realmRecord;
|
||||
MineRecord mineRecord;
|
||||
|
||||
Logger.info( "DataWarehouse is running.");
|
||||
Logger.info("DataWarehouse is running.");
|
||||
|
||||
while (true) {
|
||||
|
||||
@@ -261,7 +279,7 @@ public class DataWarehouse implements Runnable {
|
||||
mineRecord.release();
|
||||
break;
|
||||
default:
|
||||
Logger.error( "Unhandled record type");
|
||||
Logger.error("Unhandled record type");
|
||||
break;
|
||||
|
||||
} // end switch
|
||||
@@ -269,22 +287,4 @@ public class DataWarehouse implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private static void configureRemoteConnectionPool() {
|
||||
|
||||
HikariConfig config = new HikariConfig();
|
||||
|
||||
config.setMaximumPoolSize(1); // Only the server talks to remote, so yeah.
|
||||
config.setJdbcUrl(ConfigManager.MB_WAREHOUSE_ADDR.getValue());
|
||||
config.setUsername(ConfigManager.MB_WAREHOUSE_USER.getValue());
|
||||
config.setPassword(ConfigManager.MB_WAREHOUSE_PASS.getValue());
|
||||
config.addDataSourceProperty("characterEncoding", "utf8");
|
||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||
|
||||
remoteConnectionPool = new HikariDataSource(config); // setup the connection pool
|
||||
|
||||
Logger.info("remote warehouse connection configured");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,144 +26,139 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
public class GuildRecord extends DataRecord {
|
||||
|
||||
private static final LinkedBlockingQueue<GuildRecord> recordPool = new LinkedBlockingQueue<>();
|
||||
private Enum.RecordEventType eventType;
|
||||
private Guild guild;
|
||||
public String guildHash;
|
||||
private String guildName;
|
||||
private String charterName;
|
||||
private String GLHash;
|
||||
private String guildMotto;
|
||||
private int bgIcon;
|
||||
private int bgColour1;
|
||||
private int bgColour2;
|
||||
private int fgIcon;
|
||||
private int fgColour;
|
||||
public int guildID;
|
||||
private static final LinkedBlockingQueue<GuildRecord> recordPool = new LinkedBlockingQueue<>();
|
||||
public static HashMap<Integer, GuildRecord> GuildRecordCache = null;
|
||||
public String guildHash;
|
||||
public int guildID;
|
||||
private Enum.RecordEventType eventType;
|
||||
private Guild guild;
|
||||
private String guildName;
|
||||
private String charterName;
|
||||
private String GLHash;
|
||||
private String guildMotto;
|
||||
private int bgIcon;
|
||||
private int bgColour1;
|
||||
private int bgColour2;
|
||||
private int fgIcon;
|
||||
private int fgColour;
|
||||
private java.time.LocalDateTime eventDatetime;
|
||||
|
||||
private java.time.LocalDateTime eventDatetime;
|
||||
|
||||
public static HashMap<Integer, GuildRecord> GuildRecordCache = null;
|
||||
|
||||
private GuildRecord(Guild guild) {
|
||||
this.recordType = Enum.DataRecordType.GUILD;
|
||||
this.guild = guild;
|
||||
this.eventType = Enum.RecordEventType.CREATE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public GuildRecord(ResultSet rs) throws SQLException {
|
||||
super();
|
||||
this.eventType = RecordEventType.valueOf(rs.getString("eventType"));
|
||||
this.guildHash = rs.getString("guild_id");
|
||||
this.guildName = rs.getString("guild_name");
|
||||
this.charterName = rs.getString("charter");
|
||||
GLHash = rs.getString("guild_founder");
|
||||
this.guildMotto = rs.getString("guild_motto");
|
||||
this.bgIcon = rs.getInt("bgicon");
|
||||
this.bgColour1 = rs.getInt("bgcoloura");
|
||||
this.bgColour2 = rs.getInt("bgcolourb");
|
||||
this.fgIcon = rs.getInt("fgicon");
|
||||
this.fgColour = rs.getInt("fgcolour");
|
||||
|
||||
java.sql.Timestamp eventTimeStamp = rs.getTimestamp("upgradeDate");
|
||||
|
||||
if (eventTimeStamp != null)
|
||||
this.eventDatetime = LocalDateTime.ofInstant(eventTimeStamp.toInstant(), ZoneId.systemDefault());
|
||||
}
|
||||
private GuildRecord(Guild guild) {
|
||||
this.recordType = Enum.DataRecordType.GUILD;
|
||||
this.guild = guild;
|
||||
this.eventType = Enum.RecordEventType.CREATE;
|
||||
}
|
||||
|
||||
|
||||
public GuildRecord(ResultSet rs) throws SQLException {
|
||||
super();
|
||||
this.eventType = RecordEventType.valueOf(rs.getString("eventType"));
|
||||
this.guildHash = rs.getString("guild_id");
|
||||
this.guildName = rs.getString("guild_name");
|
||||
this.charterName = rs.getString("charter");
|
||||
GLHash = rs.getString("guild_founder");
|
||||
this.guildMotto = rs.getString("guild_motto");
|
||||
this.bgIcon = rs.getInt("bgicon");
|
||||
this.bgColour1 = rs.getInt("bgcoloura");
|
||||
this.bgColour2 = rs.getInt("bgcolourb");
|
||||
this.fgIcon = rs.getInt("fgicon");
|
||||
this.fgColour = rs.getInt("fgcolour");
|
||||
|
||||
public static GuildRecord borrow(Guild guild, Enum.RecordEventType eventType) {
|
||||
GuildRecord guildRecord;
|
||||
//add
|
||||
guildRecord = recordPool.poll();
|
||||
java.sql.Timestamp eventTimeStamp = rs.getTimestamp("upgradeDate");
|
||||
|
||||
if (guildRecord == null) {
|
||||
guildRecord = new GuildRecord(guild);
|
||||
guildRecord.eventType = eventType;
|
||||
}
|
||||
else {
|
||||
guildRecord.guild = guild;
|
||||
guildRecord.recordType = Enum.DataRecordType.GUILD;
|
||||
guildRecord.eventType = eventType;
|
||||
if (eventTimeStamp != null)
|
||||
this.eventDatetime = LocalDateTime.ofInstant(eventTimeStamp.toInstant(), ZoneId.systemDefault());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
guildRecord.guildHash = guildRecord.guild.getHash();
|
||||
guildRecord.guildID = guildRecord.guild.getObjectUUID();
|
||||
guildRecord.guildName = guildRecord.guild.getName();
|
||||
guildRecord.charterName = Enum.GuildType.getGuildTypeFromInt(guildRecord.guild.getCharter()).getCharterName();
|
||||
public static GuildRecord borrow(Guild guild, Enum.RecordEventType eventType) {
|
||||
GuildRecord guildRecord;
|
||||
//add
|
||||
guildRecord = recordPool.poll();
|
||||
|
||||
guildRecord.GLHash = DataWarehouse.hasher.encrypt(guildRecord.guild.getGuildLeaderUUID());
|
||||
if (guildRecord == null) {
|
||||
guildRecord = new GuildRecord(guild);
|
||||
guildRecord.eventType = eventType;
|
||||
} else {
|
||||
guildRecord.guild = guild;
|
||||
guildRecord.recordType = Enum.DataRecordType.GUILD;
|
||||
guildRecord.eventType = eventType;
|
||||
|
||||
guildRecord.guildMotto = guildRecord.guild.getMotto();
|
||||
guildRecord.bgIcon = guildRecord.guild.getBgDesign();
|
||||
guildRecord.bgColour1 = guildRecord.guild.getBgc1();
|
||||
guildRecord.bgColour2 = guildRecord.guild.getBgc2();
|
||||
guildRecord.fgIcon = guildRecord.guild.getSymbol();
|
||||
guildRecord.fgColour = guildRecord.guild.getSc();
|
||||
}
|
||||
|
||||
if (guild.getOwnedCity() != null)
|
||||
guildRecord.eventDatetime = guild.getOwnedCity().established;
|
||||
else
|
||||
guildRecord.eventDatetime = LocalDateTime.now();
|
||||
guildRecord.guildHash = guildRecord.guild.getHash();
|
||||
guildRecord.guildID = guildRecord.guild.getObjectUUID();
|
||||
guildRecord.guildName = guildRecord.guild.getName();
|
||||
guildRecord.charterName = Enum.GuildType.getGuildTypeFromInt(guildRecord.guild.getCharter()).getCharterName();
|
||||
|
||||
return guildRecord;
|
||||
}
|
||||
guildRecord.GLHash = DataWarehouse.hasher.encrypt(guildRecord.guild.getGuildLeaderUUID());
|
||||
|
||||
public static PreparedStatement buildGuildPushStatement(Connection connection, ResultSet rs) throws SQLException {
|
||||
guildRecord.guildMotto = guildRecord.guild.getMotto();
|
||||
guildRecord.bgIcon = guildRecord.guild.getBgDesign();
|
||||
guildRecord.bgColour1 = guildRecord.guild.getBgc1();
|
||||
guildRecord.bgColour2 = guildRecord.guild.getBgc2();
|
||||
guildRecord.fgIcon = guildRecord.guild.getSymbol();
|
||||
guildRecord.fgColour = guildRecord.guild.getSc();
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_guildhistory` (`event_number`, `guild_id`, `guild_name`, `guild_motto`, `guild_founder`, `charter`, `bgicon`, `bgcoloura`, `bgcolourb`, `fgicon`, `fgcolour`, `eventtype`, `datetime`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
if (guild.getOwnedCity() != null)
|
||||
guildRecord.eventDatetime = guild.getOwnedCity().established;
|
||||
else
|
||||
guildRecord.eventDatetime = LocalDateTime.now();
|
||||
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
return guildRecord;
|
||||
}
|
||||
|
||||
// Bind record data
|
||||
public static PreparedStatement buildGuildPushStatement(Connection connection, ResultSet rs) throws SQLException {
|
||||
|
||||
outStatement.setInt(1, rs.getInt("event_number"));
|
||||
outStatement.setString(2, rs.getString("guild_id"));
|
||||
outStatement.setString(3, rs.getString("guild_name"));
|
||||
outStatement.setString(4, rs.getString("guild_motto"));
|
||||
outStatement.setString(5, rs.getString("guild_founder"));
|
||||
outStatement.setString(6, rs.getString("charter"));
|
||||
outStatement.setInt(7, rs.getInt("bgicon"));
|
||||
outStatement.setInt(8, rs.getInt("bgcoloura"));
|
||||
outStatement.setInt(9, rs.getInt("bgcolourb"));
|
||||
outStatement.setInt(10, rs.getInt("fgicon"));
|
||||
outStatement.setInt(11, rs.getInt("fgcolour"));
|
||||
outStatement.setString(12, rs.getString("eventtype"));
|
||||
outStatement.setTimestamp(13, rs.getTimestamp("datetime"));
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_guildhistory` (`event_number`, `guild_id`, `guild_name`, `guild_motto`, `guild_founder`, `charter`, `bgicon`, `bgcoloura`, `bgcolourb`, `fgicon`, `fgcolour`, `eventtype`, `datetime`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
|
||||
public static PreparedStatement buildGuildQueryStatement(Connection connection) throws SQLException {
|
||||
// Bind record data
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "SELECT * FROM `warehouse_guildhistory` WHERE `event_number` > ?";
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setInt(1, WarehousePushThread.guildIndex);
|
||||
return outStatement;
|
||||
}
|
||||
outStatement.setInt(1, rs.getInt("event_number"));
|
||||
outStatement.setString(2, rs.getString("guild_id"));
|
||||
outStatement.setString(3, rs.getString("guild_name"));
|
||||
outStatement.setString(4, rs.getString("guild_motto"));
|
||||
outStatement.setString(5, rs.getString("guild_founder"));
|
||||
outStatement.setString(6, rs.getString("charter"));
|
||||
outStatement.setInt(7, rs.getInt("bgicon"));
|
||||
outStatement.setInt(8, rs.getInt("bgcoloura"));
|
||||
outStatement.setInt(9, rs.getInt("bgcolourb"));
|
||||
outStatement.setInt(10, rs.getInt("fgicon"));
|
||||
outStatement.setInt(11, rs.getInt("fgcolour"));
|
||||
outStatement.setString(12, rs.getString("eventtype"));
|
||||
outStatement.setTimestamp(13, rs.getTimestamp("datetime"));
|
||||
|
||||
void reset() {
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
this.guild = null;
|
||||
this.guildHash = null;
|
||||
this.GLHash = null;
|
||||
this.guildMotto = null;
|
||||
this.charterName = null;
|
||||
this.eventDatetime = null;
|
||||
}
|
||||
public static PreparedStatement buildGuildQueryStatement(Connection connection) throws SQLException {
|
||||
|
||||
public void release() {
|
||||
this.reset();
|
||||
recordPool.add(this);
|
||||
}
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "SELECT * FROM `warehouse_guildhistory` WHERE `event_number` > ?";
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setInt(1, WarehousePushThread.guildIndex);
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
public void write() {
|
||||
void reset() {
|
||||
|
||||
this.guild = null;
|
||||
this.guildHash = null;
|
||||
this.GLHash = null;
|
||||
this.guildMotto = null;
|
||||
this.charterName = null;
|
||||
this.eventDatetime = null;
|
||||
}
|
||||
|
||||
public void release() {
|
||||
this.reset();
|
||||
recordPool.add(this);
|
||||
}
|
||||
|
||||
public void write() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = this.buildGuildInsertStatement(connection)) {
|
||||
@@ -176,33 +171,33 @@ public class GuildRecord extends DataRecord {
|
||||
|
||||
}
|
||||
|
||||
private PreparedStatement buildGuildInsertStatement(Connection connection) throws SQLException {
|
||||
private PreparedStatement buildGuildInsertStatement(Connection connection) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_guildhistory` (`guild_id`, `guild_name`, `guild_motto`, `guild_founder`, `charter`, `bgicon`, `bgcoloura`, `bgcolourb`, `fgicon`, `fgcolour`, `eventtype`, `datetime`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_guildhistory` (`guild_id`, `guild_name`, `guild_motto`, `guild_founder`, `charter`, `bgicon`, `bgcoloura`, `bgcolourb`, `fgicon`, `fgcolour`, `eventtype`, `datetime`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
|
||||
// Bind character data
|
||||
// Bind character data
|
||||
|
||||
outStatement.setString(1, this.guildHash);
|
||||
outStatement.setString(2, this.guildName);
|
||||
outStatement.setString(3, this.guildMotto);
|
||||
outStatement.setString(4, this.GLHash);
|
||||
outStatement.setString(5, this.charterName);
|
||||
outStatement.setString(1, this.guildHash);
|
||||
outStatement.setString(2, this.guildName);
|
||||
outStatement.setString(3, this.guildMotto);
|
||||
outStatement.setString(4, this.GLHash);
|
||||
outStatement.setString(5, this.charterName);
|
||||
|
||||
outStatement.setInt(6, this.bgIcon);
|
||||
outStatement.setInt(7, this.bgColour1);
|
||||
outStatement.setInt(8, this.bgColour2);
|
||||
outStatement.setInt(9, this.fgIcon);
|
||||
outStatement.setInt(10, this.fgColour);
|
||||
outStatement.setString(11, this.eventType.name());
|
||||
outStatement.setTimestamp(12, new java.sql.Timestamp( this.eventDatetime.atZone(ZoneId.systemDefault())
|
||||
.toInstant().toEpochMilli()));
|
||||
outStatement.setInt(6, this.bgIcon);
|
||||
outStatement.setInt(7, this.bgColour1);
|
||||
outStatement.setInt(8, this.bgColour2);
|
||||
outStatement.setInt(9, this.fgIcon);
|
||||
outStatement.setInt(10, this.fgColour);
|
||||
outStatement.setString(11, this.eventType.name());
|
||||
outStatement.setTimestamp(12, new java.sql.Timestamp(this.eventDatetime.atZone(ZoneId.systemDefault())
|
||||
.toInstant().toEpochMilli()));
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
// public static void InitializeGuildRecords(){
|
||||
// GuildRecord.GuildRecordCache = DbManager.GuildQueries.GET_WAREHOUSE_GUILD_HISTORY();
|
||||
// }
|
||||
|
||||
@@ -47,8 +47,7 @@ public class MineRecord extends DataRecord {
|
||||
if (mineRecord == null) {
|
||||
mineRecord = new MineRecord();
|
||||
mineRecord.eventType = eventType;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mineRecord.recordType = Enum.DataRecordType.MINE;
|
||||
mineRecord.eventType = eventType;
|
||||
}
|
||||
@@ -58,8 +57,7 @@ public class MineRecord extends DataRecord {
|
||||
if (character.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||||
player = (PlayerCharacter) character;
|
||||
mineRecord.charHash = player.getHash();
|
||||
}
|
||||
else
|
||||
} else
|
||||
mineRecord.charHash = character.getName();
|
||||
|
||||
DataWarehouse.hasher.encrypt(0);
|
||||
|
||||
@@ -28,286 +28,285 @@ import static engine.Enum.PvpHistoryType;
|
||||
|
||||
public class PvpRecord extends DataRecord {
|
||||
|
||||
private static final LinkedBlockingQueue<PvpRecord> recordPool = new LinkedBlockingQueue<>();
|
||||
private static final LinkedBlockingQueue<PvpRecord> recordPool = new LinkedBlockingQueue<>();
|
||||
|
||||
private PlayerCharacter player;
|
||||
private PlayerCharacter victim;
|
||||
private Vector3fImmutable location;
|
||||
private boolean pvpExp;
|
||||
private PlayerCharacter player;
|
||||
private PlayerCharacter victim;
|
||||
private Vector3fImmutable location;
|
||||
private boolean pvpExp;
|
||||
|
||||
private PvpRecord(PlayerCharacter player, PlayerCharacter victim, Vector3fImmutable location, boolean pvpExp) {
|
||||
this.recordType = DataRecordType.PVP;
|
||||
this.player = player;
|
||||
this.victim = victim;
|
||||
this.location = new Vector3fImmutable(location);
|
||||
this.pvpExp = pvpExp;
|
||||
}
|
||||
private PvpRecord(PlayerCharacter player, PlayerCharacter victim, Vector3fImmutable location, boolean pvpExp) {
|
||||
this.recordType = DataRecordType.PVP;
|
||||
this.player = player;
|
||||
this.victim = victim;
|
||||
this.location = new Vector3fImmutable(location);
|
||||
this.pvpExp = pvpExp;
|
||||
}
|
||||
|
||||
public static PvpRecord borrow(PlayerCharacter player, PlayerCharacter victim, Vector3fImmutable location, boolean pvpExp) {
|
||||
public static PvpRecord borrow(PlayerCharacter player, PlayerCharacter victim, Vector3fImmutable location, boolean pvpExp) {
|
||||
|
||||
PvpRecord pvpRecord;
|
||||
PvpRecord pvpRecord;
|
||||
|
||||
pvpRecord = recordPool.poll();
|
||||
pvpRecord = recordPool.poll();
|
||||
|
||||
if (pvpRecord == null) {
|
||||
pvpRecord = new PvpRecord(player, victim, location, pvpExp);
|
||||
}
|
||||
else {
|
||||
pvpRecord.recordType = DataRecordType.PVP;
|
||||
pvpRecord.player = player;
|
||||
pvpRecord.victim = victim;
|
||||
pvpRecord.location = new Vector3fImmutable(location);
|
||||
pvpRecord.pvpExp = pvpExp;
|
||||
}
|
||||
if (pvpRecord == null) {
|
||||
pvpRecord = new PvpRecord(player, victim, location, pvpExp);
|
||||
} else {
|
||||
pvpRecord.recordType = DataRecordType.PVP;
|
||||
pvpRecord.player = player;
|
||||
pvpRecord.victim = victim;
|
||||
pvpRecord.location = new Vector3fImmutable(location);
|
||||
pvpRecord.pvpExp = pvpExp;
|
||||
}
|
||||
|
||||
return pvpRecord;
|
||||
}
|
||||
return pvpRecord;
|
||||
}
|
||||
|
||||
private static PreparedStatement buildHistoryStatement(Connection connection, int charUUID, PvpHistoryType historyType) throws SQLException {
|
||||
private static PreparedStatement buildHistoryStatement(Connection connection, int charUUID, PvpHistoryType historyType) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "";
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "";
|
||||
|
||||
switch (historyType) {
|
||||
case KILLS:
|
||||
queryString = "SELECT DISTINCT `victim_id`, `datetime` FROM warehouse_pvphistory where char_id = ? " +
|
||||
"ORDER BY `datetime` DESC LIMIT 10";
|
||||
break;
|
||||
case DEATHS:
|
||||
queryString = "SELECT DISTINCT `char_id`,`datetime` FROM warehouse_pvphistory where `victim_id` = ? " +
|
||||
"ORDER BY `datetime` DESC LIMIT 10";
|
||||
break;
|
||||
}
|
||||
switch (historyType) {
|
||||
case KILLS:
|
||||
queryString = "SELECT DISTINCT `victim_id`, `datetime` FROM warehouse_pvphistory where char_id = ? " +
|
||||
"ORDER BY `datetime` DESC LIMIT 10";
|
||||
break;
|
||||
case DEATHS:
|
||||
queryString = "SELECT DISTINCT `char_id`,`datetime` FROM warehouse_pvphistory where `victim_id` = ? " +
|
||||
"ORDER BY `datetime` DESC LIMIT 10";
|
||||
break;
|
||||
}
|
||||
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setString(1, DataWarehouse.hasher.encrypt(charUUID));
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setString(1, DataWarehouse.hasher.encrypt(charUUID));
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
public static LinkedList<Integer> getCharacterPvPHistory(int charUUID, PvpHistoryType historyType) {
|
||||
public static LinkedList<Integer> getCharacterPvPHistory(int charUUID, PvpHistoryType historyType) {
|
||||
|
||||
// Member variable declaration
|
||||
// Member variable declaration
|
||||
|
||||
LinkedList<Integer> outList = new LinkedList<>();
|
||||
LinkedList<Integer> outList = new LinkedList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildHistoryStatement(connection, charUUID, historyType);
|
||||
ResultSet rs = statement.executeQuery()) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildHistoryStatement(connection, charUUID, historyType);
|
||||
ResultSet rs = statement.executeQuery()) {
|
||||
|
||||
while (rs.next()) {
|
||||
while (rs.next()) {
|
||||
|
||||
switch (historyType) {
|
||||
case KILLS:
|
||||
outList.add((int) DataWarehouse.hasher.decrypt(rs.getString("victim_id"))[0]);
|
||||
break;
|
||||
case DEATHS:
|
||||
outList.add((int) DataWarehouse.hasher.decrypt(rs.getString("char_id"))[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return outList;
|
||||
}
|
||||
switch (historyType) {
|
||||
case KILLS:
|
||||
outList.add((int) DataWarehouse.hasher.decrypt(rs.getString("victim_id"))[0]);
|
||||
break;
|
||||
case DEATHS:
|
||||
outList.add((int) DataWarehouse.hasher.decrypt(rs.getString("char_id"))[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return outList;
|
||||
}
|
||||
|
||||
private static PreparedStatement buildLuaHistoryQueryStatement(Connection connection, int charUUID) throws SQLException {
|
||||
private static PreparedStatement buildLuaHistoryQueryStatement(Connection connection, int charUUID) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "CALL `pvpHistory`(?)";
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "CALL `pvpHistory`(?)";
|
||||
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setString(1, DataWarehouse.hasher.encrypt(charUUID));
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setString(1, DataWarehouse.hasher.encrypt(charUUID));
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
public static String getPvpHistoryString(int charUUID) {
|
||||
public static String getPvpHistoryString(int charUUID) {
|
||||
|
||||
String outString;
|
||||
String dividerString;
|
||||
String outString;
|
||||
String dividerString;
|
||||
|
||||
String newLine = System.getProperty("line.separator");
|
||||
String newLine = System.getProperty("line.separator");
|
||||
|
||||
outString = "[LUA_PVP() DATA WAREHOUSE]" + newLine;
|
||||
dividerString = "--------------------------------" + newLine;
|
||||
outString = "[LUA_PVP() DATA WAREHOUSE]" + newLine;
|
||||
dividerString = "--------------------------------" + newLine;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildLuaHistoryQueryStatement(connection, charUUID);
|
||||
ResultSet rs = statement.executeQuery()) {
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildLuaHistoryQueryStatement(connection, charUUID);
|
||||
ResultSet rs = statement.executeQuery()) {
|
||||
|
||||
while (rs.next()) {
|
||||
while (rs.next()) {
|
||||
|
||||
int killCount;
|
||||
int deathCount;
|
||||
float killRatio;
|
||||
int killCount;
|
||||
int deathCount;
|
||||
float killRatio;
|
||||
|
||||
outString += "Total Magicbane murdered souls: " + rs.getInt("TOTALDEATHS") + newLine;
|
||||
outString += dividerString;
|
||||
outString += String.format("%-8s %-8s %-8s %-8s %n", "Period", "Kills", "Deaths", "K/D");
|
||||
outString += dividerString;
|
||||
outString += "Total Magicbane murdered souls: " + rs.getInt("TOTALDEATHS") + newLine;
|
||||
outString += dividerString;
|
||||
outString += String.format("%-8s %-8s %-8s %-8s %n", "Period", "Kills", "Deaths", "K/D");
|
||||
outString += dividerString;
|
||||
|
||||
killCount = rs.getInt("KILLCOUNT");
|
||||
deathCount = rs.getInt("DEATHCOUNT");
|
||||
|
||||
if (deathCount == 0)
|
||||
killRatio = (float) killCount;
|
||||
else
|
||||
killRatio = (float) killCount / deathCount;
|
||||
killCount = rs.getInt("KILLCOUNT");
|
||||
deathCount = rs.getInt("DEATHCOUNT");
|
||||
|
||||
if (deathCount == 0)
|
||||
killRatio = (float) killCount;
|
||||
else
|
||||
killRatio = (float) killCount / deathCount;
|
||||
|
||||
try {
|
||||
outString += String.format("%-8s %-8d %-8d %.2f %n", "Total", killCount, deathCount, killRatio);
|
||||
try {
|
||||
outString += String.format("%-8s %-8d %-8d %.2f %n", "Total", killCount, deathCount, killRatio);
|
||||
|
||||
killCount = rs.getInt("DAILYKILLS");
|
||||
deathCount = rs.getInt("DAILYDEATHS");
|
||||
killCount = rs.getInt("DAILYKILLS");
|
||||
deathCount = rs.getInt("DAILYDEATHS");
|
||||
|
||||
if (deathCount == 0)
|
||||
killRatio = (float) killCount;
|
||||
else
|
||||
killRatio = (float) killCount / deathCount;
|
||||
if (deathCount == 0)
|
||||
killRatio = (float) killCount;
|
||||
else
|
||||
killRatio = (float) killCount / deathCount;
|
||||
|
||||
outString += String.format("%-8s %-8d %-8d %.2f %n", "24hrs", killCount, deathCount, killRatio);
|
||||
outString += String.format("%-8s %-8d %-8d %.2f %n", "24hrs", killCount, deathCount, killRatio);
|
||||
|
||||
killCount = rs.getInt("HOURLYKILLS");
|
||||
deathCount = rs.getInt("HOURLYDEATHS");
|
||||
killCount = rs.getInt("HOURLYKILLS");
|
||||
deathCount = rs.getInt("HOURLYDEATHS");
|
||||
|
||||
if (deathCount == 0)
|
||||
killRatio = (float) killCount;
|
||||
else
|
||||
killRatio = (float) killCount / deathCount;
|
||||
if (deathCount == 0)
|
||||
killRatio = (float) killCount;
|
||||
else
|
||||
killRatio = (float) killCount / deathCount;
|
||||
|
||||
outString += String.format("%-8s %-8d %-8d %.2f %n", "1hr", killCount, deathCount, killRatio);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
outString += String.format("%-8s %-8d %-8d %.2f %n", "1hr", killCount, deathCount, killRatio);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return outString;
|
||||
}
|
||||
return outString;
|
||||
}
|
||||
|
||||
public static PreparedStatement buildPvpPushStatement(Connection connection, ResultSet rs) throws SQLException {
|
||||
public static PreparedStatement buildPvpPushStatement(Connection connection, ResultSet rs) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_pvphistory` (`event_number`, `char_id`, `char_guild_id`, `char_nation_id`, `char_level`," +
|
||||
" `victim_id`, `victim_guild_id`, `victim_nation_id`, `victim_level`," +
|
||||
" `zone_id`, `zone_name`, `loc_x`, `loc_y`, `gave_exp`, `datetime`) " +
|
||||
" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "INSERT INTO `warehouse_pvphistory` (`event_number`, `char_id`, `char_guild_id`, `char_nation_id`, `char_level`," +
|
||||
" `victim_id`, `victim_guild_id`, `victim_nation_id`, `victim_level`," +
|
||||
" `zone_id`, `zone_name`, `loc_x`, `loc_y`, `gave_exp`, `datetime`) " +
|
||||
" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
|
||||
// Bind record data
|
||||
// Bind record data
|
||||
|
||||
outStatement.setInt(1, rs.getInt("event_number"));
|
||||
outStatement.setString(2, rs.getString("char_id"));
|
||||
outStatement.setString(3, rs.getString("char_guild_id"));
|
||||
outStatement.setString(4, rs.getString("char_nation_id"));
|
||||
outStatement.setInt(5, rs.getInt("char_level"));
|
||||
outStatement.setInt(1, rs.getInt("event_number"));
|
||||
outStatement.setString(2, rs.getString("char_id"));
|
||||
outStatement.setString(3, rs.getString("char_guild_id"));
|
||||
outStatement.setString(4, rs.getString("char_nation_id"));
|
||||
outStatement.setInt(5, rs.getInt("char_level"));
|
||||
|
||||
// Bind victim data
|
||||
// Bind victim data
|
||||
|
||||
outStatement.setString(6, rs.getString("victim_id"));
|
||||
outStatement.setString(7, rs.getString("victim_guild_id"));
|
||||
outStatement.setString(8, rs.getString("victim_nation_id"));
|
||||
outStatement.setInt(9, rs.getInt("victim_level"));
|
||||
outStatement.setString(6, rs.getString("victim_id"));
|
||||
outStatement.setString(7, rs.getString("victim_guild_id"));
|
||||
outStatement.setString(8, rs.getString("victim_nation_id"));
|
||||
outStatement.setInt(9, rs.getInt("victim_level"));
|
||||
|
||||
outStatement.setString(10, rs.getString("zone_id"));
|
||||
outStatement.setString(11, rs.getString("zone_name"));
|
||||
outStatement.setFloat(12, rs.getFloat("loc_x"));
|
||||
outStatement.setFloat(13, rs.getFloat("loc_y"));
|
||||
outStatement.setBoolean(14, rs.getBoolean("gave_exp"));
|
||||
outStatement.setTimestamp(15, rs.getTimestamp("datetime"));
|
||||
outStatement.setString(10, rs.getString("zone_id"));
|
||||
outStatement.setString(11, rs.getString("zone_name"));
|
||||
outStatement.setFloat(12, rs.getFloat("loc_x"));
|
||||
outStatement.setFloat(13, rs.getFloat("loc_y"));
|
||||
outStatement.setBoolean(14, rs.getBoolean("gave_exp"));
|
||||
outStatement.setTimestamp(15, rs.getTimestamp("datetime"));
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
public static PreparedStatement buildPvpQueryStatement(Connection connection) throws SQLException {
|
||||
public static PreparedStatement buildPvpQueryStatement(Connection connection) throws SQLException {
|
||||
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "SELECT * FROM `warehouse_pvphistory` WHERE `event_number` > ?";
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setInt(1, WarehousePushThread.pvpIndex);
|
||||
return outStatement;
|
||||
}
|
||||
PreparedStatement outStatement = null;
|
||||
String queryString = "SELECT * FROM `warehouse_pvphistory` WHERE `event_number` > ?";
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement.setInt(1, WarehousePushThread.pvpIndex);
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
this.player = null;
|
||||
this.victim = null;
|
||||
this.location = Vector3fImmutable.ZERO;
|
||||
pvpExp = false;
|
||||
}
|
||||
void reset() {
|
||||
this.player = null;
|
||||
this.victim = null;
|
||||
this.location = Vector3fImmutable.ZERO;
|
||||
pvpExp = false;
|
||||
}
|
||||
|
||||
public void release() {
|
||||
this.reset();
|
||||
recordPool.add(this);
|
||||
}
|
||||
public void release() {
|
||||
this.reset();
|
||||
recordPool.add(this);
|
||||
}
|
||||
|
||||
private PreparedStatement buildPvPInsertStatement(Connection connection) throws SQLException {
|
||||
private PreparedStatement buildPvPInsertStatement(Connection connection) throws SQLException {
|
||||
|
||||
Guild charGuild;
|
||||
Guild victimGuild;
|
||||
Zone zone;
|
||||
PreparedStatement outStatement = null;
|
||||
Guild charGuild;
|
||||
Guild victimGuild;
|
||||
Zone zone;
|
||||
PreparedStatement outStatement = null;
|
||||
|
||||
String queryString = "INSERT INTO `warehouse_pvphistory` (`char_id`, `char_guild_id`, `char_nation_id`, `char_level`," +
|
||||
" `victim_id`, `victim_guild_id`, `victim_nation_id`, `victim_level`," +
|
||||
" `zone_id`, `zone_name`, `loc_x`, `loc_y`, `gave_exp`, `datetime`) " +
|
||||
" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
String queryString = "INSERT INTO `warehouse_pvphistory` (`char_id`, `char_guild_id`, `char_nation_id`, `char_level`," +
|
||||
" `victim_id`, `victim_guild_id`, `victim_nation_id`, `victim_level`," +
|
||||
" `zone_id`, `zone_name`, `loc_x`, `loc_y`, `gave_exp`, `datetime`) " +
|
||||
" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
outStatement = connection.prepareStatement(queryString);
|
||||
|
||||
charGuild = this.player.getGuild();
|
||||
victimGuild = this.victim.getGuild();
|
||||
charGuild = this.player.getGuild();
|
||||
victimGuild = this.victim.getGuild();
|
||||
|
||||
// Use a proxy in the situation where a char guild is null (errant)
|
||||
// Use a proxy in the situation where a char guild is null (errant)
|
||||
|
||||
|
||||
// Retrieve the zone name where the PvP event occurred
|
||||
|
||||
zone = ZoneManager.findSmallestZone(this.location);
|
||||
// Retrieve the zone name where the PvP event occurred
|
||||
|
||||
outStatement.setString(1, DataWarehouse.hasher.encrypt(this.player.getObjectUUID()));
|
||||
outStatement.setString(2, DataWarehouse.hasher.encrypt(charGuild.getObjectUUID()));
|
||||
outStatement.setString(3, DataWarehouse.hasher.encrypt(charGuild.getNation().getObjectUUID()));
|
||||
outStatement.setInt(4, this.player.getLevel());
|
||||
zone = ZoneManager.findSmallestZone(this.location);
|
||||
|
||||
// Bind victim data
|
||||
outStatement.setString(1, DataWarehouse.hasher.encrypt(this.player.getObjectUUID()));
|
||||
outStatement.setString(2, DataWarehouse.hasher.encrypt(charGuild.getObjectUUID()));
|
||||
outStatement.setString(3, DataWarehouse.hasher.encrypt(charGuild.getNation().getObjectUUID()));
|
||||
outStatement.setInt(4, this.player.getLevel());
|
||||
|
||||
outStatement.setString(5, DataWarehouse.hasher.encrypt(this.victim.getObjectUUID()));
|
||||
outStatement.setString(6, DataWarehouse.hasher.encrypt(victimGuild.getObjectUUID()));
|
||||
outStatement.setString(7, DataWarehouse.hasher.encrypt(victimGuild.getNation().getObjectUUID()));
|
||||
outStatement.setInt(8, this.victim.getLevel());
|
||||
// Bind victim data
|
||||
|
||||
outStatement.setString(9, DataWarehouse.hasher.encrypt(zone.getObjectUUID()));
|
||||
outStatement.setString(10, zone.getName());
|
||||
outStatement.setFloat(11, this.location.getX());
|
||||
outStatement.setFloat(12, -this.location.getZ()); // flip sign on 'y' coordinate
|
||||
outStatement.setBoolean(13, this.pvpExp);
|
||||
outStatement.setTimestamp(14, Timestamp.valueOf(LocalDateTime.now()));
|
||||
outStatement.setString(5, DataWarehouse.hasher.encrypt(this.victim.getObjectUUID()));
|
||||
outStatement.setString(6, DataWarehouse.hasher.encrypt(victimGuild.getObjectUUID()));
|
||||
outStatement.setString(7, DataWarehouse.hasher.encrypt(victimGuild.getNation().getObjectUUID()));
|
||||
outStatement.setInt(8, this.victim.getLevel());
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
outStatement.setString(9, DataWarehouse.hasher.encrypt(zone.getObjectUUID()));
|
||||
outStatement.setString(10, zone.getName());
|
||||
outStatement.setFloat(11, this.location.getX());
|
||||
outStatement.setFloat(12, -this.location.getZ()); // flip sign on 'y' coordinate
|
||||
outStatement.setBoolean(13, this.pvpExp);
|
||||
outStatement.setTimestamp(14, Timestamp.valueOf(LocalDateTime.now()));
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
public void write() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildPvPInsertStatement(connection)) {
|
||||
public void write() {
|
||||
|
||||
statement.execute();
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement statement = buildPvPInsertStatement(connection)) {
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
statement.execute();
|
||||
|
||||
// Warehouse record for this pvp event written if code path reaches here.
|
||||
// Time to update the respective kill counters.
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e.toString());
|
||||
}
|
||||
|
||||
CharacterRecord.advanceKillCounter(this.player);
|
||||
CharacterRecord.advanceDeathCounter(this.victim);
|
||||
// Warehouse record for this pvp event written if code path reaches here.
|
||||
// Time to update the respective kill counters.
|
||||
|
||||
}
|
||||
CharacterRecord.advanceKillCounter(this.player);
|
||||
CharacterRecord.advanceDeathCounter(this.victim);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,7 @@ public class RealmRecord extends DataRecord {
|
||||
if (realmRecord == null) {
|
||||
realmRecord = new RealmRecord(realm);
|
||||
realmRecord.eventType = eventType;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
realmRecord.recordType = Enum.DataRecordType.REALM;
|
||||
realmRecord.eventType = eventType;
|
||||
realmRecord.realm = realm;
|
||||
@@ -57,7 +56,7 @@ public class RealmRecord extends DataRecord {
|
||||
realmRecord.charterType = Enum.CharterType.getCharterTypeByID(realmRecord.realm.getCharterType()).name();
|
||||
|
||||
if (realmRecord.eventType.equals(Enum.RecordEventType.CAPTURE))
|
||||
realmRecord.eventDateTime = realm.ruledSince;
|
||||
realmRecord.eventDateTime = realm.ruledSince;
|
||||
else
|
||||
realmRecord.eventDateTime = LocalDateTime.now();
|
||||
|
||||
@@ -122,7 +121,7 @@ public class RealmRecord extends DataRecord {
|
||||
outStatement.setString(4, cityHash);
|
||||
outStatement.setString(5, guildHash);
|
||||
outStatement.setString(6, eventType.name());
|
||||
outStatement.setTimestamp(7, Timestamp.valueOf(this.eventDateTime));
|
||||
outStatement.setTimestamp(7, Timestamp.valueOf(this.eventDateTime));
|
||||
|
||||
return outStatement;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user