mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-26 10:37:44 +01:00
Merge pull request #148 from zeeZ/master
Organize imports and output prefixing.
This commit is contained in:
commit
771b708959
@ -9,6 +9,7 @@ import java.util.logging.Logger;
|
||||
|
||||
public class AsynchronousQueue<T> {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
|
||||
private Object lock = new Object();
|
||||
private Thread thread;
|
||||
@ -62,7 +63,7 @@ public class AsynchronousQueue<T> {
|
||||
try {
|
||||
thread.setPriority(Thread.MIN_PRIORITY);
|
||||
} catch (SecurityException e) {
|
||||
log.info("Failed to set minimum priority for worker thread!");
|
||||
log.info(LOG_PREFIX + "Failed to set minimum priority for worker thread!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -74,13 +75,13 @@ public class AsynchronousQueue<T> {
|
||||
Thread oldThread = thread;
|
||||
thread = null;
|
||||
|
||||
log.info("Stopping map renderer...");
|
||||
log.info(LOG_PREFIX + "Stopping map renderer...");
|
||||
|
||||
oldThread.interrupt();
|
||||
try {
|
||||
oldThread.join(1000);
|
||||
} catch (InterruptedException e) {
|
||||
log.info("Waiting for map renderer to stop is interrupted");
|
||||
log.info(LOG_PREFIX + "Waiting for map renderer to stop is interrupted");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -96,7 +97,7 @@ public class AsynchronousQueue<T> {
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
log.log(Level.SEVERE, "Exception on rendering-thread", ex);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Exception on rendering-thread", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.dynmap;
|
||||
|
||||
import org.dynmap.Color;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -14,6 +13,7 @@ import org.dynmap.debug.Debug;
|
||||
|
||||
public class ColorScheme {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
private static final HashMap<String, ColorScheme> cache = new HashMap<String, ColorScheme>();
|
||||
|
||||
public String name;
|
||||
@ -115,10 +115,10 @@ public class ColorScheme {
|
||||
}
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.log(Level.SEVERE, "Could not load colors '" + name + "' ('" + colorSchemeFile + "').", e);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Could not load colors '" + name + "' ('" + colorSchemeFile + "').", e);
|
||||
return null;
|
||||
} catch (FileNotFoundException e) {
|
||||
log.log(Level.SEVERE, "Could not load colors '" + name + "' ('" + colorSchemeFile + "'): File not found.", e);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Could not load colors '" + name + "' ('" + colorSchemeFile + "'): File not found.", e);
|
||||
}
|
||||
return new ColorScheme(name, colors, datacolors);
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ import org.dynmap.web.handlers.SendMessageHandler;
|
||||
|
||||
public class DynmapPlugin extends JavaPlugin {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
|
||||
public HttpServer webServer = null;
|
||||
public MapManager mapManager = null;
|
||||
@ -87,7 +88,7 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
|
||||
tilesDirectory = getFile(configuration.getString("tilespath", "web/tiles"));
|
||||
if (!tilesDirectory.isDirectory() && !tilesDirectory.mkdirs()) {
|
||||
log.warning("Could not create directory for tiles ('" + tilesDirectory + "').");
|
||||
log.warning(LOG_PREFIX + "Could not create directory for tiles ('" + tilesDirectory + "').");
|
||||
}
|
||||
|
||||
playerList = new PlayerList(getServer(), getFile("hiddenplayers.txt"), configuration);
|
||||
@ -122,7 +123,7 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
|
||||
/* Print version info */
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
log.info("[dynmap] version " + pdfFile.getVersion() + " is enabled" );
|
||||
log.info(LOG_PREFIX + "version " + pdfFile.getVersion() + " is enabled" );
|
||||
}
|
||||
|
||||
public void loadWebserver() {
|
||||
@ -163,7 +164,7 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
try {
|
||||
webServer.startServer();
|
||||
} catch (IOException e) {
|
||||
log.severe("Failed to start WebServer on " + bindAddress + ":" + port + "!");
|
||||
log.severe(LOG_PREFIX + "Failed to start WebServer on " + bindAddress + ":" + port + "!");
|
||||
}
|
||||
|
||||
}
|
||||
@ -294,7 +295,7 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
Debugger debugger = (Debugger) constructor.newInstance(this, debuggerConfigurationMap);
|
||||
Debug.addDebugger(debugger);
|
||||
} catch (Exception e) {
|
||||
log.severe("Error loading debugger: " + e);
|
||||
log.severe(LOG_PREFIX + "Error loading debugger: " + e);
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
@ -402,15 +403,15 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
fos.write(Json.stringifyJson(clientConfig).getBytes());
|
||||
fos.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
log.log(Level.SEVERE, "Exception while writing JSON-configuration-file.", ex);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-configuration-file.", ex);
|
||||
} catch (IOException ioe) {
|
||||
log.log(Level.SEVERE, "Exception while writing JSON-configuration-file.", ioe);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-configuration-file.", ioe);
|
||||
}
|
||||
}
|
||||
|
||||
public void webChat(String name, String message) {
|
||||
mapManager.pushUpdate(new Client.ChatMessage("web", name, message));
|
||||
log.info("[WEB]" + name + ": " + message);
|
||||
log.info(LOG_PREFIX + "[WEB]" + name + ": " + message);
|
||||
/* Let HeroChat take a look - only broadcast to players if it doesn't handle it */
|
||||
if(hchand.sendWebMessageToHeroChat(name, message) == false)
|
||||
getServer().broadcastMessage("[WEB]" + name + ": " + message);
|
||||
|
@ -1,20 +1,21 @@
|
||||
package org.dynmap;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.CustomEventListener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.lang.reflect.Method;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
public class HeroChatHandler {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
|
||||
private static final String DEF_CHANNEL = "Global";
|
||||
private static final List<String> DEF_CHANNELS = Collections
|
||||
@ -156,7 +157,7 @@ public class HeroChatHandler {
|
||||
isgood = true;
|
||||
} catch (ClassNotFoundException cnfx) {
|
||||
} catch (NoSuchMethodException nsmx) {
|
||||
System.out.println(nsmx);
|
||||
log.severe(LOG_PREFIX + nsmx);
|
||||
}
|
||||
return isgood;
|
||||
}
|
||||
@ -229,7 +230,7 @@ public class HeroChatHandler {
|
||||
public HeroChatHandler(Configuration cfg, DynmapPlugin plugin, Server server) {
|
||||
/* If we're enabling hero chat support */
|
||||
if (cfg.getNode("web").getBoolean("enableherochat", false)) {
|
||||
log.info("[dynmap] HeroChat support configured");
|
||||
log.info(LOG_PREFIX + "HeroChat support configured");
|
||||
this.plugin = plugin;
|
||||
/* Now, get the monitored channel list */
|
||||
hcchannels = cfg.getNode("web").getStringList("herochatchannels",
|
||||
@ -245,22 +246,22 @@ public class HeroChatHandler {
|
||||
|
||||
private void activateHeroChat(Plugin herochat) {
|
||||
if (HeroChatChannelChatEvent.initialize() == false) {
|
||||
log.severe("[dynmap] Cannot load HeroChat chat event class!");
|
||||
log.severe(LOG_PREFIX + "Cannot load HeroChat chat event class!");
|
||||
return;
|
||||
}
|
||||
if (HeroChatChannel.initialize() == false) {
|
||||
log.severe("[dynmap] Cannot load HeroChat channel class!");
|
||||
log.severe(LOG_PREFIX + "Cannot load HeroChat channel class!");
|
||||
return;
|
||||
}
|
||||
if (HeroChatChannelEvent.initialize() == false) {
|
||||
log.severe("[dynmap] Cannot load HeroChat channel event class!");
|
||||
log.severe(LOG_PREFIX + "Cannot load HeroChat channel event class!");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Register event handler */
|
||||
plugin.getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT,
|
||||
new OurEventListener(), Event.Priority.Monitor, plugin);
|
||||
log.info("[dynmap] HeroChat integration active");
|
||||
log.info(LOG_PREFIX + "HeroChat integration active");
|
||||
}
|
||||
/**
|
||||
* Send message from web to appropriate HeroChat channel
|
||||
|
@ -25,6 +25,7 @@ import org.json.simple.parser.ParseException;
|
||||
|
||||
class JsonTimerTask extends TimerTask {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
|
||||
private final DynmapPlugin plugin;
|
||||
private Server server;
|
||||
@ -66,9 +67,9 @@ class JsonTimerTask extends TimerTask {
|
||||
jsonMsgs = (JSONArray) parser.parse(inputFileReader);
|
||||
inputFileReader.close();
|
||||
} catch (IOException ex) {
|
||||
log.log(Level.SEVERE, "Exception while reading JSON-file.", ex);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Exception while reading JSON-file.", ex);
|
||||
} catch (ParseException ex) {
|
||||
log.log(Level.SEVERE, "Exception while parsing JSON-file.", ex);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Exception while parsing JSON-file.", ex);
|
||||
}
|
||||
|
||||
if (jsonMsgs != null) {
|
||||
@ -120,9 +121,9 @@ class JsonTimerTask extends TimerTask {
|
||||
fos.write(Json.stringifyJson(update).getBytes());
|
||||
fos.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
log.log(Level.SEVERE, "Exception while writing JSON-file.", ex);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-file.", ex);
|
||||
} catch (IOException ioe) {
|
||||
log.log(Level.SEVERE, "Exception while writing JSON-file.", ioe);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-file.", ioe);
|
||||
}
|
||||
}
|
||||
lastTimestamp = System.currentTimeMillis();
|
||||
@ -166,9 +167,9 @@ class JsonTimerTask extends TimerTask {
|
||||
fos.write(Json.stringifyJson(regionData).getBytes());
|
||||
fos.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
log.log(Level.SEVERE, "Exception while writing JSON-file.", ex);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-file.", ex);
|
||||
} catch (IOException ioe) {
|
||||
log.log(Level.SEVERE, "Exception while writing JSON-file.", ioe);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Exception while writing JSON-file.", ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package org.dynmap;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -12,24 +10,18 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import org.dynmap.kzedmap.KzedMapTile;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.util.config.ConfigurationNode;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.MapTile;
|
||||
import org.dynmap.debug.Debug;
|
||||
import org.dynmap.kzedmap.KzedMap;
|
||||
import org.dynmap.kzedmap.KzedZoomedMapTile;
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
public class MapManager {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
|
||||
public AsynchronousQueue<MapTile> tileQueue;
|
||||
public AsynchronousQueue<ImageWriter> writeQueue;
|
||||
@ -88,7 +80,7 @@ public class MapManager {
|
||||
rendered.clear();
|
||||
map_index++; /* Next map */
|
||||
if(map_index >= world.maps.size()) { /* Last one done? */
|
||||
log.info("Full render finished.");
|
||||
log.info(LOG_PREFIX + "Full render finished.");
|
||||
active_renders.remove(world.world.getName());
|
||||
return;
|
||||
}
|
||||
@ -213,27 +205,27 @@ public class MapManager {
|
||||
void renderFullWorld(Location l) {
|
||||
DynmapWorld world = worlds.get(l.getWorld().getName());
|
||||
if (world == null) {
|
||||
log.severe("Could not render: world '" + l.getWorld().getName() + "' not defined in configuration.");
|
||||
log.severe(LOG_PREFIX + "Could not render: world '" + l.getWorld().getName() + "' not defined in configuration.");
|
||||
return;
|
||||
}
|
||||
if(do_timesliced_render) {
|
||||
String wname = l.getWorld().getName();
|
||||
FullWorldRenderState rndr = active_renders.get(wname);
|
||||
if(rndr != null) {
|
||||
log.info("Full world render of world '" + wname + "' already active.");
|
||||
log.info(LOG_PREFIX + "Full world render of world '" + wname + "' already active.");
|
||||
return;
|
||||
}
|
||||
rndr = new FullWorldRenderState(world,l); /* Make new activation record */
|
||||
active_renders.put(wname, rndr); /* Add to active table */
|
||||
/* Schedule first tile to be worked */
|
||||
scheduler.scheduleSyncDelayedTask(plug_in, rndr, (int)(timeslice_interval*20));
|
||||
log.info("Full render starting on world '" + wname + "' (timesliced)...");
|
||||
log.info(LOG_PREFIX + "Full render starting on world '" + wname + "' (timesliced)...");
|
||||
|
||||
return;
|
||||
}
|
||||
World w = world.world;
|
||||
|
||||
log.info("Full render starting on world '" + w.getName() + "'...");
|
||||
log.info(LOG_PREFIX + "Full render starting on world '" + w.getName() + "'...");
|
||||
for (MapType map : world.maps) {
|
||||
int requiredChunkCount = 200;
|
||||
HashSet<MapTile> found = new HashSet<MapTile>();
|
||||
@ -287,7 +279,7 @@ public class MapManager {
|
||||
w.unloadChunk(c.x, c.z, false, true);
|
||||
}
|
||||
}
|
||||
log.info("Full render finished.");
|
||||
log.info(LOG_PREFIX + "Full render finished.");
|
||||
}
|
||||
|
||||
public void activateWorld(World w) {
|
||||
@ -300,7 +292,7 @@ public class MapManager {
|
||||
if (world != null) {
|
||||
world.world = w;
|
||||
worlds.put(w.getName(), world);
|
||||
log.info("Activated world '" + w.getName() + "' in Dynmap.");
|
||||
log.info(LOG_PREFIX + "Activated world '" + w.getName() + "' in Dynmap.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,14 +309,14 @@ public class MapManager {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> configuredMap = (Map<String, Object>) configuredMapObj;
|
||||
String typeName = (String) configuredMap.get("class");
|
||||
log.info("Loading map '" + typeName.toString() + "'...");
|
||||
log.info(LOG_PREFIX + "Loading map '" + typeName.toString() + "'...");
|
||||
Class<?> mapTypeClass = Class.forName(typeName);
|
||||
Constructor<?> constructor = mapTypeClass.getConstructor(Map.class);
|
||||
MapType mapType = (MapType) constructor.newInstance(configuredMap);
|
||||
mapType.onTileInvalidated.addListener(invalitateListener);
|
||||
mapTypes.add(mapType);
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Error loading maptype", e);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Error loading maptype", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -379,7 +371,7 @@ public class MapManager {
|
||||
worldTileDirectories.put(world, worldTileDirectory);
|
||||
}
|
||||
if (!worldTileDirectory.isDirectory() && !worldTileDirectory.mkdirs()) {
|
||||
log.warning("Could not create directory for tiles ('" + worldTileDirectory + "').");
|
||||
log.warning(LOG_PREFIX + "Could not create directory for tiles ('" + worldTileDirectory + "').");
|
||||
}
|
||||
return new File(worldTileDirectory, tile.getFilename());
|
||||
}
|
||||
|
@ -8,24 +8,24 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class LogDebugger implements Debugger {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
private static String prepend = "dynmap: ";
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
|
||||
public LogDebugger(JavaPlugin plugin, Map<String, Object> configuration) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
log.info(prepend + message);
|
||||
log.info(LOG_PREFIX + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message) {
|
||||
log.log(Level.SEVERE, prepend + message);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message, Throwable thrown) {
|
||||
log.log(Level.SEVERE, prepend + message);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + message);
|
||||
thrown.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.dynmap.flat;
|
||||
|
||||
import org.dynmap.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.io.File;
|
||||
@ -13,6 +12,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.dynmap.Client;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ColorScheme;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.MapManager;
|
||||
|
@ -1,9 +1,9 @@
|
||||
package org.dynmap.kzedmap;
|
||||
|
||||
import org.dynmap.Color;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.Color;
|
||||
|
||||
public class CaveTileRenderer extends DefaultTileRenderer {
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.dynmap.kzedmap;
|
||||
|
||||
import org.dynmap.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -12,13 +11,12 @@ import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.dynmap.Client;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ColorScheme;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.MapTile;
|
||||
import org.dynmap.debug.Debug;
|
||||
|
||||
public class DefaultTileRenderer implements MapTileRenderer {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package org.dynmap.kzedmap;
|
||||
|
||||
import org.dynmap.Color;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.Color;
|
||||
|
||||
public class HighlightTileRenderer extends DefaultTileRenderer {
|
||||
protected HashSet<Integer> highlightBlocks = new HashSet<Integer>();
|
||||
|
@ -16,6 +16,7 @@ import org.dynmap.debug.Debug;
|
||||
|
||||
public class KzedMap extends MapType {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
|
||||
/* dimensions of a map tile */
|
||||
public static final int tileWidth = 128;
|
||||
@ -49,7 +50,7 @@ public class KzedMap extends MapType {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> configuredRenderer = (Map<String, Object>) configuredRendererObj;
|
||||
String typeName = (String) configuredRenderer.get("class");
|
||||
log.info("Loading renderer '" + typeName.toString() + "'...");
|
||||
log.info(LOG_PREFIX + "Loading renderer '" + typeName.toString() + "'...");
|
||||
Class<?> mapTypeClass = Class.forName(typeName);
|
||||
Constructor<?> constructor = mapTypeClass.getConstructor(Map.class);
|
||||
MapTileRenderer mapTileRenderer = (MapTileRenderer) constructor.newInstance(configuredRenderer);
|
||||
|
@ -6,6 +6,7 @@ import java.util.logging.Logger;
|
||||
|
||||
public class BoundInputStream extends InputStream {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
private InputStream base;
|
||||
private long bound;
|
||||
|
||||
|
@ -12,6 +12,7 @@ import java.util.logging.Logger;
|
||||
|
||||
public class HttpServer extends Thread {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
|
||||
private ServerSocket sock = null;
|
||||
private Thread listeningThread;
|
||||
@ -30,7 +31,7 @@ public class HttpServer extends Thread {
|
||||
sock = new ServerSocket(port, 5, bindAddress);
|
||||
listeningThread = this;
|
||||
start();
|
||||
log.info("Dynmap WebServer started on " + bindAddress + ":" + port);
|
||||
log.info(LOG_PREFIX + "Dynmap WebServer started on " + bindAddress + ":" + port);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
@ -41,24 +42,24 @@ public class HttpServer extends Thread {
|
||||
HttpServerConnection requestThread = new HttpServerConnection(socket, this);
|
||||
requestThread.start();
|
||||
} catch (IOException e) {
|
||||
log.info("map WebServer.run() stops with IOException");
|
||||
log.info(LOG_PREFIX + "map WebServer.run() stops with IOException");
|
||||
break;
|
||||
}
|
||||
}
|
||||
log.info("Webserver shut down.");
|
||||
log.info(LOG_PREFIX + "Webserver shut down.");
|
||||
} catch (Exception ex) {
|
||||
log.log(Level.SEVERE, "Exception on WebServer-thread", ex);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Exception on WebServer-thread", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
log.info("Shutting down webserver...");
|
||||
log.info(LOG_PREFIX + "Shutting down webserver...");
|
||||
try {
|
||||
if (sock != null) {
|
||||
sock.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.log(Level.INFO, "Exception while closing socket for webserver shutdown", e);
|
||||
log.log(Level.INFO, LOG_PREFIX + "Exception while closing socket for webserver shutdown", e);
|
||||
}
|
||||
listeningThread = null;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import org.dynmap.debug.Debug;
|
||||
|
||||
public class HttpServerConnection extends Thread {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
|
||||
private static Pattern requestHeaderLine = Pattern.compile("^(\\S+)\\s+(\\S+)\\s+HTTP/(.+)$");
|
||||
private static Pattern requestHeaderField = Pattern.compile("^([^:]+):\\s*(.+)$");
|
||||
@ -174,7 +175,7 @@ public class HttpServerConnection extends Thread {
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "HttpHandler '" + handler + "' has thown an exception", e);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "HttpHandler '" + handler + "' has thown an exception", e);
|
||||
if (socket != null) {
|
||||
out.flush();
|
||||
socket.close();
|
||||
@ -228,7 +229,7 @@ public class HttpServerConnection extends Thread {
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
log.log(Level.SEVERE, "Exception while handling request: ", e);
|
||||
log.log(Level.SEVERE, LOG_PREFIX + "Exception while handling request: ", e);
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -12,10 +13,10 @@ import org.dynmap.web.HttpHandler;
|
||||
import org.dynmap.web.HttpRequest;
|
||||
import org.dynmap.web.HttpResponse;
|
||||
import org.dynmap.web.HttpStatus;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public abstract class FileHandler implements HttpHandler {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
//BUG-this breaks re-entrancy of this handler, which is called from multiple threads (one per request)
|
||||
//private byte[] readBuffer = new byte[40960];
|
||||
//Replace with pool of buffers
|
||||
|
@ -17,6 +17,7 @@ import org.json.simple.parser.JSONParser;
|
||||
|
||||
public class SendMessageHandler implements HttpHandler {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
protected static final String LOG_PREFIX = "[dynmap] ";
|
||||
|
||||
private static final JSONParser parser = new JSONParser();
|
||||
public Event<Message> onMessageReceived = new Event<SendMessageHandler.Message>();
|
||||
|
Loading…
Reference in New Issue
Block a user