mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-03-30 08:15:41 +02:00
Removed System debug messages.
Added missing JsonTimerTask.java
This commit is contained in:
parent
fb01f6ecf7
commit
2f6930bc17
@ -96,8 +96,6 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
log.severe("Failed to start WebServer on " + bindAddress + ":" + port + "!");
|
||||
}
|
||||
}
|
||||
else
|
||||
System.out.println("WebServer Disabled");
|
||||
|
||||
if(configuration.getBoolean("jsonfile", false)) {
|
||||
jsonConfig();
|
||||
@ -105,8 +103,7 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
timer = new Timer();
|
||||
timer.scheduleAtFixedRate(new JsonTimerTask(this, configuration), jsonInterval, jsonInterval);
|
||||
}
|
||||
else
|
||||
System.out.println("JsonFile Writing Disabled");
|
||||
|
||||
registerEvents();
|
||||
}
|
||||
|
||||
|
71
src/main/java/org/dynmap/JsonTimerTask.java
Normal file
71
src/main/java/org/dynmap/JsonTimerTask.java
Normal file
@ -0,0 +1,71 @@
|
||||
package org.dynmap;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.List;
|
||||
import java.util.TimerTask;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
import org.dynmap.web.Json;
|
||||
|
||||
class JsonTimerTask extends TimerTask
|
||||
{
|
||||
private final DynmapPlugin plugin;
|
||||
private Server server;
|
||||
private PlayerList playerList;
|
||||
private MapManager mapManager;
|
||||
private Configuration configuration;
|
||||
|
||||
public JsonTimerTask(DynmapPlugin instance, Configuration config)
|
||||
{
|
||||
this.plugin = instance;
|
||||
this.server = this.plugin.getServer();
|
||||
this.playerList = new PlayerList(this.server);
|
||||
this.mapManager = this.plugin.getMapManager();
|
||||
this.configuration = config;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
long current = System.currentTimeMillis();
|
||||
|
||||
Client.Update update = new Client.Update();
|
||||
update.timestamp = current;
|
||||
update.servertime = ((World)this.server.getWorlds().get(0)).getTime();
|
||||
|
||||
Player[] players = this.playerList.getVisiblePlayers();
|
||||
update.players = new Client.Player[players.length];
|
||||
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;
|
||||
if (webpath.isAbsolute())
|
||||
outputFile = webpath;
|
||||
else {
|
||||
outputFile = new File(DynmapPlugin.dataRoot, webpath.toString());
|
||||
}
|
||||
try
|
||||
{
|
||||
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…
Reference in New Issue
Block a user