diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/trait/BossBarTrait.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/trait/BossBarTrait.java index a5a094bbf..33e48d1dd 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/trait/BossBarTrait.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/trait/BossBarTrait.java @@ -41,6 +41,9 @@ public class BossBarTrait extends Trait { if (!npc.isSpawned() || !isBoss(npc.getEntity())) return; BossBar bar = NMSImpl.getBossBar(npc.getEntity()); + if (bar == null) { + return; + } bar.setVisible(visible); if (color != null) { bar.setColor(color); diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java index 4e5cf6f6e..14a619774 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java @@ -1460,7 +1460,11 @@ public class NMSImpl implements NMSBridge { if (entity.getType() == EntityType.WITHER) { bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle; } else if (entity.getType() == EntityType.ENDER_DRAGON) { - bserver = ((EnderDragonBattle) ENDERDRAGON_BATTLE_FIELD.invoke(NMSImpl.getHandle(entity))).bossBattle; + Object battleObject = ENDERDRAGON_BATTLE_FIELD.invoke(NMSImpl.getHandle(entity)); + if (battleObject == null) { + return null; + } + bserver = ((EnderDragonBattle) battleObject).bossBattle; } } catch (Throwable e) { e.printStackTrace();