SPIGOT-6726: NPE when calling getBossBar() on plugin spawned EnderDragon

This commit is contained in:
Brokkonaut 2021-08-28 19:02:19 +10:00 committed by md_5
parent 5be41fb80f
commit e167f28088
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -67,12 +67,13 @@ public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderD
@Override
public BossBar getBossBar() {
return getDragonBattle().getBossBar();
DragonBattle battle = getDragonBattle();
return battle != null ? battle.getBossBar() : null;
}
@Override
public DragonBattle getDragonBattle() {
return new CraftDragonBattle(getHandle().getEnderDragonBattle());
return getHandle().getEnderDragonBattle() != null ? new CraftDragonBattle(getHandle().getEnderDragonBattle()) : null;
}
@Override