Null check ALL the profiles.

We should probably find a more elegant way to do this, though.
This commit is contained in:
GJ 2012-07-10 14:02:48 -04:00
parent 07c66378c0
commit 686bcd5308
4 changed files with 37 additions and 4 deletions

View File

@ -130,6 +130,10 @@ public class EntityListener implements Listener {
PlayerProfile profile = Users.getProfile(player); PlayerProfile profile = Users.getProfile(player);
if (profile == null) {
return;
}
if (profile.getGodMode()) { if (profile.getGodMode()) {
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -59,6 +59,10 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlayerProfile profile = Users.getProfile(player); PlayerProfile profile = Users.getProfile(player);
if (profile == null) {
return;
}
if (profile.getGodMode()) { if (profile.getGodMode()) {
if (!Permissions.getInstance().mcgod(player)) { if (!Permissions.getInstance().mcgod(player)) {
profile.toggleGodMode(); profile.toggleGodMode();
@ -110,7 +114,13 @@ public class PlayerListener implements Listener {
*/ */
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) { public void onPlayerPickupItem(PlayerPickupItemEvent event) {
if (Users.getProfile(event.getPlayer()).getAbilityMode(AbilityType.BERSERK)) { PlayerProfile profile = Users.getProfile(event.getPlayer());
if (profile == null) {
return;
}
if (profile.getAbilityMode(AbilityType.BERSERK)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -190,7 +200,11 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerRespawn(PlayerRespawnEvent event) { public void onPlayerRespawn(PlayerRespawnEvent event) {
Users.getProfile(event.getPlayer()).actualizeRespawnATS(); PlayerProfile profile = Users.getProfile(event.getPlayer());
if (profile != null) {
profile.actualizeRespawnATS();
}
} }
/** /**

View File

@ -41,8 +41,15 @@ public class PartyManager {
* @return true if they are in the same party, false otherwise * @return true if they are in the same party, false otherwise
*/ */
public boolean inSameParty(Player firstPlayer, Player secondPlayer) { public boolean inSameParty(Player firstPlayer, Player secondPlayer) {
Party firstParty = Users.getProfile(firstPlayer).getParty(); PlayerProfile firstProfile = Users.getProfile(firstPlayer);
Party secondParty = Users.getProfile(secondPlayer).getParty(); PlayerProfile secondProfile = Users.getProfile(secondPlayer);
if (firstProfile == null || secondProfile == null) {
return false;
}
Party firstParty = firstProfile.getParty();
Party secondParty = secondProfile.getParty();
if (firstParty == null || secondParty == null || firstParty != secondParty) { if (firstParty == null || secondParty == null || firstParty != secondParty) {
return false; return false;

View File

@ -107,6 +107,10 @@ public class Skills {
} }
/* Check if any abilities are active */ /* Check if any abilities are active */
if (profile == null) {
return;
}
if (!profile.getAbilityUse()) { if (!profile.getAbilityUse()) {
return; return;
} }
@ -151,6 +155,10 @@ public class Skills {
ToolType tool = skill.getTool(); ToolType tool = skill.getTool();
AbilityType ability = skill.getAbility(); AbilityType ability = skill.getAbility();
if (profile == null) {
return;
}
if (profile.getToolPreparationMode(tool) && curTime - (profile.getToolPreparationATS(tool) * TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) { if (profile.getToolPreparationMode(tool) && curTime - (profile.getToolPreparationATS(tool) * TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) {
profile.setToolPreparationMode(tool, false); profile.setToolPreparationMode(tool, false);