toRespawn.put(npc.getOwner(), new NPCLocation(npc.getLocation(), npc.getUID(), npc.getOwner()));
NPCManager.despawn(npc.getUID(), NPCRemoveReason.DEATH);
}
private boolean findTarget(HumanNPC npc) {
Guard guard = npc.getType("guard");
Player player = Bukkit.getPlayerExact(npc.getOwner());
if (player == null) {
despawn(npc);
return false;
}
double range = Settings.getDouble("PathfindingRange");
if (guard.isAggressive()
&& LocationUtils.withinRange(npc.getLocation(), player.getLocation(), guard.getProtectionRadius())) {
LivingEntity entity = Targeter.findTarget(Targeter.getNearby(player, guard.getProtectionRadius()), npc);
if (entity != null && !entity.isDead()) {
guard.target(entity, npc);
return true;
} else if (npc.getHandle().getTarget() != player) {
PathUtils.target(npc, player, false, -1, -1, range);
}
} else {