Fix username lookup returning "null" instead of null (#3220)

This commit is contained in:
Luck 2021-11-27 09:43:47 +00:00
parent 272d289d4a
commit 9204848ffb
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 8 additions and 2 deletions

View File

@ -573,7 +573,10 @@ public class MongoStorage implements StorageImplementation {
MongoCollection<Document> c = this.database.getCollection(this.prefix + "uuid");
Document doc = c.find(new Document("_id", uniqueId)).first();
if (doc != null) {
return doc.get("name", String.class);
String username = doc.get("name", String.class);
if (username != null && !username.equals("null")) {
return username;
}
}
return null;
}

View File

@ -694,7 +694,10 @@ public class SqlStorage implements StorageImplementation {
ps.setString(1, uniqueId.toString());
try (ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
return rs.getString("username");
String username = rs.getString("username");
if (username != null && !username.equals("null")) {
return username;
}
}
}
}