Merge remote branch 'upstream/master'

This commit is contained in:
Mike Primm 2011-06-15 01:40:42 -05:00
commit 0b7bd72231
24 changed files with 173 additions and 49 deletions

View File

@ -78,6 +78,9 @@ render-triggers:
# - playerjoin # - playerjoin
- blockplaced - blockplaced
- blockbreak - blockbreak
- snowform
- leavesdecay
- blockburn
# The path where the tile-files are placed. # The path where the tile-files are placed.
tilespath: web/tiles tilespath: web/tiles
@ -121,6 +124,8 @@ templates:
# Template for normal world # Template for normal world
normal: normal:
enabled: true enabled: true
# If bigworld set to true, use alternate directory layout better suited to large worlds
# bigworld: true
center: center:
x: 0 x: 0
y: 64 y: 64
@ -184,6 +189,8 @@ templates:
# Nether world template # Nether world template
nether: nether:
enabled: true enabled: true
# If bigworld set to true, use alternate directory layout better suited to large worlds
# bigworld: true
center: center:
x: 0 x: 0
y: 64 y: 64
@ -209,6 +216,8 @@ templates:
# Skylands world template # Skylands world template
skylands: skylands:
enabled: true enabled: true
# If bigworld set to true, use alternate directory layout better suited to large worlds
# bigworld: true
center: center:
x: 0 x: 0
y: 64 y: 64
@ -267,6 +276,8 @@ worlds:
# x: 0 # x: 0
# y: 64 # y: 64
# z: 0 # z: 0
# # If bigworld set to true, use alternate directory layout better suited to large worlds
# # bigworld: true
# maps: # maps:
# - class: org.dynmap.flat.FlatMap # - class: org.dynmap.flat.FlatMap
# name: flat # name: flat

View File

