diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 12dd6fb49..efc5a2551 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -138,13 +138,13 @@ public class BlockListener implements Listener { } Player player = event.getPlayer(); - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); - PlayerProfile profile = mcMMOPlayer.getProfile(); - if (Misc.isNPCPlayer(player, mcMMOPlayer.getProfile())) { + if (Misc.isNPCPlayer(player)) { return; } + McMMOPlayer mcMMOPlayer = Users.getPlayer(player); + PlayerProfile profile = mcMMOPlayer.getProfile(); Block block = event.getBlock(); ItemStack heldItem = player.getItemInHand(); @@ -258,12 +258,12 @@ public class BlockListener implements Listener { } Player player = event.getPlayer(); - PlayerProfile profile = Users.getProfile(player); - if (Misc.isNPCPlayer(player, profile)) { + if (Misc.isNPCPlayer(player)) { return; } + PlayerProfile profile = Users.getProfile(player); Block block = event.getBlock(); /* @@ -313,13 +313,13 @@ public class BlockListener implements Listener { } Player player = event.getPlayer(); - McMMOPlayer mcMMOPlayer = Users.getPlayer(player); - PlayerProfile profile = mcMMOPlayer.getProfile(); - if (Misc.isNPCPlayer(player, profile)) { + if (Misc.isNPCPlayer(player)) { return; } + McMMOPlayer mcMMOPlayer = Users.getPlayer(player); + PlayerProfile profile = mcMMOPlayer.getProfile(); ItemStack heldItem = player.getItemInHand(); Block block = event.getBlock(); diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 0def65d51..cf18e1002 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -150,17 +150,13 @@ public class EntityListener implements Listener { if (livingEntity instanceof Player) { Player player = (Player) entity; - if (!player.isOnline()) { + if (!player.isOnline() || Misc.isNPCPlayer(player)) { return; } McMMOPlayer mcMMOPlayer = Users.getPlayer(player); PlayerProfile profile = mcMMOPlayer.getProfile(); - if (Misc.isNPCPlayer(player, profile)) { - return; - } - /* Check for invincibility */ if (profile.getGodMode()) { event.setCancelled(true); @@ -287,9 +283,8 @@ public class EntityListener implements Listener { if (entity instanceof Player) { Player player = (Player) entity; - PlayerProfile profile = Users.getProfile(player); - if (Misc.isNPCPlayer(player, profile)) { + if (Misc.isNPCPlayer(player)) { return; } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 1250dd2f9..6d61e3b92 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -57,12 +57,13 @@ public class PlayerListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) { Player player = event.getPlayer(); - PlayerProfile profile = Users.getProfile(player); - if (Misc.isNPCPlayer(player, profile)) { + if (Misc.isNPCPlayer(player)) { return; } + PlayerProfile profile = Users.getProfile(player); + if (profile.getGodMode() && !Permissions.mcgod(player)) { profile.toggleGodMode(); player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden")); @@ -170,12 +171,13 @@ public class PlayerListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerRespawn(PlayerRespawnEvent event) { Player player = event.getPlayer(); - PlayerProfile profile = Users.getProfile(player); - if (Misc.isNPCPlayer(player, profile)) { + if (Misc.isNPCPlayer(player)) { return; } + PlayerProfile profile = Users.getProfile(player); + profile.actualizeRespawnATS(); } @@ -327,12 +329,13 @@ public class PlayerListener implements Listener { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerChat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); - PlayerProfile profile = Users.getProfile(player); - if (Misc.isNPCPlayer(player, profile)) { + if (Misc.isNPCPlayer(player)) { return; } + PlayerProfile profile = Users.getProfile(player); + if (profile.getPartyChatMode()) { Party party = profile.getParty(); diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index b9e75029b..492b2565f 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -102,15 +102,7 @@ public final class Misc { } public static boolean isNPCPlayer(Player player) { - if (player == null || Users.getProfile(player) == null || player.hasMetadata("NPC")) { - return true; - } - - return false; - } - - public static boolean isNPCPlayer(Player player, PlayerProfile profile) { - if (player == null || profile == null || player.hasMetadata("NPC")) { + if (player == null || player.hasMetadata("NPC")) { return true; }