CastleAmbassador check for existing fortress.

This commit is contained in:
MobiusDevelopment 2024-06-15 02:02:48 +03:00
parent 9f626229a9
commit 9fd5a862d1
2 changed files with 6 additions and 4 deletions

View File

@ -156,8 +156,9 @@ public class CastleAmbassador extends AbstractNpcAI
@Override
public String onSpawn(Npc npc)
{
final Castle castle = npc.getFort().getCastleByAmbassador(npc.getId());
if (castle.getOwnerId() == 0)
final Fort fort = npc.getFort();
final Castle castle = fort == null ? null : fort.getCastleByAmbassador(npc.getId());
if ((castle == null) || (castle.getOwnerId() == 0))
{
npc.deleteMe();
}

View File

@ -156,8 +156,9 @@ public class CastleAmbassador extends AbstractNpcAI
@Override
public String onSpawn(Npc npc)
{
final Castle castle = npc.getFort().getCastleByAmbassador(npc.getId());
if (castle.getOwnerId() == 0)
final Fort fort = npc.getFort();
final Castle castle = fort == null ? null : fort.getCastleByAmbassador(npc.getId());
if ((castle == null) || (castle.getOwnerId() == 0))
{
npc.deleteMe();
}