浏览代码

Load UUID with SQL

TfT_02 11 年之前
父节点
当前提交
69ebde052d
共有 1 个文件被更改,包括 9 次插入3 次删除
  1. 9 3
      src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java

+ 9 - 3
src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java

@@ -366,7 +366,12 @@ public final class SQLDatabaseManager implements DatabaseManager {
 
     private PlayerProfile loadPlayerProfile(String playerName, String uuid, boolean create, boolean retry) {
         if (!checkConnected()) {
-            return new PlayerProfile(playerName, false); // return fake profile if not connected
+            // return fake profile if not connected
+            if (uuid.isEmpty()) {
+                return new PlayerProfile(playerName, false);
+            }
+
+            return new PlayerProfile(playerName, UUID.fromString(uuid), false);
         }
 
         PreparedStatement statement = null;
@@ -1270,7 +1275,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
         Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>();     // Skill & XP
         Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
         MobHealthbarType mobHealthbarType;
-        UUID uuid = null;
+        UUID uuid;
 
         final int OFFSET_SKILLS = 0; // TODO update these numbers when the query changes (a new skill is added)
         final int OFFSET_XP = 13;
@@ -1326,9 +1331,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
         }
 
         try {
-            UUID.fromString(result.getString(OFFSET_OTHER + 3));
+            uuid = UUID.fromString(result.getString(OFFSET_OTHER + 3));
         }
         catch (Exception e) {
+            uuid = null;
         }
 
         return new PlayerProfile(playerName, uuid, skills, skillsXp, skillsDATS, mobHealthbarType);