Cleaned up configuration handling and added new logging class.
This commit is contained in:
parent
e5556d9138
commit
e28ee185b6
15 changed files with 354 additions and 120 deletions
|
|
@ -4,10 +4,11 @@ import java.util.Map;
|
|||
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
|
||||
public class CaveTileRenderer extends DefaultTileRenderer {
|
||||
|
||||
public CaveTileRenderer(Map<String, Object> configuration) {
|
||||
public CaveTileRenderer(ConfigurationNode configuration) {
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import org.bukkit.World.Environment;
|
|||
import org.dynmap.Client;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ColorScheme;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.debug.Debug;
|
||||
|
||||
|
|
@ -33,7 +34,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||
return name;
|
||||
}
|
||||
|
||||
public DefaultTileRenderer(Map<String, Object> configuration) {
|
||||
public DefaultTileRenderer(ConfigurationNode configuration) {
|
||||
name = (String) configuration.get("prefix");
|
||||
Object o = configuration.get("maximumheight");
|
||||
if (o != null) {
|
||||
|
|
|
|||
|
|
@ -6,19 +6,16 @@ import java.util.Map;
|
|||
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.Color;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
|
||||
public class HighlightTileRenderer extends DefaultTileRenderer {
|
||||
protected HashSet<Integer> highlightBlocks = new HashSet<Integer>();
|
||||
|
||||
public HighlightTileRenderer(Map<String, Object> configuration) {
|
||||
public HighlightTileRenderer(ConfigurationNode configuration) {
|
||||
super(configuration);
|
||||
Object highlightObj = configuration.get("highlight");
|
||||
if (highlightObj instanceof List<?>) {
|
||||
for(Object o : (List<?>)highlightObj) {
|
||||
highlightBlocks.add((Integer)o);
|
||||
}
|
||||
} else if (highlightObj instanceof Integer) {
|
||||
highlightBlocks.add((Integer)highlightObj);
|
||||
List<Integer> highlight = configuration.<Integer>getList("highlight");
|
||||
for(Integer i : highlight) {
|
||||
highlightBlocks.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ import java.util.logging.Logger;
|
|||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.MapManager;
|
||||
import org.dynmap.MapTile;
|
||||
import org.dynmap.MapType;
|
||||
import org.dynmap.debug.Debug;
|
||||
|
|
@ -37,34 +39,16 @@ public class KzedMap extends MapType {
|
|||
MapTileRenderer[] renderers;
|
||||
ZoomedTileRenderer zoomrenderer;
|
||||
|
||||
public KzedMap(Map<String, Object> configuration) {
|
||||
renderers = loadRenderers(configuration);
|
||||
public KzedMap(ConfigurationNode configuration) {
|
||||
log.info(LOG_PREFIX + "Loading renderers for map '" + getClass().toString() + "'...");
|
||||
List<MapTileRenderer> renderers = configuration.<MapTileRenderer>createInstances("renderers", new Class<?>[0], new Object[0]);
|
||||
this.renderers = new MapTileRenderer[renderers.size()];
|
||||
renderers.toArray(this.renderers);
|
||||
log.info(LOG_PREFIX + "Loaded " + renderers.size() + " renderers for map '" + getClass().toString() + "'.");
|
||||
|
||||
zoomrenderer = new ZoomedTileRenderer(configuration);
|
||||
}
|
||||
|
||||
private MapTileRenderer[] loadRenderers(Map<String, Object> configuration) {
|
||||
List<?> configuredRenderers = (List<?>) configuration.get("renderers");
|
||||
ArrayList<MapTileRenderer> renderers = new ArrayList<MapTileRenderer>();
|
||||
for (Object configuredRendererObj : configuredRenderers) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> configuredRenderer = (Map<String, Object>) configuredRendererObj;
|
||||
String typeName = (String) configuredRenderer.get("class");
|
||||
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);
|
||||
renderers.add(mapTileRenderer);
|
||||
} catch (Exception e) {
|
||||
Debug.error("Error loading renderer", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
MapTileRenderer[] result = new MapTileRenderer[renderers.size()];
|
||||
renderers.toArray(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapTile[] getTiles(Location l) {
|
||||
World world = l.getWorld();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue