瀏覽代碼

Update player name in case it has changed.

TODO: Check for double names if that happens? In general?
SLiPCoR 11 年之前
父節點
當前提交
d02058ca13
共有 1 個文件被更改,包括 14 次插入2 次删除
  1. 14 2
      src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java

+ 14 - 2
src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java

@@ -481,9 +481,21 @@ public final class SQLDatabaseManager implements DatabaseManager {
 
             if (result.next()) {
                 try {
-                    PlayerProfile ret = loadFromResult(playerName, result);
+                    PlayerProfile profile = loadFromResult(playerName, result);
                     result.close();
-                    return ret;
+
+                    if (!playerName.isEmpty() && !profile.getPlayerName().isEmpty()) {
+                        statement = connection.prepareStatement(
+                                "UPDATE `" + tablePrefix + "users` "
+                                        + "SET user = ? "
+                                        + "WHERE UUID = ?");
+                        statement.setString(1, playerName);
+                        statement.setString(2, uuid);
+                        result = statement.executeQuery();
+                        result.close();
+                    }
+
+                    return profile;
                 }
                 catch (SQLException e) {
                 }