Updated JsonTimerTask.java to be Multi-World Compatible
This commit is contained in:
parent
92b45b8d31
commit
5930f36733
1 changed files with 42 additions and 33 deletions
|
|
@ -32,40 +32,49 @@ class JsonTimerTask extends TimerTask
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
long current = System.currentTimeMillis();
|
for(World world : this.server.getWorlds())
|
||||||
|
{
|
||||||
|
long current = System.currentTimeMillis();
|
||||||
|
|
||||||
Client.Update update = new Client.Update();
|
Client.Update update = new Client.Update();
|
||||||
update.timestamp = current;
|
update.timestamp = current;
|
||||||
update.servertime = ((World)this.server.getWorlds().get(0)).getTime();
|
update.servertime = world.getTime();
|
||||||
|
|
||||||
Player[] players = this.playerList.getVisiblePlayers();
|
update.timestamp = current;
|
||||||
update.players = new Client.Player[players.length];
|
update.servertime = world.getTime() % 24000;
|
||||||
for (int i = 0; i < players.length; i++) {
|
|
||||||
Player p = players[i];
|
|
||||||
update.players[i] = new Client.Player(p.getName(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ());
|
|
||||||
}
|
|
||||||
update.updates = this.mapManager.updateQueue.getUpdatedObjects(current - 10L);
|
|
||||||
|
|
||||||
File webpath = new File(this.configuration.getString("webpath", "web"), "dynmap.json");
|
|
||||||
File outputFile;
|
Player[] players = playerList.getVisiblePlayers();
|
||||||
if (webpath.isAbsolute())
|
update.players = new Client.Player[players.length];
|
||||||
outputFile = webpath;
|
for(int i=0;i<players.length;i++) {
|
||||||
else {
|
Player p = players[i];
|
||||||
outputFile = new File(DynmapPlugin.dataRoot, webpath.toString());
|
Location pl = p.getLocation();
|
||||||
}
|
update.players[i] = new Client.Player(p.getName(), pl.getWorld().getName(), pl.getX(), pl.getY(), pl.getZ());
|
||||||
try
|
}
|
||||||
{
|
|
||||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
update.updates = mapManager.getWorldUpdates(world.getName(), current - 10L);
|
||||||
fos.write(Json.stringifyJson(update).getBytes());
|
|
||||||
fos.close();
|
File webpath = new File(this.configuration.getString("webpath", "web"), "dynmap_"+world.getName()+".json");
|
||||||
}
|
File outputFile;
|
||||||
catch (FileNotFoundException ex)
|
if (webpath.isAbsolute())
|
||||||
{
|
outputFile = webpath;
|
||||||
System.out.println("FileNotFoundException : " + ex);
|
else {
|
||||||
}
|
outputFile = new File(DynmapPlugin.dataRoot, webpath.toString());
|
||||||
catch (IOException ioe)
|
}
|
||||||
{
|
try
|
||||||
System.out.println("IOException : " + ioe);
|
{
|
||||||
}
|
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||||
}
|
fos.write(Json.stringifyJson(update).getBytes());
|
||||||
|
fos.close();
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException ex)
|
||||||
|
{
|
||||||
|
System.out.println("FileNotFoundException : " + ex);
|
||||||
|
}
|
||||||
|
catch (IOException ioe)
|
||||||
|
{
|
||||||
|
System.out.println("IOException : " + ioe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue