mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-25 18:17:37 +01:00
New config to Disable Webserver
New feature and config to output JSON to file
This commit is contained in:
parent
b2f6ae5132
commit
fb01f6ecf7
@ -15,6 +15,15 @@ webserver-bindaddress: 0.0.0.0
|
|||||||
# The TCP-port the webserver will listen on.
|
# The TCP-port the webserver will listen on.
|
||||||
webserver-port: 8123
|
webserver-port: 8123
|
||||||
|
|
||||||
|
# Disables Webserver portion of Dynmap (Advanced users only)
|
||||||
|
disable-webserver: true
|
||||||
|
|
||||||
|
# Writes JSON to file in the webpath
|
||||||
|
jsonfile: true
|
||||||
|
|
||||||
|
# How often the json file gets written to(in seconds)
|
||||||
|
jsonfile-interval: 1000
|
||||||
|
|
||||||
disabledcommands:
|
disabledcommands:
|
||||||
- fullrender
|
- fullrender
|
||||||
|
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package org.dynmap;
|
package org.dynmap;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.Timer;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -22,6 +25,7 @@ import org.dynmap.web.HttpServer;
|
|||||||
import org.dynmap.web.handlers.ClientConfigurationHandler;
|
import org.dynmap.web.handlers.ClientConfigurationHandler;
|
||||||
import org.dynmap.web.handlers.ClientUpdateHandler;
|
import org.dynmap.web.handlers.ClientUpdateHandler;
|
||||||
import org.dynmap.web.handlers.FilesystemHandler;
|
import org.dynmap.web.handlers.FilesystemHandler;
|
||||||
|
import org.dynmap.web.Json;
|
||||||
|
|
||||||
public class DynmapPlugin extends JavaPlugin {
|
public class DynmapPlugin extends JavaPlugin {
|
||||||
|
|
||||||
@ -32,6 +36,8 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
private PlayerList playerList;
|
private PlayerList playerList;
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
|
|
||||||
|
private Timer timer;
|
||||||
|
|
||||||
private BukkitPlayerDebugger debugger = new BukkitPlayerDebugger(this);
|
private BukkitPlayerDebugger debugger = new BukkitPlayerDebugger(this);
|
||||||
|
|
||||||
public static File dataRoot;
|
public static File dataRoot;
|
||||||
@ -64,6 +70,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
mapManager = new MapManager(getWorld(), debugger, configuration);
|
mapManager = new MapManager(getWorld(), debugger, configuration);
|
||||||
mapManager.startManager();
|
mapManager.startManager();
|
||||||
|
|
||||||
|
if(!configuration.getBoolean("disable-webserver", true)) {
|
||||||
InetAddress bindAddress;
|
InetAddress bindAddress;
|
||||||
{
|
{
|
||||||
String address = configuration.getString("webserver-bindaddress", "0.0.0.0");
|
String address = configuration.getString("webserver-bindaddress", "0.0.0.0");
|
||||||
@ -88,7 +95,18 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.severe("Failed to start WebServer on " + bindAddress + ":" + port + "!");
|
log.severe("Failed to start WebServer on " + bindAddress + ":" + port + "!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.out.println("WebServer Disabled");
|
||||||
|
|
||||||
|
if(configuration.getBoolean("jsonfile", false)) {
|
||||||
|
jsonConfig();
|
||||||
|
int jsonInterval = configuration.getInt("jsonfile", 1) * 1000;
|
||||||
|
timer = new Timer();
|
||||||
|
timer.scheduleAtFixedRate(new JsonTimerTask(this, configuration), jsonInterval, jsonInterval);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
System.out.println("JsonFile Writing Disabled");
|
||||||
registerEvents();
|
registerEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,4 +129,30 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
|
||||||
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Normal, this);
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Normal, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void jsonConfig()
|
||||||
|
{
|
||||||
|
File outputFile;
|
||||||
|
Map<?, ?> clientConfig = (Map<?, ?>) configuration.getProperty("web");
|
||||||
|
File webpath = new File(configuration.getString("webpath", "web"), "dynmap_config.json");
|
||||||
|
if(webpath.isAbsolute())
|
||||||
|
outputFile = webpath;
|
||||||
|
else
|
||||||
|
outputFile = new File(DynmapPlugin.dataRoot, webpath.toString());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||||
|
fos.write(Json.stringifyJson(clientConfig).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