We need both UUID and username to create new.

This commit is contained in:
t00thpick1 2014-07-27 12:57:12 -04:00
parent fc393e1047
commit e6a7c8f5d2
6 changed files with 12 additions and 15 deletions

View File

@ -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();

View File

@ -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);

View File

@ -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

View File

@ -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) {

View File

@ -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) {

View File

@ -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);