Spoiler
70396 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain - java.lang.ClassCastException: com.fs.starfarer.campaign.BaseLocation$LocationToken cannot be cast to com.fs.starfarer.campaign.BaseCampaignEntity
java.lang.ClassCastException: com.fs.starfarer.campaign.BaseLocation$LocationToken cannot be cast to com.fs.starfarer.campaign.BaseCampaignEntity
at com.fs.starfarer.campaign.BaseLocation.getEntityById(Unknown Source)
at fleetjour.scripts.panel.Common.findTargetEntity(Common.kt:85)
What basically happens is that I fetch SectorEntityToken ID of the system's center through getCenter(); store this ID in field of my class, and then fetch SectorEntityToken by this ID through public SectorEntityToken getEntityById(String var1).
BUT. If the star system in question is a nebula, it has LocationToken as its center, while getEntityById method has this code:
if (this.idToEntity.containsKey(var1)) {
BaseCampaignEntity var2 = (BaseCampaignEntity)this.idToEntity.get(var1);
if (var2.getContainingLocation() != null && var2.getContainingLocation().getAllEntities().contains(var2)) {
return var2;
}
}