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 e691b9a1c..383cd70a4 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsEventHandler.java @@ -51,6 +51,9 @@ public abstract class AcrobaticsEventHandler { * @return true if the damage is fatal, false otherwise */ protected boolean isFatal(int damage) { + if(player == null) + return true; + if (player.getHealth() - damage < 1) { return true; } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index d1d41cdd9..5361df9fa 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -26,6 +26,9 @@ public class AcrobaticsManager { * @param event The event to check */ public void rollCheck(EntityDamageEvent event) { + if(player == null) + return; + if (!permissionInstance.roll(player)) { return; } @@ -54,6 +57,9 @@ public class AcrobaticsManager { * @param event The event to check */ public void dodgeCheck(EntityDamageEvent event) { + if(player == null) + return; + if (!permissionInstance.dodge(player)) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/DodgeEventHandler.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/DodgeEventHandler.java index 9dec99742..6fe6064e9 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/DodgeEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/DodgeEventHandler.java @@ -39,11 +39,17 @@ public class DodgeEventHandler extends AcrobaticsEventHandler { @Override protected void sendAbilityMessage() { + if(player == null) + return; + player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc")); } @Override protected void processXPGain(int xp) { + if(player == null) + return; + PlayerProfile profile = manager.getProfile(); if (System.currentTimeMillis() >= profile.getRespawnATS() + 5) { diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java index 9700a000e..4ef6f39d4 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/RollEventHandler.java @@ -56,6 +56,9 @@ public class RollEventHandler extends AcrobaticsEventHandler { @Override protected void sendAbilityMessage() { + if(player == null) + return; + if (isGraceful) { player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc")); } @@ -67,6 +70,9 @@ public class RollEventHandler extends AcrobaticsEventHandler { @Override protected void processXPGain(int xpGain) { + if(player == null) + return; + Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xpGain); } @@ -74,6 +80,9 @@ public class RollEventHandler extends AcrobaticsEventHandler { * Check if this is a graceful roll. */ private void isGracefulRoll() { + if(player == null) + return; + if (Permissions.getInstance().gracefulRoll(player)) { this.isGraceful = player.isSneaking(); } diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index c9111cf10..d3f968abb 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -33,6 +33,9 @@ public class ArcheryManager { * @param livingEntity Entity damaged by the arrow */ public void trackArrows(LivingEntity livingEntity) { + if(player == null) + return; + if (!permissionsInstance.trackArrows(player)) { return; } @@ -57,6 +60,9 @@ public class ArcheryManager { * @param event The event to modify */ public void dazeCheck(Player defender, EntityDamageEvent event) { + if(player == null) + return; + if (!permissionsInstance.daze(player)) { return; } @@ -81,6 +87,9 @@ public class ArcheryManager { * @param event The event to modify. */ public void bonusDamage(EntityDamageEvent event) { + if(player == null) + return; + if (!permissionsInstance.archeryBonus(player)) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/combat/Axes.java b/src/main/java/com/gmail/nossr50/skills/combat/Axes.java index 39393d704..a7acc6c48 100644 --- a/src/main/java/com/gmail/nossr50/skills/combat/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/combat/Axes.java @@ -30,6 +30,9 @@ public class Axes { * @param event The event to modify */ public static void axesBonus(Player attacker, EntityDamageByEntityEvent event) { + if(attacker == null) + return; + final int MAX_BONUS = 4; /* Add 1 DMG for every 50 skill levels */ @@ -49,6 +52,9 @@ public class Axes { * @param event The event to modify */ public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event) { + if(attacker == null) + return; + Entity entity = event.getEntity(); if (entity instanceof Tameable) { @@ -104,6 +110,8 @@ public class Axes { */ @SuppressWarnings("deprecation") public static void impact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) { + if(attacker == null) + return; /* * TODO: Finish this skill. The idea is you will greatly damage an opponents armor. @@ -140,6 +148,9 @@ public class Axes { * @param event The event to modify */ private static void applyGreaterImpact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) { + if(attacker == null) + return; + final int GREATER_IMPACT_CHANCE = 25; final double GREATER_IMPACT_MULTIPLIER = 1.5; @@ -167,6 +178,9 @@ public class Axes { * @return true if the player has armor, false otherwise */ private static boolean hasArmor(Player player) { + if(player == null) + return false; + PlayerInventory inventory = player.getInventory(); if (inventory.getBoots() != null || inventory.getChestplate() != null || inventory.getHelmet() != null || inventory.getLeggings() != null) { diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/gathering/BlastMining.java index f0a49c13a..36fa41306 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/BlastMining.java @@ -82,6 +82,9 @@ public class BlastMining { * @param event Event whose explosion is being processed */ public static void dropProcessing(Player player, EntityExplodeEvent event) { + if(player == null) + return; + final int RANK_1_LEVEL = 125; final int RANK_2_LEVEL = 250; final int RANK_3_LEVEL = 375; @@ -172,6 +175,9 @@ public class BlastMining { * @param event Event whose explosion radius is being changed */ public static void biggerBombs(Player player, ExplosionPrimeEvent event) { + if(player == null) + return; + final int RANK_1_LEVEL = 250; final int RANK_2_LEVEL = 500; final int RANK_3_LEVEL = 750; @@ -210,6 +216,9 @@ public class BlastMining { * @param event Event whose explosion damage is being reduced */ public static void demolitionsExpertise(Player player, EntityDamageEvent event) { + if(player == null) + return; + final int RANK_1_LEVEL = 500; final int RANK_2_LEVEL = 750; final int RANK_3_LEVEL = 1000; @@ -242,6 +251,9 @@ public class BlastMining { * @param plugin mcMMO plugin instance */ public static void detonate(PlayerInteractEvent event, Player player, mcMMO plugin) { + if(player == null) + return; + PlayerProfile profile = Users.getProfile(player); if (profile.getSkillLevel(SkillType.MINING) < 125) diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java b/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java index 5d074bd4a..8f5c5823d 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java @@ -37,6 +37,9 @@ public class Excavation { * @param player The player who broke the block */ public static void excavationProcCheck(Block block, Player player) { + if(player == null) + return; + Material type = block.getType(); Location location = block.getLocation(); @@ -122,6 +125,9 @@ public class Excavation { * @param block The block to check */ public static void gigaDrillBreaker(Player player, Block block) { + if(player == null) + return; + Skills.abilityDurabilityLoss(player.getItemInHand(), Config.getInstance().getAbilityToolDamage()); if (!mcMMO.placeStore.isTrue(block) && !Misc.blockBreakSimulate(block, player, true)) { diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java index b8e17fea4..24e837814 100755 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -72,6 +72,9 @@ public class Fishing { * @param event The event to modify */ private static void getFishingResults(Player player, PlayerFishEvent event) { + if(player == null) + return; + PlayerProfile profile = Users.getProfile(player); List rewards = new ArrayList(); Item theCatch = (Item) event.getCaught(); @@ -135,6 +138,9 @@ public class Fishing { */ public static void processResults(PlayerFishEvent event) { Player player = event.getPlayer(); + if(player == null) + return; + PlayerProfile profile = Users.getProfile(player); getFishingResults(player, event); diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java index ee5f9e014..9443325e4 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java @@ -37,6 +37,9 @@ public class Herbalism { * @param block The block to be changed by Green Terra */ public static void greenTerra(Player player, Block block) { + if(player == null) + return; + PlayerInventory inventory = player.getInventory(); boolean hasSeeds = inventory.contains(Material.SEEDS); @@ -51,6 +54,9 @@ public class Herbalism { } public static void greenTerraConvert(Player player, Block block) { + if(player == null) + return; + Material type = block.getType(); if (Misc.blockBreakSimulate(block, player, false)) { @@ -77,6 +83,9 @@ public class Herbalism { * @param plugin mcMMO plugin instance */ public static void herbalismProcCheck(final Block block, Player player, BlockBreakEvent event, mcMMO plugin) { + if(player == null) + return; + final PlayerProfile profile = Users.getProfile(player); final int MAX_BONUS_LEVEL = 1000; @@ -372,6 +381,9 @@ public class Herbalism { * @param plugin mcMMO plugin instance */ private static void greenThumbWheat(Block block, Player player, BlockBreakEvent event, mcMMO plugin) { + if(player == null) + return; + final int MAX_BONUS_LEVEL = 1500; PlayerProfile profile = Users.getProfile(player); @@ -407,6 +419,9 @@ public class Herbalism { * @param block The block being used in the ability */ public static void greenThumbBlocks(ItemStack is, Player player, Block block) { + if(player == null) + return; + final int MAX_BONUS_LEVEL = 1500; PlayerProfile profile = Users.getProfile(player); diff --git a/src/main/java/com/gmail/nossr50/skills/swords/CounterAttackEventHandler.java b/src/main/java/com/gmail/nossr50/skills/swords/CounterAttackEventHandler.java index b34456ec6..e36936c17 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/CounterAttackEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/CounterAttackEventHandler.java @@ -24,6 +24,9 @@ public class CounterAttackEventHandler { } protected boolean isHoldingSword() { + if(player == null) + return false; + return ItemChecks.isSword(player.getItemInHand()); } @@ -36,6 +39,9 @@ public class CounterAttackEventHandler { } protected void sendAbilityMessages() { + if(player == null) + return; + player.sendMessage(LocaleLoader.getString("Swords.Combat.Countered")); if (attacker instanceof Player) { diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SerratedStrikesEventHandler.java b/src/main/java/com/gmail/nossr50/skills/swords/SerratedStrikesEventHandler.java index c2ba02ebd..c61c553fa 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SerratedStrikesEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SerratedStrikesEventHandler.java @@ -19,6 +19,9 @@ public class SerratedStrikesEventHandler { } protected void applyAbilityEffects() { + if(player == null) + return; + Combat.applyAbilityAoE(player, target, damage / Swords.SERRATED_STRIKES_MODIFIER, SkillType.SWORDS); BleedTimer.add(target, Swords.SERRATED_STRIKES_BLEED_TICKS); } diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index 84aff182d..f91712b83 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -28,6 +28,9 @@ public class SwordsManager { * @param defender The defending entity */ public void bleedCheck(LivingEntity defender) { + if(player == null) + return; + if (!permissionsInstance.swordsBleed(player)) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java index b2688039c..95816498c 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/BeastLoreEventHandler.java @@ -19,6 +19,9 @@ public class BeastLoreEventHandler { } protected void sendInspectMessage() { + if(player == null) + return; + String message = LocaleLoader.getString("Combat.BeastLore") + " "; if (beast.isTamed()) { diff --git a/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java index a35b99e72..84ad5d2a1 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java @@ -29,10 +29,16 @@ public class CallOfTheWildEventHandler { } protected void sendInsufficientAmountMessage() { + if(player == null) + return; + player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GRAY + Misc.prettyItemString(inHand.getTypeId())); } protected boolean nearbyEntityExists() { + if(player == null) + return false; + boolean entityExists = false; for (Entity entity : player.getNearbyEntities(40, 40, 40)) { @@ -46,6 +52,9 @@ public class CallOfTheWildEventHandler { } protected void sendFailureMessage() { + if(player == null) + return; + if (type == EntityType.OCELOT) { player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Ocelot")); } @@ -55,6 +64,9 @@ public class CallOfTheWildEventHandler { } protected void spawnCreature() { + if(player == null) + return; + LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type); entity.setMetadata("mcmmoSummoned", new FixedMetadataValue(mcMMO.p, true)); @@ -69,6 +81,9 @@ public class CallOfTheWildEventHandler { } protected void processResourceCost() { + if(player == null) + return; + int newAmount = inHand.getAmount() - summonAmount; if (newAmount == 0) { @@ -80,6 +95,9 @@ public class CallOfTheWildEventHandler { } protected void sendSuccessMessage() { + if(player == null) + return; + player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete")); } } diff --git a/src/main/java/com/gmail/nossr50/skills/taming/EnvironmentallyAwareEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/EnvironmentallyAwareEventHandler.java index 01a0eba27..07c8a3fa1 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/EnvironmentallyAwareEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/EnvironmentallyAwareEventHandler.java @@ -18,6 +18,9 @@ public class EnvironmentallyAwareEventHandler { } protected void teleportWolf() { + if(player == null) + return; + if (event.getDamage() > wolf.getHealth()) { return; } @@ -26,6 +29,9 @@ public class EnvironmentallyAwareEventHandler { } protected void sendAbilityMessage() { + if(player == null) + return; + player.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf")); } diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index b75afb633..eb946fa6f 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -36,6 +36,9 @@ public class TamingManager { * @param damage The damage being absorbed by the wolf */ public void fastFoodService(Wolf wolf, int damage) { + if(player == null) + return; + if (!permissionsInstance.fastFoodService(player)) { return; } @@ -61,6 +64,9 @@ public class TamingManager { * @param event The event to modify */ public void sharpenedClaws(EntityDamageEvent event) { + if(player == null) + return; + if (!permissionsInstance.sharpenedClaws(player)) { return; } @@ -78,6 +84,9 @@ public class TamingManager { * @param event The event to modify */ public void gore(EntityDamageEvent event) { + if(player == null) + return; + if (!permissionsInstance.gore(player)) { return; } @@ -150,6 +159,9 @@ public class TamingManager { * @param livingEntity The entity to examine */ public void beastLore(LivingEntity livingEntity) { + if(player == null) + return; + if (!permissionsInstance.beastLore(player)) { return; } @@ -166,6 +178,9 @@ public class TamingManager { * @param summonAmount The amount of material needed to summon the entity */ private void callOfTheWild(EntityType type, int summonAmount) { + if(player == null) + return; + if (!permissionsInstance.callOfTheWild(player)) { return; } @@ -198,6 +213,9 @@ public class TamingManager { * @param cause The damage cause of the event */ private void environmentallyAware(EntityDamageEvent event, DamageCause cause) { + if(player == null) + return; + if (!permissionsInstance.environmentallyAware(player)) { return; } @@ -230,6 +248,9 @@ public class TamingManager { * @param cause The damage cause of the event */ private void thickFur(EntityDamageEvent event, DamageCause cause) { + if(player == null) + return; + if (!permissionsInstance.thickFur(player)) { return; } @@ -247,6 +268,9 @@ public class TamingManager { * @param event The event to modify */ private void shockProof(EntityDamageEvent event) { + if(player == null) + return; + if (!permissionsInstance.shockProof(player)) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index dd04ecffb..4e49fde92 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -27,6 +27,9 @@ public class UnarmedManager { * @param defender The defending player */ public void disarmCheck(Player defender) { + if(player == null) + return; + if (!permissionsInstance.disarm(player)) { return; } @@ -58,6 +61,9 @@ public class UnarmedManager { * @param event The event to modify */ public void deflectCheck(EntityDamageEvent event) { + if(player == null) + return; + if (!permissionsInstance.deflect(player)) { return; } @@ -82,6 +88,9 @@ public class UnarmedManager { * @param event The event to modify. */ public void bonusDamage(EntityDamageEvent event) { + if(player == null) + return; + if (!permissionsInstance.unarmedBonus(player)) { return; } @@ -99,6 +108,9 @@ public class UnarmedManager { * @return true if the defender was not disarmed, false otherwise */ private boolean hasIronGrip(Player defender) { + if(defender == null) + return false; + if (!permissionsInstance.ironGrip(defender)) { return false; }