RepairManager: Fix unsafe enchantments being stripped, CombatUtils: Use instanceof for IronGolem (#5192)

* RepairManager: Fix unsafe enchantments being stripped

* CombatUtils: Use instanceof for IronGolem check to avoid cast exceptions for pets/npcs/...

---------

Co-authored-by: Dieu <info@l4b.org>
This commit is contained in:
Techirion
2025-07-09 23:23:34 +02:00
committed by GitHub
parent e6c62beed9
commit c377544fa2
2 changed files with 3 additions and 3 deletions

View File

@@ -411,7 +411,7 @@ public class RepairManager extends SkillManager {
if (enchantLevel > enchant.getKey().getMaxLevel()) {
enchantLevel = enchant.getKey().getMaxLevel();
item.addEnchantment(enchant.getKey(), enchantLevel);
item.addUnsafeEnchantment(enchant.getKey(), enchantLevel);
}
}

View File

@@ -961,8 +961,8 @@ public final class CombatUtils {
EntityType type = target.getType();
if (ExperienceConfig.getInstance().hasCombatXP(type)) {
if (type == EntityType.IRON_GOLEM) {
if (!((IronGolem) target).isPlayerCreated()) {
if (type == EntityType.IRON_GOLEM && target instanceof IronGolem ironGolem) {
if (!ironGolem.isPlayerCreated()) {
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
}
} else {