Răsfoiți Sursa

We need both UUID and username to create new.

t00thpick1 11 ani în urmă
părinte
comite
e6a7c8f5d2

+ 2 - 2
src/main/java/com/gmail/nossr50/api/ExperienceAPI.java

@@ -930,7 +930,7 @@ public final class ExperienceAPI {
     }
 
     private static PlayerProfile getOfflineProfile(UUID uuid) {
-        PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid, false);
+        PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
 
         if (!profile.isLoaded()) {
             throw new InvalidPlayerException();
@@ -942,7 +942,7 @@ public final class ExperienceAPI {
     @Deprecated
     private static PlayerProfile getOfflineProfile(String playerName) {
         UUID uuid = mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId();
-        PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid, false);
+        PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
 
         if (!profile.isLoaded()) {
             throw new InvalidPlayerException();

+ 1 - 1
src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java

@@ -56,7 +56,7 @@ public class ConvertDatabaseCommand implements CommandExecutor {
                 UserManager.clearAll();
 
                 for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
-                    PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId(), false);
+                    PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId());
 
                     if (profile.isLoaded()) {
                         mcMMO.getDatabaseManager().saveUser(profile);

+ 2 - 5
src/main/java/com/gmail/nossr50/database/DatabaseManager.java

@@ -73,7 +73,7 @@ public interface DatabaseManager {
     /**
      * Load a player from the database.
      *
-     * @deprecated replaced by {@link #loadPlayerProfile(UUID uuid, boolean createNew)}
+     * @deprecated replaced by {@link #loadPlayerProfile(String playerName, UUID uuid, boolean createNew)}
      *
      * @param playerName The name of the player to load from the database
      * @param createNew Whether to create a new record if the player is not
@@ -88,12 +88,9 @@ public interface DatabaseManager {
      * Load a player from the database.
      *
      * @param uuid The uuid of the player to load from the database
-     * @param createNew Whether to create a new record if the player is not
-     *          found
      * @return The player's data, or an unloaded PlayerProfile if not found
-     *          and createNew is false
      */
-    public PlayerProfile loadPlayerProfile(UUID uuid, boolean createNew);
+    public PlayerProfile loadPlayerProfile(UUID uuid);
 
     /**
      * Load a player from the database. Attempt to use uuid, fall back on playername

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

@@ -388,11 +388,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
 
     @Deprecated
     public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
-        return loadPlayerProfile(playerName, "", create);
+        return loadPlayerProfile(playerName, "", false);
     }
 
-    public PlayerProfile loadPlayerProfile(UUID uuid, boolean create) {
-        return loadPlayerProfile("", uuid.toString(), create);
+    public PlayerProfile loadPlayerProfile(UUID uuid) {
+        return loadPlayerProfile("", uuid.toString(), false);
     }
 
     public PlayerProfile loadPlayerProfile(String playerName, UUID uuid, boolean create) {

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

@@ -688,11 +688,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
 
     @Deprecated
     public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
-        return loadPlayerProfile(playerName, "", create, true);
+        return loadPlayerProfile(playerName, "", false, true);
     }
 
-    public PlayerProfile loadPlayerProfile(UUID uuid, boolean create) {
-        return loadPlayerProfile("", uuid.toString(), create, true);
+    public PlayerProfile loadPlayerProfile(UUID uuid) {
+        return loadPlayerProfile("", uuid.toString(), false, true);
     }
 
     public PlayerProfile loadPlayerProfile(String playerName, UUID uuid, boolean create) {

+ 1 - 1
src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java

@@ -41,7 +41,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
 
         // Increment attempt counter and try
         attempt++;
-        PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getUniqueId(), true);
+        PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
         // If successful, schedule the apply
         if (profile.isLoaded()) {
             new ApplySuccessfulProfile(profile).runTask(mcMMO.p);