From ad68f50b1433344525617d98ff0e5f5d88b97aab Mon Sep 17 00:00:00 2001 From: bm01 Date: Tue, 19 Feb 2013 01:46:50 +0100 Subject: [PATCH] Removed isNPCPlayer, isNPCEntity is identical --- .../nossr50/listeners/BlockListener.java | 10 +++++----- .../nossr50/listeners/EntityListener.java | 6 +++--- .../nossr50/listeners/PlayerListener.java | 20 +++++++++---------- .../acrobatics/AcrobaticsEventHandler.java | 2 +- .../nossr50/skills/mining/MiningManager.java | 4 ++-- .../skills/smelting/SmeltingManager.java | 4 ++-- .../nossr50/skills/utilities/CombatTools.java | 8 ++++---- .../java/com/gmail/nossr50/util/Misc.java | 9 --------- 8 files changed, 27 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 94bc51825..f8e67482b 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -103,7 +103,7 @@ public class BlockListener implements Listener { public void onBlockPlace(BlockPlaceEvent event) { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -139,7 +139,7 @@ public class BlockListener implements Listener { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -223,7 +223,7 @@ public class BlockListener implements Listener { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -252,7 +252,7 @@ public class BlockListener implements Listener { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -318,7 +318,7 @@ public class BlockListener implements Listener { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index fb8910827..c6c1dcb52 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -160,7 +160,7 @@ public class EntityListener implements Listener { if (livingEntity instanceof Player) { Player player = (Player) entity; - if (!player.isOnline() || Misc.isNPCPlayer(player)) { + if (!player.isOnline() || Misc.isNPCEntity(player)) { return; } @@ -296,7 +296,7 @@ public class EntityListener implements Listener { if (entity instanceof Player) { Player player = (Player) entity; - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -352,7 +352,7 @@ public class EntityListener implements Listener { public void onEntityTame(EntityTameEvent event) { Player player = (Player) event.getOwner(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(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 8870863ad..b4a8edc98 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -73,7 +73,7 @@ public class PlayerListener implements Listener { Player player = event.getEntity(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -97,7 +97,7 @@ public class PlayerListener implements Listener { public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -125,7 +125,7 @@ public class PlayerListener implements Listener { if (event.getResult() == Result.ALLOWED) { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -157,7 +157,7 @@ public class PlayerListener implements Listener { public void onPlayerFish(PlayerFishEvent event) { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player) || !Permissions.fishing(player)) { + if (Misc.isNPCEntity(player) || !Permissions.fishing(player)) { return; } @@ -192,7 +192,7 @@ public class PlayerListener implements Listener { Player player = event.getPlayer(); Item item = event.getItem(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -212,7 +212,7 @@ public class PlayerListener implements Listener { public void onPlayerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -251,7 +251,7 @@ public class PlayerListener implements Listener { public void onPlayerRespawn(PlayerRespawnEvent event) { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -267,7 +267,7 @@ public class PlayerListener implements Listener { public void onPlayerInteractLowest(PlayerInteractEvent event) { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -321,7 +321,7 @@ public class PlayerListener implements Listener { public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -407,7 +407,7 @@ public class PlayerListener implements Listener { public void onPlayerChat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java index 7180f473d..c2c441838 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java @@ -53,7 +53,7 @@ public abstract class AcrobaticsEventHandler { protected boolean isFatal(int damage) { Player player = manager.getMcMMOPlayer().getPlayer(); - if (Misc.isNPCPlayer(player) || player.getHealth() - damage < 1) { + if (Misc.isNPCEntity(player) || player.getHealth() - damage < 1) { return true; } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 7873f2c7d..0fb6c0141 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -56,7 +56,7 @@ public class MiningManager extends SkillManager{ * @param event Event whose explosion is being processed */ public void blastMiningDropProcessing(EntityExplodeEvent event) { - if (Misc.isNPCPlayer(mcMMOPlayer.getPlayer())) { + if (Misc.isNPCEntity(mcMMOPlayer.getPlayer())) { return; } @@ -93,7 +93,7 @@ public class MiningManager extends SkillManager{ * @param event Event whose explosion radius is being changed */ public void biggerBombs(ExplosionPrimeEvent event) { - if (Misc.isNPCPlayer(mcMMOPlayer.getPlayer())) { + if (Misc.isNPCEntity(mcMMOPlayer.getPlayer())) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index 68be5eaba..fde0bb686 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -26,7 +26,7 @@ public class SmeltingManager extends SkillManager { public void fuelEfficiency(FurnaceBurnEvent event) { Player player = mcMMOPlayer.getPlayer(); - if (Misc.isNPCPlayer(player) || !Permissions.fuelEfficiency(player)) { + if (Misc.isNPCEntity(player) || !Permissions.fuelEfficiency(player)) { return; } @@ -38,7 +38,7 @@ public class SmeltingManager extends SkillManager { public void smeltProcessing(FurnaceSmeltEvent event) { Player player = mcMMOPlayer.getPlayer(); - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java index 97d172e74..54b1fa1ad 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/CombatTools.java @@ -65,7 +65,7 @@ public final class CombatTools { if (attacker instanceof Player) { Player player = (Player) attacker; - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -193,7 +193,7 @@ public final class CombatTools { if (wolf.isTamed() && wolf.getOwner() instanceof Player) { Player master = (Player) wolf.getOwner(); - if (Misc.isNPCPlayer(master)) { + if (Misc.isNPCEntity(master)) { return; } @@ -256,7 +256,7 @@ public final class CombatTools { if (targetIsPlayer) { Player player = (Player) target; - if (Misc.isNPCPlayer(player)) { + if (Misc.isNPCEntity(player)) { return; } @@ -295,7 +295,7 @@ public final class CombatTools { * @param event The event to run the archery checks on. */ private static void archeryCheck(Player shooter, LivingEntity target, EntityDamageByEntityEvent event) { - if (Misc.isNPCPlayer(shooter)) { + if (Misc.isNPCEntity(shooter)) { return; } diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index 21ef79886..2f4fac3f2 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -6,7 +6,6 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; @@ -38,14 +37,6 @@ public final class Misc { return false; } - public static boolean isNPCPlayer(Player player) { - if (player == null || player.hasMetadata("NPC")) { - return true; - } - - return false; - } - /** * Get the upgrade tier of the item in hand. *