Transfered client-updates to two components (jsonfile and internal).

This commit is contained in:
FrozenCow 2011-05-21 02:01:26 +02:00
parent 9fa46597d1
commit d5b4f6c8c4
11 changed files with 271 additions and 245 deletions

View file

@ -94,16 +94,7 @@ public class DynmapPlugin extends JavaPlugin {
mapManager = new MapManager(this, configuration);
mapManager.startRendering();
if (!configuration.getBoolean("disable-webserver", false)) {
loadWebserver();
}
if (configuration.getBoolean("jsonfile", false)) {
jsonConfig();
int jsonInterval = configuration.getInteger("jsonfile-interval", 1) * 1000;
timer = new Timer();
timer.scheduleAtFixedRate(new JsonTimerTask(this, configuration), jsonInterval, jsonInterval);
}
loadWebserver();
enabledTriggers.clear();
List<String> triggers = configuration.getStrings("render-triggers", new ArrayList<String>());
@ -121,11 +112,15 @@ public class DynmapPlugin extends JavaPlugin {
registerEvents();
startWebserver();
if (!configuration.getBoolean("disable-webserver", false)) {
startWebserver();
}
/* Print version info */
PluginDescriptionFile pdfFile = this.getDescription();
Log.info("version " + pdfFile.getVersion() + " is enabled" );
events.<Object>trigger("initialized", null);
}
public void loadWebserver() {
@ -145,7 +140,6 @@ public class DynmapPlugin extends JavaPlugin {
webServer = new HttpServer(bindAddress, port);
webServer.handlers.put("/", new FilesystemHandler(getFile(configuration.getString("webpath", "web"))));
webServer.handlers.put("/tiles/", new FilesystemHandler(tilesDirectory));
webServer.handlers.put("/up/", new ClientUpdateHandler(this, configuration.getBoolean("health-in-json", false)));
webServer.handlers.put("/up/configuration", new ClientConfigurationHandler(this));
if (configuration.getBoolean("allowwebchat", false)) {
@ -388,27 +382,6 @@ public class DynmapPlugin extends JavaPlugin {
return true;
}
private void jsonConfig() {
File outputFile;
JSONObject clientConfiguration = new JSONObject();
events.trigger("buildclientconfiguration", clientConfiguration);
File webpath = new File(configuration.getString("webpath", "web"), "standalone/dynmap_config.json");
if (webpath.isAbsolute())
outputFile = webpath;
else
outputFile = new File(getDataFolder(), webpath.toString());
try {
FileOutputStream fos = new FileOutputStream(outputFile);
fos.write(clientConfiguration.toJSONString().getBytes());
fos.close();
} catch (FileNotFoundException ex) {
Log.severe("Exception while writing JSON-configuration-file.", ex);
} catch (IOException ioe) {
Log.severe("Exception while writing JSON-configuration-file.", ioe);
}
}
public void webChat(String name, String message) {
mapManager.pushUpdate(new Client.ChatMessage("web", null, name, message, null));
Log.info("[WEB]" + name + ": " + message);