This is for the nio based 508 in the downloads section.
In palidino76.server.model.NPCManager, add:
Code:
private List<NPC> npcsToAdd = new ArrayList<NPC>();
private List<NPC> npcsToRemove = new ArrayList<NPC>();
public List<NPC> getNPCsToRemove() {
return npcsToRemove;
}
public List<NPC> getNPCsToAdd() {
return npcsToAdd;
}
at the bottom of globalNPCUpdate() add:
Code:
if (!npcsToRemove.isEmpty()) {
npcs.removeAll(npcsToRemove);
npcsToRemove.clear();
}
if (!npcsToAdd.isEmpty()) {
npcs.addAll(npcsToAdd);
npcsToAdd.clear();
}
Now go the palidino76.server.model.npcs.NPC, and in the process method, replace the remove(this) line with:
Code:
Engine.npcManager.getNPCsToRemove().add(this);
For the respawning in the process method change the line to:
Code:
Engine.npcManager.getNPCsToAdd().add(new NPC(getId(), getType(), makeX, makeY, getHeight(), rangeX1, rangeY1, rangeX2, rangeY2, true));