Don't throw a warning if we're expecting a null object.

This commit is contained in:
gmcferrin 2013-08-21 14:20:12 +00:00
parent 51bf989418
commit 2bae937b28
5 changed files with 15 additions and 8 deletions

View File

@ -67,7 +67,7 @@ public abstract class ExperienceCommand implements TabExecutor {
} }
String playerName = Misc.getMatchedPlayerName(args[0]); String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
// 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 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) { if (mcMMOPlayer == null) {

View File

@ -58,7 +58,7 @@ public class SkillresetCommand extends ExperienceCommand {
} }
String playerName = Misc.getMatchedPlayerName(args[0]); String playerName = Misc.getMatchedPlayerName(args[0]);
mcMMOPlayer = UserManager.getPlayer(playerName); mcMMOPlayer = UserManager.getPlayer(playerName, true);
// 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 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) { if (mcMMOPlayer == null) {

View File

@ -34,7 +34,7 @@ public class InspectCommand implements TabExecutor {
} }
String playerName = Misc.getMatchedPlayerName(args[0]); String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
// 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 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) { if (mcMMOPlayer == null) {

View File

@ -52,7 +52,7 @@ public class McrankCommand implements TabExecutor {
} }
String playerName = Misc.getMatchedPlayerName(args[0]); String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
if (mcMMOPlayer != null) { if (mcMMOPlayer != null) {
playerName = mcMMOPlayer.getPlayer().getName(); playerName = mcMMOPlayer.getPlayer().getName();

View File

@ -77,7 +77,7 @@ public final class UserManager {
* @return the player's McMMOPlayer object * @return the player's McMMOPlayer object
*/ */
public static McMMOPlayer getPlayer(String playerName) { public static McMMOPlayer getPlayer(String playerName) {
return retrieveMcMMOPlayer(playerName); return retrieveMcMMOPlayer(playerName, false);
} }
/** /**
@ -87,17 +87,24 @@ public final class UserManager {
* @return the player's McMMOPlayer object * @return the player's McMMOPlayer object
*/ */
public static McMMOPlayer getPlayer(OfflinePlayer player) { public static McMMOPlayer getPlayer(OfflinePlayer player) {
return retrieveMcMMOPlayer(player.getName()); return retrieveMcMMOPlayer(player.getName(), false);
} }
private static McMMOPlayer retrieveMcMMOPlayer(String playerName) { public static McMMOPlayer getPlayer(String playerName, boolean offlineValid) {
return retrieveMcMMOPlayer(playerName, offlineValid);
}
private static McMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) {
McMMOPlayer mcMMOPlayer = players.get(playerName); McMMOPlayer mcMMOPlayer = players.get(playerName);
if (mcMMOPlayer == null) { if (mcMMOPlayer == null) {
Player player = mcMMO.p.getServer().getPlayerExact(playerName); Player player = mcMMO.p.getServer().getPlayerExact(playerName);
if (player == null) { if (player == null) {
mcMMO.p.getLogger().warning("A valid mcMMOPlayer object could not be found for " + playerName + "."); if (!offlineValid) {
mcMMO.p.getLogger().warning("A valid mcMMOPlayer object could not be found for " + playerName + ".");
}
return null; return null;
} }