package org.dynmap; import static org.dynmap.JSONUtils.a; import static org.dynmap.JSONUtils.s; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; import org.json.simple.JSONArray; import org.json.simple.JSONObject; public class ClientUpdateComponent extends Component { public ClientUpdateComponent(final DynmapPlugin plugin, ConfigurationNode configuration) { super(plugin, configuration); plugin.events.addListener("buildclientupdate", new Event.Listener() { @Override public void triggered(ClientUpdateEvent e) { buildClientUpdate(e); } }); } protected void buildClientUpdate(ClientUpdateEvent e) { World world = e.world.world; JSONObject u = e.update; long since = e.timestamp; String worldName = world.getName(); s(u, "servertime", world.getTime() % 24000); s(u, "hasStorm", world.hasStorm()); s(u, "isThundering", world.isThundering()); s(u, "players", new JSONArray()); Player[] players = plugin.playerList.getVisiblePlayers(); for(int i=0;i