Added events for components and implemented 'buildclientconfiguration'-event in ClientConfigurationComponent.

This commit is contained in:
FrozenCow 2011-05-19 20:36:56 +02:00
parent 38c8254707
commit e57301b14e
13 changed files with 358 additions and 129 deletions

View file

@ -1,5 +1,10 @@
package org.dynmap.kzedmap;
import static org.dynmap.JSONUtils.a;
import static org.dynmap.JSONUtils.s;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.io.File;
@ -17,10 +22,12 @@ import org.dynmap.ConfigurationNode;
import org.dynmap.MapManager;
import org.dynmap.debug.Debug;
import org.dynmap.MapChunkCache;
import org.json.simple.JSONObject;
public class DefaultTileRenderer implements MapTileRenderer {
protected static final Color translucent = new Color(0, 0, 0, 0);
protected String name;
protected ConfigurationNode configuration;
protected int maximumHeight = 127;
protected ColorScheme colorScheme;
@ -34,6 +41,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
}
public DefaultTileRenderer(ConfigurationNode configuration) {
this.configuration = configuration;
name = (String) configuration.get("prefix");
Object o = configuration.get("maximumheight");
if (o != null) {
@ -356,4 +364,15 @@ public class DefaultTileRenderer implements MapTileRenderer {
c.setRGBA((c.getRed() * scale) >> 8, (c.getGreen() * scale) >> 8,
(c.getBlue() * scale) >> 8, c.getAlpha());
}
@Override
public void buildClientConfiguration(JSONObject worldObject) {
ConfigurationNode c = configuration;
JSONObject o = new JSONObject();
s(o, "type", "KzedMapType");
s(o, "name", c.getString("name"));
s(o, "title", c.getString("title"));
s(o, "prefix", c.getString("prefix"));
a(worldObject, "maps", o);
}
}

View file

@ -16,6 +16,7 @@ import org.dynmap.Log;
import org.dynmap.MapTile;
import org.dynmap.MapType;
import org.dynmap.MapChunkCache;
import org.json.simple.JSONObject;
public class KzedMap extends MapType {
protected static final Logger log = Logger.getLogger("Minecraft");
@ -300,4 +301,11 @@ public class KzedMap extends MapType {
}
}
}
@Override
public void buildClientConfiguration(JSONObject worldObject) {
for(MapTileRenderer renderer : renderers) {
renderer.buildClientConfiguration(worldObject);
}
}
}

View file

@ -3,8 +3,12 @@ package org.dynmap.kzedmap;
import java.io.File;
import org.dynmap.MapChunkCache;
import org.json.simple.JSONObject;
public interface MapTileRenderer {
String getName();
boolean render(MapChunkCache cache, KzedMapTile tile, File outputFile);
void buildClientConfiguration(JSONObject worldObject);
}