Fix a NPE when trying to join a non-existing player

Fixes #860
This commit is contained in:
TfT_02 2013-03-21 22:04:52 +01:00
parent 9730cdb880
commit 70160468c0
3 changed files with 9 additions and 5 deletions

View File

@ -17,6 +17,7 @@ Version 1.4.04-dev
= Fixed bug where Shake wouldn't damage mobs whose max health was less than 4
= Fixed bug where the API would fail if the name of a player's current party is requested when the player isn't in one (Thanks @dualspiral!)
= Fixed bug with retrieving a player's party members
= Fixed bug which caused an NPE when trying to join a non-existing player
! Updated localization files
- Removed deprecated functions from API classes.
- Removed functions for getting the PlayerProfile - using API classes is preferred, but if not the McMMOPlayer should be used instead

View File

@ -31,6 +31,9 @@ public class PartyJoinCommand implements CommandExecutor {
return true;
}
mcMMOPlayer = UserManager.getPlayer(args[1]);
player = mcMMOPlayer.getPlayer();
String password = getPassword(args);
// Make sure party passwords match
@ -63,8 +66,8 @@ public class PartyJoinCommand implements CommandExecutor {
private boolean canJoinParty(CommandSender sender, String targetName) {
mcMMOTarget = UserManager.getPlayer(targetName);
if (CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return true;
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
target = mcMMOTarget.getPlayer();

View File

@ -67,17 +67,17 @@ public final class CommandUtils {
public static boolean checkPlayerExistence(CommandSender sender, String playerName, McMMOPlayer mcMMOPlayer) {
if (mcMMOPlayer != null) {
return false;
return true;
}
PlayerProfile playerProfile = new PlayerProfile(playerName, false);
if (unloadedProfile(sender, playerProfile)) {
return true;
return false;
}
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
return true;
return false;
}
public static boolean unloadedProfile(CommandSender sender, PlayerProfile profile) {