diff --git a/CHANGELOG.md b/CHANGELOG.md index 2766c01..24ac40a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### Added: - ### Fixed: -- Fixed level saving +- Fixed npe +- ### Changed: - \ No newline at end of file diff --git a/src/main/java/net/levelz/util/BonusHelper.java b/src/main/java/net/levelz/util/BonusHelper.java index 7d7131d..f29dc32 100644 --- a/src/main/java/net/levelz/util/BonusHelper.java +++ b/src/main/java/net/levelz/util/BonusHelper.java @@ -75,7 +75,7 @@ public static void crossbowBonus(LivingEntity shooter, ProjectileEntity projecti } public static boolean itemDamageChanceBonus(@Nullable PlayerEntity playerEntity) { - if (LevelManager.BONUSES.containsKey("itemDamageChance")) { + if (playerEntity != null && LevelManager.BONUSES.containsKey("itemDamageChance")) { LevelManager levelManager = ((LevelManagerAccess) playerEntity).getLevelManager(); SkillBonus skillBonus = LevelManager.BONUSES.get("itemDamageChance"); int level = levelManager.getPlayerSkills().get(skillBonus.getId()).getLevel(); @@ -86,8 +86,8 @@ public static boolean itemDamageChanceBonus(@Nullable PlayerEntity playerEntity) return false; } - public static StatusEffectInstance potionEffectChanceBonus(PlayerEntity playerEntity, StatusEffectInstance statusEffectInstance) { - if (LevelManager.BONUSES.containsKey("potionEffectChance")) { + public static StatusEffectInstance potionEffectChanceBonus(@Nullable PlayerEntity playerEntity, StatusEffectInstance statusEffectInstance) { + if (playerEntity != null && LevelManager.BONUSES.containsKey("potionEffectChance")) { LevelManager levelManager = ((LevelManagerAccess) playerEntity).getLevelManager(); SkillBonus skillBonus = LevelManager.BONUSES.get("potionEffectChance"); int level = levelManager.getPlayerSkills().get(skillBonus.getId()).getLevel();