mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 19:54:44 +02:00
Refactor DB code a bit and fix console spam when using the Plan plugin
Fixes #4450
This commit is contained in:
@ -54,7 +54,7 @@ public class ConvertDatabaseCommand implements CommandExecutor {
|
||||
UserManager.clearAll();
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId());
|
||||
PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId(), null);
|
||||
|
||||
if (profile.isLoaded()) {
|
||||
mcMMO.getDatabaseManager().saveUser(profile);
|
||||
|
@ -22,7 +22,7 @@ public class McremoveCommand implements TabExecutor {
|
||||
if (args.length == 1) {
|
||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||
|
||||
if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
|
||||
if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -97,14 +97,20 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
UUID uuid = null;
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
uuid = player.getUniqueId();
|
||||
}
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
|
||||
OfflinePlayer offlinePlayer = mcMMO.p.getServer().getOfflinePlayer(playerName);
|
||||
PlayerProfile profile;
|
||||
|
||||
uuid = offlinePlayer.getUniqueId();
|
||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid, null);
|
||||
|
||||
//Check loading by UUID
|
||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
//Check loading by name
|
||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName);
|
||||
|
||||
if(CommandUtils.unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
editValues(null, profile, skill, value, isSilent(args));
|
||||
|
@ -80,13 +80,19 @@ public class SkillresetCommand implements TabExecutor {
|
||||
if (mcMMOPlayer == null) {
|
||||
UUID uuid = null;
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
uuid = player.getUniqueId();
|
||||
}
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
|
||||
uuid = player.getUniqueId();
|
||||
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid, playerName);
|
||||
|
||||
//Check loading by UUID
|
||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
//Didn't find it by UUID so try to find it by name
|
||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName);
|
||||
|
||||
//Check if it was present in DB
|
||||
if(CommandUtils.unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
editValues(null, profile, skill);
|
||||
|
@ -30,7 +30,7 @@ public class InspectCommand implements TabExecutor {
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName); // Temporary Profile
|
||||
|
||||
if (!CommandUtils.isLoaded(sender, profile)) {
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user