mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-31 01:03:44 +01:00 
			
		
		
		
	Don't throw a warning if we're expecting a null object.
This commit is contained in:
		| @@ -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) { | ||||||
|   | |||||||
| @@ -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) { | ||||||
|   | |||||||
| @@ -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) { | ||||||
|   | |||||||
| @@ -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(); | ||||||
|   | |||||||
| @@ -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) { | ||||||
|  |             	if (!offlineValid) { | ||||||
|                     mcMMO.p.getLogger().warning("A valid mcMMOPlayer object could not be found for " + playerName + "."); |                     mcMMO.p.getLogger().warning("A valid mcMMOPlayer object could not be found for " + playerName + "."); | ||||||
|  |             	} | ||||||
|  |  | ||||||
|                 return null; |                 return null; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 gmcferrin
					gmcferrin