@ -39,6 +39,7 @@ public class ClientComponent extends Component {
return o; return o;
} }
@SuppressWarnings("unchecked")
protected static final JSONArray convertList(List<?> l) { protected static final JSONArray convertList(List<?> l) {
JSONArray o = new JSONArray(); JSONArray o = new JSONArray();
for(Object entry : l) { for(Object entry : l) {
@ -47,6 +48,7 @@ public class ClientComponent extends Component {
return o; return o;
} }
@SuppressWarnings("unchecked")
protected static final Object convert(Object o) { protected static final Object convert(Object o) {
if (o instanceof Map<?, ?>) { if (o instanceof Map<?, ?>) {
return convertMap((Map<String, ?>)o); return convertMap((Map<String, ?>)o);

View File

@ -1,7 +1,6 @@
package org.dynmap; package org.dynmap;
import static org.dynmap.JSONUtils.a; import static org.dynmap.JSONUtils.a;
import static org.dynmap.JSONUtils.l;
import static org.dynmap.JSONUtils.s; import static org.dynmap.JSONUtils.s;
import org.dynmap.Event.Listener; import org.dynmap.Event.Listener;
@ -33,6 +32,7 @@ public class ClientConfigurationComponent extends Component {
s(wo, "center/x", wn.getFloat("center/x", 0.0f)); s(wo, "center/x", wn.getFloat("center/x", 0.0f));
s(wo, "center/y", wn.getFloat("center/y", 64.0f)); s(wo, "center/y", wn.getFloat("center/y", 64.0f));
s(wo, "center/z", wn.getFloat("center/z", 0.0f)); s(wo, "center/z", wn.getFloat("center/z", 0.0f));
s(wo, "bigworld", world.bigworld);
a(t, "worlds", wo); a(t, "worlds", wo);
for(MapType mt : world.maps) { for(MapType mt : world.maps) {

View File

@ -29,6 +29,7 @@ public class ConfigurationNode implements Map<String, Object> {
entries = map; entries = map;
} }
@SuppressWarnings("unchecked")
public Object getObject(String path) { public Object getObject(String path) {
if (path.isEmpty()) if (path.isEmpty())
return entries; return entries;
@ -60,6 +61,7 @@ public class ConfigurationNode implements Map<String, Object> {
return o; return o;
} }
@SuppressWarnings("unchecked")
public <T> T getGeneric(String path, T def) { public <T> T getGeneric(String path, T def) {
Object o = getObject(path, def); Object o = getObject(path, def);
try { try {
@ -112,6 +114,7 @@ public class ConfigurationNode implements Map<String, Object> {
return o.toString(); return o.toString();
} }
@SuppressWarnings("unchecked")
public <T> List<T> getList(String path) { public <T> List<T> getList(String path) {
try { try {
List<T> list = (List<T>)getObject(path, null); List<T> list = (List<T>)getObject(path, null);
@ -139,6 +142,7 @@ public class ConfigurationNode implements Map<String, Object> {
return new ConfigurationNode(v); return new ConfigurationNode(v);
} }
@SuppressWarnings("unchecked")
public List<ConfigurationNode> getNodes(String path) { public List<ConfigurationNode> getNodes(String path) {
List<Object> o = getList(path); List<Object> o = getList(path);
@ -165,6 +169,7 @@ public class ConfigurationNode implements Map<String, Object> {
extendMap(this, other); extendMap(this, other);
} }
@SuppressWarnings("unchecked")
private final static void extendMap(Map<String, Object> left, Map<String, Object> right) { private final static void extendMap(Map<String, Object> left, Map<String, Object> right) {
ConfigurationNode original = new ConfigurationNode(left); ConfigurationNode original = new ConfigurationNode(left);
for(Map.Entry<String, Object> entry : right.entrySet()) { for(Map.Entry<String, Object> entry : right.entrySet()) {

View File

@ -18,8 +18,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.block.SnowFormEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
@ -180,11 +183,35 @@ public class DynmapPlugin extends JavaPlugin {
BlockListener renderTrigger = new BlockListener() { BlockListener renderTrigger = new BlockListener() {
@Override @Override
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
if(event.isCancelled())
return;
mm.touch(event.getBlockPlaced().getLocation()); mm.touch(event.getBlockPlaced().getLocation());
} }
@Override @Override
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
if(event.isCancelled())
return;
mm.touch(event.getBlock().getLocation());
}
@Override
public void onSnowForm(SnowFormEvent event) {
if(event.isCancelled())
return;
mm.touch(event.getBlock().getLocation());
}
@Override
public void onLeavesDecay(LeavesDecayEvent event) {
if(event.isCancelled())
return;
mm.touch(event.getBlock().getLocation());
}
@Override
public void onBlockBurn(BlockBurnEvent event) {
if(event.isCancelled())
return;
mm.touch(event.getBlock().getLocation()); mm.touch(event.getBlock().getLocation());
} }
}; };
@ -192,6 +219,12 @@ public class DynmapPlugin extends JavaPlugin {
pm.registerEvent(org.bukkit.event.Event.Type.BLOCK_PLACE, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this); pm.registerEvent(org.bukkit.event.Event.Type.BLOCK_PLACE, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
if (isTrigger("blockbreak")) if (isTrigger("blockbreak"))
pm.registerEvent(org.bukkit.event.Event.Type.BLOCK_BREAK, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this); pm.registerEvent(org.bukkit.event.Event.Type.BLOCK_BREAK, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
if (isTrigger("snowform"))
pm.registerEvent(org.bukkit.event.Event.Type.SNOW_FORM, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
if (isTrigger("leavesdecay"))
pm.registerEvent(org.bukkit.event.Event.Type.LEAVES_DECAY, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
if (isTrigger("blockburn"))
pm.registerEvent(org.bukkit.event.Event.Type.BLOCK_BURN, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
} }
{ {
PlayerListener renderTrigger = new PlayerListener() { PlayerListener renderTrigger = new PlayerListener() {

View File

@ -15,4 +15,5 @@ public class DynmapWorld {
public int servertime; public int servertime;
public boolean sendposition; public boolean sendposition;
public boolean sendhealth; public boolean sendhealth;
public boolean bigworld; /* If true, deeper directory hierarchy */
} }

View File

@ -5,6 +5,7 @@ import java.util.Map;
public class Events { public class Events {
public Map<String, Event<?>> events = new HashMap<String, Event<?>>(); public Map<String, Event<?>> events = new HashMap<String, Event<?>>();
@SuppressWarnings("unchecked")
public <T> void addListener(String eventName, Event.Listener<T> listener) { public <T> void addListener(String eventName, Event.Listener<T> listener) {
Event<?> genericEvent = events.get(eventName); Event<?> genericEvent = events.get(eventName);
Event<T> event = null; Event<T> event = null;
@ -16,6 +17,7 @@ public class Events {
event.addListener(listener); event.addListener(listener);
} }
@SuppressWarnings("unchecked")
public <T> void removeListener(String eventName, Event.Listener<T> listener) { public <T> void removeListener(String eventName, Event.Listener<T> listener) {
Event<?> genericEvent = events.get(eventName); Event<?> genericEvent = events.get(eventName);
Event<T> event = null; Event<T> event = null;
@ -25,6 +27,7 @@ public class Events {
} }
} }
@SuppressWarnings("unchecked")
public <T> void trigger(String eventName, T argument) { public <T> void trigger(String eventName, T argument) {
Event<?> genericEvent = events.get(eventName); Event<?> genericEvent = events.get(eventName);
if (genericEvent == null) if (genericEvent == null)

View File

@ -3,7 +3,6 @@ package org.dynmap;
import org.dynmap.Event.Listener; import org.dynmap.Event.Listener;
import org.dynmap.web.handlers.ClientUpdateHandler; import org.dynmap.web.handlers.ClientUpdateHandler;
import org.dynmap.web.handlers.SendMessageHandler; import org.dynmap.web.handlers.SendMessageHandler;
import org.dynmap.web.handlers.SendMessageHandler.Message;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import static org.dynmap.JSONUtils.*; import static org.dynmap.JSONUtils.*;

View File

@ -25,6 +25,7 @@ public class JSONUtils {
} }
// Sets a value on the specified path. If JSONObjects inside the path are missing, they'll be created. // Sets a value on the specified path. If JSONObjects inside the path are missing, they'll be created.
@SuppressWarnings("unchecked")
public static void s(JSONObject o, String path, Object value) { public static void s(JSONObject o, String path, Object value) {
int index = path.indexOf('/'); int index = path.indexOf('/');
if (index == -1) { if (index == -1) {
@ -45,6 +46,7 @@ public class JSONUtils {
} }
// Adds a value to the list at the specified path. If the list does not exist, it will be created. // Adds a value to the list at the specified path. If the list does not exist, it will be created.
@SuppressWarnings("unchecked")
public static void a(JSONObject o, String path, Object value) { public static void a(JSONObject o, String path, Object value) {
Object oo = g(o, path); Object oo = g(o, path);
JSONArray array; JSONArray array;
@ -58,6 +60,7 @@ public class JSONUtils {
} }
// Simply creates a JSONArray. // Simply creates a JSONArray.
@SuppressWarnings("unchecked")
public static JSONArray l(Object... items) { public static JSONArray l(Object... items) {
JSONArray arr = new JSONArray(); JSONArray arr = new JSONArray();
for(Object item : items) { for(Object item : items) {

View File

@ -3,7 +3,6 @@ package org.dynmap;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.Reader; import java.io.Reader;
@ -13,9 +12,7 @@ import java.util.Iterator;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player;
import org.dynmap.web.Json; import org.dynmap.web.Json;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
@ -105,6 +102,7 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
} }
} }
@SuppressWarnings("unchecked")
protected void writeUpdates() { protected void writeUpdates() {
File outputFile; File outputFile;
File outputTempFile; File outputTempFile;

View File

@ -300,6 +300,7 @@ public class MapManager {
dynmapWorld.servertime = (int)(w.getTime() % 24000); dynmapWorld.servertime = (int)(w.getTime() % 24000);
dynmapWorld.sendposition = worldConfiguration.getBoolean("sendposition", true); dynmapWorld.sendposition = worldConfiguration.getBoolean("sendposition", true);
dynmapWorld.sendhealth = worldConfiguration.getBoolean("sendhealth", true); dynmapWorld.sendhealth = worldConfiguration.getBoolean("sendhealth", true);
dynmapWorld.bigworld = worldConfiguration.getBoolean("bigworld", false);
if(loclist != null) { if(loclist != null) {
for(ConfigurationNode loc : loclist) { for(ConfigurationNode loc : loclist) {
Location lx = new Location(w, loc.getDouble("x", 0), loc.getDouble("y", 64), loc.getDouble("z", 0)); Location lx = new Location(w, loc.getDouble("x", 0), loc.getDouble("y", 64), loc.getDouble("z", 0));

View File

@ -3,10 +3,14 @@ package org.dynmap;
import org.bukkit.World; import org.bukkit.World;
public abstract class MapTile { public abstract class MapTile {
private World world; protected DynmapWorld world;
private MapType map; private MapType map;
public World getWorld() { public World getWorld() {
return world.world;
}
public DynmapWorld getDynmapWorld() {
return world; return world;
} }
@ -18,7 +22,7 @@ public abstract class MapTile {
public abstract String getDayFilename(); public abstract String getDayFilename();
public MapTile(World world, MapType map) { public MapTile(DynmapWorld world, MapType map) {
this.world = world; this.world = world;
this.map = map; this.map = map;
} }
@ -38,6 +42,6 @@ public abstract class MapTile {
} }
public String getKey() { public String getKey() {
return world.getName() + "." + map.getName(); return world.world.getName() + "." + map.getName();
} }
} }

View File

@ -1,5 +1,6 @@
package org.dynmap.flat; package org.dynmap.flat;
import org.dynmap.DynmapWorld;
import static org.dynmap.JSONUtils.a; import static org.dynmap.JSONUtils.a;
import static org.dynmap.JSONUtils.s; import static org.dynmap.JSONUtils.s;
import java.io.File; import java.io.File;
@ -72,13 +73,14 @@ public class FlatMap extends MapType {
@Override @Override
public MapTile[] getTiles(Location l) { public MapTile[] getTiles(Location l) {
return new MapTile[] { new FlatMapTile(l.getWorld(), this, (int) Math.floor(l.getBlockX() / 128.0), (int) Math.floor(l.getBlockZ() / 128.0), 128) }; DynmapWorld w = MapManager.mapman.getWorld(l.getWorld().getName());
return new MapTile[] { new FlatMapTile(w, this, (int) Math.floor(l.getBlockX() / 128.0), (int) Math.floor(l.getBlockZ() / 128.0), 128) };
} }
@Override @Override
public MapTile[] getAdjecentTiles(MapTile tile) { public MapTile[] getAdjecentTiles(MapTile tile) {
FlatMapTile t = (FlatMapTile) tile; FlatMapTile t = (FlatMapTile) tile;
World w = t.getWorld(); DynmapWorld w = t.getDynmapWorld();
int x = t.x; int x = t.x;
int y = t.y; int y = t.y;
int s = t.size; int s = t.size;
@ -254,6 +256,8 @@ public class FlatMap extends MapType {
if((!outputFile.exists()) || (crc != hashman.getImageHashCode(tile.getKey(), null, t.x, t.y))) { if((!outputFile.exists()) || (crc != hashman.getImageHashCode(tile.getKey(), null, t.x, t.y))) {
/* Wrap buffer as buffered image */ /* Wrap buffer as buffered image */
Debug.debug("saving image " + outputFile.getPath()); Debug.debug("saving image " + outputFile.getPath());
if(!outputFile.getParentFile().exists())
outputFile.getParentFile().mkdirs();
try { try {
ImageIO.write(im.buf_img, "png", outputFile); ImageIO.write(im.buf_img, "png", outputFile);
} catch (IOException e) { } catch (IOException e) {
@ -279,6 +283,8 @@ public class FlatMap extends MapType {
crc = hashman.calculateTileHash(argb_buf_day); crc = hashman.calculateTileHash(argb_buf_day);
if((!dayfile.exists()) || (crc != hashman.getImageHashCode(tile.getKey(), "day", t.x, t.y))) { if((!dayfile.exists()) || (crc != hashman.getImageHashCode(tile.getKey(), "day", t.x, t.y))) {
Debug.debug("saving image " + dayfile.getPath()); Debug.debug("saving image " + dayfile.getPath());
if(!dayfile.getParentFile().exists())
dayfile.getParentFile().mkdirs();
try { try {
ImageIO.write(im_day.buf_img, "png", dayfile); ImageIO.write(im_day.buf_img, "png", dayfile);
} catch (IOException e) { } catch (IOException e) {
@ -384,8 +390,10 @@ public class FlatMap extends MapType {
public int x; public int x;
public int y; public int y;
public int size; public int size;
private String fname;
private String fname_day;
public FlatMapTile(World world, FlatMap map, int x, int y, int size) { public FlatMapTile(DynmapWorld world, FlatMap map, int x, int y, int size) {
super(world, map); super(world, map);
this.map = map; this.map = map;
this.x = x; this.x = x;
@ -395,11 +403,23 @@ public class FlatMap extends MapType {
@Override @Override
public String getFilename() { public String getFilename() {
return map.prefix + "_" + size + "_" + -(y+1) + "_" + x + ".png"; if(fname == null) {
if(world.bigworld)
fname = map.prefix + "/" + ((-(y+1))>>5) + "_" + (x>>5) + "/" + size + "_" + -(y+1) + "_" + x + ".png";
else
fname = map.prefix + "_" + size + "_" + -(y+1) + "_" + x + ".png";
}
return fname;
} }
@Override @Override
public String getDayFilename() { public String getDayFilename() {
return map.prefix + "_day_" + size + "_" + -(y+1) + "_" + x + ".png"; if(fname_day == null) {
if(world.bigworld)
fname_day = map.prefix + "_day/" + ((-(y+1))>>5) + "_" + (x>>5) + "/" + size + "_" + -(y+1) + "_" + x + ".png";
else
fname_day = map.prefix + "_day_" + size + "_" + -(y+1) + "_" + x + ".png";
}
return fname_day;
} }
public String toString() { public String toString() {
return getWorld().getName() + ":" + getFilename(); return getWorld().getName() + ":" + getFilename();

View File

@ -10,7 +10,6 @@ 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 org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.lang.reflect.Field;
import org.dynmap.Client; import org.dynmap.Client;
import org.dynmap.ConfigurationNode; import org.dynmap.ConfigurationNode;
import org.dynmap.DynmapPlugin; import org.dynmap.DynmapPlugin;
@ -40,6 +39,7 @@ public class HeroChatHandler {
/* Reflection-based access wrapper for ChannelChatEvent from HeroChat */ /* Reflection-based access wrapper for ChannelChatEvent from HeroChat */
private static class HeroChatChannelChatEvent { private static class HeroChatChannelChatEvent {
@SuppressWarnings("rawtypes")
private static Class channelchatevent; private static Class channelchatevent;
private static Method getsource; private static Method getsource;
private static Method getmessage; private static Method getmessage;
@ -97,6 +97,7 @@ public class HeroChatHandler {
/* Reflection-based access wrapper for ChannelEvent from HeroChat */ /* Reflection-based access wrapper for ChannelEvent from HeroChat */
private static class HeroChatChannelEvent { private static class HeroChatChannelEvent {
@SuppressWarnings("rawtypes")
private static Class channelevent; private static Class channelevent;
private static Method getchannel; private static Method getchannel;
private static Method iscancelled; private static Method iscancelled;
@ -148,6 +149,7 @@ public class HeroChatHandler {
/* Reflection-based access wrapper for Channel from HeroChat */ /* Reflection-based access wrapper for Channel from HeroChat */
private static class HeroChatChannel { private static class HeroChatChannel {
@SuppressWarnings("rawtypes")
private static Class channel; private static Class channel;
private static Method getname; private static Method getname;
private static Method getnick; private static Method getnick;

View File

@ -189,7 +189,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
} }
/* Hand encoding and writing file off to MapManager */ /* Hand encoding and writing file off to MapManager */
KzedZoomedMapTile zmtile = new KzedZoomedMapTile(tile.getWorld(), KzedZoomedMapTile zmtile = new KzedZoomedMapTile(tile.getDynmapWorld(),
(KzedMap) tile.getMap(), tile); (KzedMap) tile.getMap(), tile);
File zoomFile = MapManager.mapman.getTileFile(zmtile); File zoomFile = MapManager.mapman.getTileFile(zmtile);
@ -240,6 +240,8 @@ public class DefaultTileRenderer implements MapTileRenderer {
int ty = mtile.py/KzedMap.tileHeight; int ty = mtile.py/KzedMap.tileHeight;
if((!fname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(), null, tx, ty))) { if((!fname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(), null, tx, ty))) {
Debug.debug("saving image " + fname.getPath()); Debug.debug("saving image " + fname.getPath());
if(!fname.getParentFile().exists())
fname.getParentFile().mkdirs();
try { try {
ImageIO.write(img.buf_img, "png", fname); ImageIO.write(img.buf_img, "png", fname);
} catch (IOException e) { } catch (IOException e) {
@ -264,6 +266,8 @@ public class DefaultTileRenderer implements MapTileRenderer {
crc = hashman.calculateTileHash(img.argb_buf); crc = hashman.calculateTileHash(img.argb_buf);
if((!dfname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(), "day", tx, ty))) { if((!dfname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(), "day", tx, ty))) {
Debug.debug("saving image " + dfname.getPath()); Debug.debug("saving image " + dfname.getPath());
if(!dfname.getParentFile().exists())
dfname.getParentFile().mkdirs();
try { try {
ImageIO.write(img_day.buf_img, "png", dfname); ImageIO.write(img_day.buf_img, "png", dfname);
} catch (IOException e) { } catch (IOException e) {
@ -335,6 +339,8 @@ public class DefaultTileRenderer implements MapTileRenderer {
zIm.setRGB(ox, oy, KzedMap.tileWidth/2, KzedMap.tileHeight/2, zimg.argb_buf, 0, KzedMap.tileWidth/2); zIm.setRGB(ox, oy, KzedMap.tileWidth/2, KzedMap.tileHeight/2, zimg.argb_buf, 0, KzedMap.tileWidth/2);
/* save zoom-out tile */ /* save zoom-out tile */
if(!zoomFile.getParentFile().exists())
zoomFile.getParentFile().mkdirs();
try { try {
ImageIO.write(zIm, "png", zoomFile); ImageIO.write(zIm, "png", zoomFile);

View File

@ -1,5 +1,6 @@
package org.dynmap.kzedmap; package org.dynmap.kzedmap;
import org.dynmap.DynmapWorld;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -10,10 +11,10 @@ import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World;
import org.dynmap.ConfigurationNode; import org.dynmap.ConfigurationNode;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.Log; import org.dynmap.Log;
import org.dynmap.MapManager;
import org.dynmap.MapTile; import org.dynmap.MapTile;
import org.dynmap.MapType; import org.dynmap.MapType;
import org.dynmap.utils.MapChunkCache; import org.dynmap.utils.MapChunkCache;
@ -70,7 +71,7 @@ public class KzedMap extends MapType {
@Override @Override
public MapTile[] getTiles(Location l) { public MapTile[] getTiles(Location l) {
World world = l.getWorld(); DynmapWorld world = MapManager.mapman.getWorld(l.getWorld().getName());
int x = l.getBlockX(); int x = l.getBlockX();
int y = l.getBlockY(); int y = l.getBlockY();
@ -121,7 +122,7 @@ public class KzedMap extends MapType {
public MapTile[] getAdjecentTiles(MapTile tile) { public MapTile[] getAdjecentTiles(MapTile tile) {
if (tile instanceof KzedMapTile) { if (tile instanceof KzedMapTile) {
KzedMapTile t = (KzedMapTile) tile; KzedMapTile t = (KzedMapTile) tile;
World world = tile.getWorld(); DynmapWorld world = tile.getDynmapWorld();
MapTileRenderer renderer = t.renderer; MapTileRenderer renderer = t.renderer;
return new MapTile[] { return new MapTile[] {
new KzedMapTile(world, this, renderer, t.px - tileWidth, t.py), new KzedMapTile(world, this, renderer, t.px - tileWidth, t.py),
@ -132,7 +133,7 @@ public class KzedMap extends MapType {
return new MapTile[0]; return new MapTile[0];
} }
public void addTile(ArrayList<MapTile> tiles, World world, int px, int py) { public void addTile(ArrayList<MapTile> tiles, DynmapWorld world, int px, int py) {
for (int i = 0; i < renderers.length; i++) { for (int i = 0; i < renderers.length; i++) {
tiles.add(new KzedMapTile(world, this, renderers[i], px, py)); tiles.add(new KzedMapTile(world, this, renderers[i], px, py));
} }

View File

@ -1,19 +1,20 @@
package org.dynmap.kzedmap; package org.dynmap.kzedmap;
import org.dynmap.DynmapWorld;
import java.io.File; import java.io.File;
import org.bukkit.World;
import org.dynmap.MapTile; import org.dynmap.MapTile;
public class KzedMapTile extends MapTile { public class KzedMapTile extends MapTile {
public KzedMap map; public KzedMap map;
public MapTileRenderer renderer; public MapTileRenderer renderer;
public int px, py; public int px, py;
private String fname;
private String fname_day;
// Hack. // Hack.
public File file = null; public File file = null;
public KzedMapTile(World world, KzedMap map, MapTileRenderer renderer, int px, int py) { public KzedMapTile(DynmapWorld world, KzedMap map, MapTileRenderer renderer, int px, int py) {
super(world, map); super(world, map);
this.map = map; this.map = map;
this.renderer = renderer; this.renderer = renderer;
@ -23,12 +24,24 @@ public class KzedMapTile extends MapTile {
@Override @Override
public String getFilename() { public String getFilename() {
return renderer.getName() + "_" + px + "_" + py + ".png"; if(fname == null) {
if(world.bigworld)
fname = renderer.getName() + "/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png";
else
fname = renderer.getName() + "_" + px + "_" + py + ".png";
}
return fname;
} }
@Override @Override
public String getDayFilename() { public String getDayFilename() {
return renderer.getName() + "_day_" + px + "_" + py + ".png"; if(fname_day == null) {
if(world.bigworld)
fname_day = renderer.getName() + "_day/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png";
else
fname_day = renderer.getName() + "_day_" + px + "_" + py + ".png";
}
return fname_day;
} }
@Override @Override

View File

@ -1,22 +1,39 @@
package org.dynmap.kzedmap; package org.dynmap.kzedmap;
import org.bukkit.World; import org.dynmap.DynmapWorld;
import org.dynmap.MapTile; import org.dynmap.MapTile;
public class KzedZoomedMapTile extends MapTile { public class KzedZoomedMapTile extends MapTile {
private String fname;
private String fname_day;
@Override @Override
public String getFilename() { public String getFilename() {
return "z" + originalTile.renderer.getName() + "_" + getTileX() + "_" + getTileY() + ".png"; if(fname == null) {
if(world.bigworld)
fname = "z" + originalTile.renderer.getName() + "/" + (getTileX()>>12) + '_' +
(getTileY() >> 12) + '/' + getTileX() + "_" + getTileY() + ".png";
else
fname = "z" + originalTile.renderer.getName() + "_" + getTileX() + "_" + getTileY() + ".png";
}
return fname;
} }
@Override @Override
public String getDayFilename() { public String getDayFilename() {
return "z" + originalTile.renderer.getName() + "_day_" + getTileX() + "_" + getTileY() + ".png"; if(fname_day == null) {
if(world.bigworld)
fname_day = "z" + originalTile.renderer.getName() + "_day/" + (getTileX()>>12) + '_' +
(getTileY() >> 12) + '/' + getTileX() + "_" + getTileY() + ".png";
else
fname_day = "z" + originalTile.renderer.getName() + "_day_" + getTileX() + "_" + getTileY() + ".png";
}
return fname_day;
} }
public KzedMapTile originalTile; public KzedMapTile originalTile;
public KzedZoomedMapTile(World world, KzedMap map, KzedMapTile original) { public KzedZoomedMapTile(DynmapWorld world, KzedMap map, KzedMapTile original) {
super(world, map); super(world, map);
this.originalTile = original; this.originalTile = original;
} }

View File

@ -2,8 +2,6 @@ package org.dynmap.web.handlers;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.util.Date; import java.util.Date;
import java.util.Map;
import org.dynmap.DynmapPlugin; import org.dynmap.DynmapPlugin;
import org.dynmap.DynmapWorld; import org.dynmap.DynmapWorld;
import org.dynmap.Event; import org.dynmap.Event;

View File

@ -5,24 +5,14 @@ import java.util.Date;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.config.Configuration;
import org.dynmap.Client;
import org.dynmap.ClientUpdateEvent; import org.dynmap.ClientUpdateEvent;
import org.dynmap.DynmapPlugin; import org.dynmap.DynmapPlugin;
import org.dynmap.DynmapWorld; import org.dynmap.DynmapWorld;
import org.dynmap.MapManager;
import org.dynmap.PlayerList;
import org.dynmap.web.HttpField; import org.dynmap.web.HttpField;
import org.dynmap.web.HttpHandler; 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 org.dynmap.web.Json;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import static org.dynmap.JSONUtils.*; import static org.dynmap.JSONUtils.*;

View File

@ -13,7 +13,6 @@ 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 org.dynmap.utils.FileLockManager;
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");

View File

@ -9,14 +9,14 @@ var config = {
// For proxying webserver through php. // For proxying webserver through php.
// url: { // url: {
// configuration: 'up.php?path=configuration', // configuration: 'up.php?path=configuration',
// update: 'up.php?path=world/{world}/?{timestamp}', // update: 'up.php?path=world/{world}/{timestamp}',
// sendmessage: 'up.php?path=sendmessage' // sendmessage: 'up.php?path=sendmessage'
// }, // },
// For proxying webserver through aspx. // For proxying webserver through aspx.
// url: { // url: {
// configuration: 'up.aspx?path=configuration', // configuration: 'up.aspx?path=configuration',
// update: 'up.aspx?path=world/{world}/?{timestamp}', // update: 'up.aspx?path=world/{world}/{timestamp}',
// sendmessage: 'up.aspx?path=sendmessage' // sendmessage: 'up.aspx?path=sendmessage'
// }, // },

View File

@ -29,6 +29,10 @@ FlatMapType.prototype = $.extend(new DynMapType(), {
if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].nightandday && this.dynmap.serverday) if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].nightandday && this.dynmap.serverday)
dnprefix = '_day'; dnprefix = '_day';
if(this.dynmap.world.bigworld)
tileName = this.prefix + dnprefix + '/' + (coord.x >> 5) + '_' + (coord.y >> 5) +
'/128_' + coord.x + '_' + coord.y + '.png';
else
tileName = this.prefix + dnprefix + '_128_' + coord.x + '_' + coord.y + '.png'; tileName = this.prefix + dnprefix + '_128_' + coord.x + '_' + coord.y + '.png';
imgSize = Math.pow(2, 7+zoom); imgSize = Math.pow(2, 7+zoom);
var tile = $('<div/>') var tile = $('<div/>')

View File

@ -51,13 +51,27 @@ KzedMapType.prototype = $.extend(new DynMapType(), {
// Most zoomed out tiles. // Most zoomed out tiles.
tileSize = 128; tileSize = 128;
imgSize = tileSize; imgSize = tileSize;
if (this.dynmap.world.bigworld) {
tileName = 'z' + this.prefix + dnprefix + '/' + ((-coord.x * tileSize*2)>>12) +
'_' + ((coord.y * tileSize*2) >> 12) + '/' +
(-coord.x * tileSize*2) + '_' + (coord.y * tileSize*2) + '.png';
}
else {
tileName = 'z' + this.prefix + dnprefix + '_' + (-coord.x * tileSize*2) + '_' + (coord.y * tileSize*2) + '.png'; tileName = 'z' + this.prefix + dnprefix + '_' + (-coord.x * tileSize*2) + '_' + (coord.y * tileSize*2) + '.png';
}
} else { } else {
// Other zoom levels. // Other zoom levels.
tileSize = 128; tileSize = 128;
imgSize = Math.pow(2, 6+zoom); imgSize = Math.pow(2, 6+zoom);
if(this.dynmap.world.bigworld) {
tileName = this.prefix + dnprefix + '/' + ((-coord.x*tileSize) >> 12) + '_' +
((coord.y*tileSize)>>12) + '/' +
(-coord.x*tileSize) + '_' + (coord.y*tileSize) + '.png';
}
else {
tileName = this.prefix + dnprefix + '_' + (-coord.x*tileSize) + '_' + (coord.y*tileSize) + '.png'; tileName = this.prefix + dnprefix + '_' + (-coord.x*tileSize) + '_' + (coord.y*tileSize) + '.png';
}
} }
var img; var img;
var tile = $('<div/>') var tile = $('<div/>')