mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-12-17 22:38:45 +01:00
Refactor DB code a bit and fix console spam when using the Plan plugin
Fixes #4450
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user