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