mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Null check ALL the profiles.
We should probably find a more elegant way to do this, though.
This commit is contained in:
parent
07c66378c0
commit
686bcd5308
@ -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;
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user