Fixing a multitude of reported NPEs.

This commit is contained in:
Glitchfinder 2013-08-04 12:15:01 -07:00
parent a2450d2d07
commit aeaab43f44
4 changed files with 31 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@ -40,7 +41,13 @@ public final class PartyAPI {
* @return true if the player is in a party, false otherwise * @return true if the player is in a party, false otherwise
*/ */
public static boolean inParty(Player player) { public static boolean inParty(Player player) {
return UserManager.getPlayer(player).inParty(); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer == null) {
return false;
}
return mcMMOPlayer.inParty();
} }
/** /**

View File

@ -215,6 +215,10 @@ public class EntityListener implements Listener {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer == null) {
return;
}
/* Check for invincibility */ /* Check for invincibility */
if (mcMMOPlayer.getGodMode()) { if (mcMMOPlayer.getGodMode()) {
event.setCancelled(true); event.setCancelled(true);

View File

@ -299,6 +299,11 @@ public class PlayerListener implements Listener {
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer == null) {
return;
}
Item drop = event.getItem(); Item drop = event.getItem();
ItemStack dropStack = drop.getItemStack(); ItemStack dropStack = drop.getItemStack();
@ -341,6 +346,10 @@ public class PlayerListener implements Listener {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer == null) {
return;
}
mcMMOPlayer.resetAbilityMode(); mcMMOPlayer.resetAbilityMode();
BleedTimerTask.bleedOut(player); BleedTimerTask.bleedOut(player);
mcMMOPlayer.getProfile().save(); mcMMOPlayer.getProfile().save();

View File

@ -139,6 +139,11 @@ public final class CombatUtils {
private static void processArcheryCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event, Entity arrow) { private static void processArcheryCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event, Entity arrow) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer == null) {
return;
}
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager(); ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
if (archeryManager.canSkillShot()) { if (archeryManager.canSkillShot()) {
@ -312,6 +317,11 @@ public final class CombatUtils {
Player player = (Player) target; Player player = (Player) target;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer == null) {
return;
}
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager(); AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
if (acrobaticsManager.canDodge(damager)) { if (acrobaticsManager.canDodge(damager)) {