From e6a7c8f5d2b74781de7d74ca54397b3865d1a7e4 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Sun, 27 Jul 2014 12:57:12 -0400 Subject: [PATCH] We need both UUID and username to create new. --- src/main/java/com/gmail/nossr50/api/ExperienceAPI.java | 4 ++-- .../nossr50/commands/database/ConvertDatabaseCommand.java | 2 +- .../java/com/gmail/nossr50/database/DatabaseManager.java | 7 ++----- .../gmail/nossr50/database/FlatfileDatabaseManager.java | 6 +++--- .../com/gmail/nossr50/database/SQLDatabaseManager.java | 6 +++--- .../nossr50/runnables/player/PlayerProfileLoadingTask.java | 2 +- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index aef29050b..dbfddb519 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/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(); diff --git a/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java b/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java index 92f6e008e..53fef1073 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java +++ b/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); diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java index 0e180d016..6b5e4c079 100644 --- a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java +++ b/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 diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index c30b4fac7..67e410f51 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/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) { diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index db31262e1..30c8a24a8 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/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) { diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java index 0cd1064fd..f6698cbdc 100644 --- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java +++ b/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);