Fix NPEs relating combat checks and world changing. Fixes #976, #979

This commit is contained in:
GJ 2013-04-22 23:19:26 -04:00
parent 7e67505dfb
commit 2ca7d139fe
3 changed files with 10 additions and 2 deletions

View File

@ -128,6 +128,10 @@ public class PlayerListener implements Listener {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer == null) {
return;
}
if (mcMMOPlayer.getGodMode() && !Permissions.mcgod(player)) {
mcMMOPlayer.toggleGodMode();
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));

View File

@ -29,5 +29,4 @@ public class MctopCommandAsyncTask extends BukkitRunnable {
new MctopCommandDisplayTask(userslist, page, tablePrefix, sender).runTaskLater(mcMMO.p, 1);
}
}

View File

@ -266,7 +266,7 @@ public final class CombatUtils {
if (target instanceof Player) {
Player player = (Player) target;
if (Misc.isNPCEntity(player)) {
if (Misc.isNPCEntity(player) || !player.isOnline()) {
return;
}
@ -291,6 +291,11 @@ public final class CombatUtils {
}
else if (attacker instanceof Player) {
Player player = (Player) attacker;
if (Misc.isNPCEntity(player)) {
return;
}
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
if (Permissions.mobHealthDisplay(player) && profile.getMobHealthbarType() != MobHealthbarType.DISABLED) {