catch null bossbars for enderdragaon NPCs, fixes #1764

This commit is contained in:
mcmonkey 2019-05-03 01:55:47 -07:00
parent 244e8dd343
commit 47fd18dc04
No known key found for this signature in database
GPG Key ID: 2F0F11928478A6F5
2 changed files with 8 additions and 1 deletions

View File

@ -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);

View File

@ -1459,7 +1459,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();