Merge pull request #143 from mlus-asuka/1.20.1-dev

2.1.4 update
This commit is contained in:
mlus 2025-11-22 23:01:31 +08:00 committed by GitHub
commit d78c84d8ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 6 deletions

View File

@ -142,8 +142,8 @@ public class VanillaSync {
try { try {
String player_uuid = event.getProfile().getId().toString(); String player_uuid = event.getProfile().getId().toString();
PlayerSync.LOGGER.info("Detected connection from player" + player_uuid + ",starting checking"); PlayerSync.LOGGER.info("Detected connection from player" + player_uuid + ",starting checking");
boolean online = false; boolean online;
int lastServer = -1; int lastServer;
// First query: check basic player data and check whether player can join into server. // First query: check basic player data and check whether player can join into server.
JDBCsetUp.QueryResult qr1 = JDBCsetUp.executeQuery("SELECT online, last_server FROM player_data WHERE uuid='" + player_uuid + "'"); JDBCsetUp.QueryResult qr1 = JDBCsetUp.executeQuery("SELECT online, last_server FROM player_data WHERE uuid='" + player_uuid + "'");
@ -410,8 +410,7 @@ public class VanillaSync {
dynamicTagInput, dynamicTagInput,
snbtDataVersion, snbtDataVersion,
currentDataVersion); currentDataVersion);
CompoundTag compoundTag = (CompoundTag) updatedDynamicTag.getValue(); return (CompoundTag) updatedDynamicTag.getValue();
return compoundTag;
} }
/** /**

View File

@ -49,7 +49,7 @@ public class JDBCsetUp {
Connection connection = getConnection(); // With database selected (and "USE" already run) Connection connection = getConnection(); // With database selected (and "USE" already run)
PreparedStatement queryStatement = connection.prepareStatement(sql); PreparedStatement queryStatement = connection.prepareStatement(sql);
ResultSet resultSet = queryStatement.executeQuery(); ResultSet resultSet = queryStatement.executeQuery();
return new QueryResult(connection, resultSet); return new QueryResult(connection, queryStatement, resultSet);
} }
/** /**
@ -94,7 +94,7 @@ public class JDBCsetUp {
} }
} }
public record QueryResult(Connection connection, ResultSet resultSet) implements AutoCloseable { public record QueryResult(Connection connection,PreparedStatement preparedStatement, ResultSet resultSet) implements AutoCloseable {
@Override @Override
public void close() { public void close() {
if (resultSet != null) { if (resultSet != null) {
@ -105,6 +105,14 @@ public class JDBCsetUp {
} }
} }
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException e) {
LOGGER.error("Error closing PreparedStatement", e);
}
}
if (connection != null) { if (connection != null) {
try { try {
connection.close(); connection.close();