From 9463e210b8fe60d2517f1c438faee28291e15dc2 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 4 Apr 2013 07:42:33 -0400 Subject: [PATCH] Compact our checks. --- .../gmail/nossr50/datatypes/player/McMMOPlayer.java | 6 +----- .../com/gmail/nossr50/listeners/BlockListener.java | 12 ++---------- .../com/gmail/nossr50/listeners/PlayerListener.java | 12 ++---------- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index afc477572..6c1a006f2 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -650,11 +650,7 @@ public class McMMOPlayer { * @return Modified experience */ private int modifyXpGain(SkillType skillType, int xp) { - if (player.getGameMode() == GameMode.CREATIVE) { - return 0; - } - - if ((skillType.getMaxLevel() < profile.getSkillLevel(skillType) + 1) || (Config.getInstance().getPowerLevelCap() < getPowerLevel() + 1)) { + if (player.getGameMode() == GameMode.CREATIVE || (skillType.getMaxLevel() < profile.getSkillLevel(skillType) + 1) || (Config.getInstance().getPowerLevelCap() < getPowerLevel() + 1)) { return 0; } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 469f0c7a4..a6af7e72d 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -131,11 +131,7 @@ public class BlockListener implements Listener { Player player = event.getPlayer(); - if (Misc.isNPCEntity(player)) { - return; - } - - if (player.getGameMode() == GameMode.CREATIVE) { + if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) { return; } @@ -208,11 +204,7 @@ public class BlockListener implements Listener { Player player = event.getPlayer(); - if (Misc.isNPCEntity(player)) { - return; - } - - if (player.getGameMode() == GameMode.CREATIVE) { + if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) { return; } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index a3de299e3..a8352ed60 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -279,11 +279,7 @@ public class PlayerListener implements Listener { public void onPlayerInteractLowest(PlayerInteractEvent event) { Player player = event.getPlayer(); - if (Misc.isNPCEntity(player)) { - return; - } - - if (player.getGameMode() == GameMode.CREATIVE) { + if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) { return; } @@ -342,11 +338,7 @@ public class PlayerListener implements Listener { public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - if (Misc.isNPCEntity(player)) { - return; - } - - if (player.getGameMode() == GameMode.CREATIVE) { + if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) { return; }