Add some debug output when adding players fails

This commit is contained in:
Brokkonaut
2018-09-15 03:36:52 +02:00
parent 421f16784f
commit a55cbabbdd
2 changed files with 10 additions and 4 deletions

View File

@ -28,7 +28,7 @@ public class Actor {
return false;
}
final Actor other = (Actor) obj;
return this.UUID == null ? other.UUID == null : this.UUID.equals(other.UUID);
return (this.UUID == null) ? (other.UUID == null) : this.UUID.equals(other.UUID);
}
final String name;

View File

@ -473,7 +473,6 @@ public class Consumer extends Thread {
for (final Actor actor : r.getActors()) {
if (playerIDAsIntIncludeUncommited(actor) == null) {
if (!addPlayer(conn, actor)) {
logblock.getLogger().warning("[Consumer] Failed to add player " + actor.getName());
failOnActors = true; // skip this row
}
}
@ -621,10 +620,17 @@ public class Consumer extends Thread {
String name = actor.getName();
String uuid = actor.getUUID();
Statement state = conn.createStatement();
state.execute("INSERT IGNORE INTO `lb-players` (playername,UUID) SELECT '" + mysqlTextEscape(name) + "','" + mysqlTextEscape(uuid) + "' FROM `lb-players` WHERE NOT EXISTS (SELECT NULL FROM `lb-players` WHERE UUID = '" + mysqlTextEscape(uuid) + "') LIMIT 1;");
final ResultSet rs = state.executeQuery("SELECT playerid FROM `lb-players` WHERE UUID = '" + mysqlTextEscape(uuid) + "'");
String q1 = "INSERT IGNORE INTO `lb-players` (playername,UUID) SELECT '" + mysqlTextEscape(name) + "','" + mysqlTextEscape(uuid) + "' FROM `lb-players` WHERE NOT EXISTS (SELECT NULL FROM `lb-players` WHERE UUID = '" + mysqlTextEscape(uuid) + "') LIMIT 1;";
String q2 = "SELECT playerid FROM `lb-players` WHERE UUID = '" + mysqlTextEscape(uuid) + "'";
int q1Result = state.executeUpdate(q1);
final ResultSet rs = state.executeQuery(q2);
if (rs.next()) {
uncommitedPlayerIds.put(actor, rs.getInt(1));
} else {
logblock.getLogger().warning("[Consumer] Failed to add player " + actor.getName());
logblock.getLogger().warning("[Consumer-Debug] Query 1: " + q1);
logblock.getLogger().warning("[Consumer-Debug] Query 1 - Result: " + q1Result);
logblock.getLogger().warning("[Consumer-Debug] Query 2: " + q2);
}
rs.close();
state.close();