sendToPlayer.put("direction", player.getLocation().getDirection());
sendToPlayer.put("map", mapId);
sendToPlayer.put("otherPlayers", otherPlayersArray);
for (String playerId : map.getPlayers()) {
Player otherPlayer = PlayerManager.getPlayer(playerId);
PlayerManager.pushJson(otherPlayer, sendToOthers);
JSONObject otherPlayerJson = new JSONObject();
otherPlayerJson.put("name", otherPlayer.id());
otherPlayerJson.put("spriteheight", 56);
otherPlayerJson.put("spritewidth", 42);
otherPlayerJson.put("image", otherPlayer.getAvatar());
otherPlayerJson.put("x", otherPlayer.getLocation().getLeft());
otherPlayerJson.put("y", otherPlayer.getLocation().getTop());
otherPlayerJson.put("z", map.getEntityZ());
otherPlayerJson.put("direction", otherPlayer.getLocation().getDirection());
otherPlayersArray.put(otherPlayerJson);
}
map.addPlayer(player.id());
PlayerManager.pushJson(player, sendToPlayer);