@Override
public void simpleUpdate(float tpf) {
if (newPlayer) {
Iterator playerIterator = getPlayerList().iterator();
while (playerIterator.hasNext()) {
Player p = (Player) playerIterator.next();
System.out.println(p + " newPlayer? " + newPlayer + " updateNeeded? " + p.isAtachementUpdate());
if (p.isAtachementUpdate()) {
if (!p.isAttached()) {
p.setChatter(new Chatter(p.getName(), p.getUUID()));
this.formHandler.addNewUser(p.getChatter());
//p.getAvatar().setLocalTranslation(Player.spawnLocation);
worldPhysics.setupAllPlayers();
p.setAttached(true);
//rootNode.attachChild(p.getAvatar());
}
p.setAtachementUpdate(false);
}
if (p.isMarkedForDeletion()) {
System.out.println("Deleting player " + p);
rootNode.detachChild(p.getAvatar());
rootNode.detachChild(p);
p.detachAllChildren();
//getPlayerList().remove(p);
p.setMarkedForDeletion(false);
this.formHandler.removeUser(p.getChatter());
}
newPlayer = false;
}
if(needsToBeDeleted.size() > 0){
for(String uuid : needsToBeDeleted){
Player deletePlayer;
deletePlayer = this.getPlayerByUUID(uuid);
deletePlayer.setMarkedForDeletion(true);
}
newPlayer = true;
needsToBeDeleted.clear();
}