From b19d8f8745c22cf5f8054dc4f606fc9f8408cc92 Mon Sep 17 00:00:00 2001 From: FrozenCow Date: Mon, 13 Jun 2011 23:37:35 +0200 Subject: [PATCH 1/4] Fixed urls for php and aspx proxies. --- web/config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/config.js b/web/config.js index f4c02493..347446b2 100644 --- a/web/config.js +++ b/web/config.js @@ -9,14 +9,14 @@ var config = { // For proxying webserver through php. // url: { // configuration: 'up.php?path=configuration', - // update: 'up.php?path=world/{world}/?{timestamp}', + // update: 'up.php?path=world/{world}/{timestamp}', // sendmessage: 'up.php?path=sendmessage' // }, // For proxying webserver through aspx. // url: { // configuration: 'up.aspx?path=configuration', - // update: 'up.aspx?path=world/{world}/?{timestamp}', + // update: 'up.aspx?path=world/{world}/{timestamp}', // sendmessage: 'up.aspx?path=sendmessage' // }, @@ -30,4 +30,4 @@ var config = { tileUrl : 'tiles/', tileWidth : 128, tileHeight : 128 -}; \ No newline at end of file +}; From 0cf7b4be9b83040a62d7e9ca7b7eecd137f1ed2e Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Mon, 13 Jun 2011 21:43:02 -0500 Subject: [PATCH 2/4] Add alternate directory structure to better support huge worlds --- configuration.txt | 8 +++++ .../dynmap/ClientConfigurationComponent.java | 2 +- src/main/java/org/dynmap/DynmapWorld.java | 1 + .../dynmap/InternalClientUpdateComponent.java | 1 - .../dynmap/JsonFileClientUpdateComponent.java | 3 -- src/main/java/org/dynmap/MapChunkCache.java | 3 -- src/main/java/org/dynmap/MapManager.java | 1 + src/main/java/org/dynmap/MapTile.java | 10 +++++-- src/main/java/org/dynmap/flat/FlatMap.java | 30 +++++++++++++++---- .../dynmap/kzedmap/DefaultTileRenderer.java | 8 ++++- src/main/java/org/dynmap/kzedmap/KzedMap.java | 16 ++++------ .../java/org/dynmap/kzedmap/KzedMapTile.java | 21 +++++++++++-- .../org/dynmap/kzedmap/KzedZoomedMapTile.java | 24 +++++++++++++-- .../dynmap/kzedmap/ZoomedTileRenderer.java | 13 -------- web/js/flatmap.js | 8 +++-- web/js/kzedmaps.js | 20 +++++++++++-- 16 files changed, 118 insertions(+), 51 deletions(-) delete mode 100644 src/main/java/org/dynmap/kzedmap/ZoomedTileRenderer.java diff --git a/configuration.txt b/configuration.txt index 3159aef8..1cb80333 100644 --- a/configuration.txt +++ b/configuration.txt @@ -121,6 +121,8 @@ templates: # Template for normal world normal: enabled: true + # If bigworld set to true, use alternate directory layout better suited to large worlds + # bigworld: true center: x: 0 y: 64 @@ -184,6 +186,8 @@ templates: # Nether world template nether: enabled: true + # If bigworld set to true, use alternate directory layout better suited to large worlds + # bigworld: true center: x: 0 y: 64 @@ -209,6 +213,8 @@ templates: # Skylands world template skylands: enabled: true + # If bigworld set to true, use alternate directory layout better suited to large worlds + # bigworld: true center: x: 0 y: 64 @@ -267,6 +273,8 @@ worlds: # x: 0 # y: 64 # z: 0 + # # If bigworld set to true, use alternate directory layout better suited to large worlds + # # bigworld: true # maps: # - class: org.dynmap.flat.FlatMap # name: flat diff --git a/src/main/java/org/dynmap/ClientConfigurationComponent.java b/src/main/java/org/dynmap/ClientConfigurationComponent.java index d39f5488..6c795e79 100644 --- a/src/main/java/org/dynmap/ClientConfigurationComponent.java +++ b/src/main/java/org/dynmap/ClientConfigurationComponent.java @@ -1,7 +1,6 @@ package org.dynmap; import static org.dynmap.JSONUtils.a; -import static org.dynmap.JSONUtils.l; import static org.dynmap.JSONUtils.s; 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/y", wn.getFloat("center/y", 64.0f)); s(wo, "center/z", wn.getFloat("center/z", 0.0f)); + s(wo, "bigworld", world.bigworld); a(t, "worlds", wo); for(MapType mt : world.maps) { diff --git a/src/main/java/org/dynmap/DynmapWorld.java b/src/main/java/org/dynmap/DynmapWorld.java index e4896392..71a8a3e7 100644 --- a/src/main/java/org/dynmap/DynmapWorld.java +++ b/src/main/java/org/dynmap/DynmapWorld.java @@ -15,4 +15,5 @@ public class DynmapWorld { public int servertime; public boolean sendposition; public boolean sendhealth; + public boolean bigworld; /* If true, deeper directory hierarchy */ } diff --git a/src/main/java/org/dynmap/InternalClientUpdateComponent.java b/src/main/java/org/dynmap/InternalClientUpdateComponent.java index b1dadb9f..160cd458 100644 --- a/src/main/java/org/dynmap/InternalClientUpdateComponent.java +++ b/src/main/java/org/dynmap/InternalClientUpdateComponent.java @@ -3,7 +3,6 @@ package org.dynmap; import org.dynmap.Event.Listener; import org.dynmap.web.handlers.ClientUpdateHandler; import org.dynmap.web.handlers.SendMessageHandler; -import org.dynmap.web.handlers.SendMessageHandler.Message; import org.json.simple.JSONObject; import static org.dynmap.JSONUtils.*; diff --git a/src/main/java/org/dynmap/JsonFileClientUpdateComponent.java b/src/main/java/org/dynmap/JsonFileClientUpdateComponent.java index e140d2d9..57723b26 100644 --- a/src/main/java/org/dynmap/JsonFileClientUpdateComponent.java +++ b/src/main/java/org/dynmap/JsonFileClientUpdateComponent.java @@ -3,7 +3,6 @@ package org.dynmap; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; -import java.io.FileReader; import java.io.InputStreamReader; import java.io.FileInputStream; import java.io.Reader; @@ -13,9 +12,7 @@ import java.util.Iterator; import java.util.Timer; import java.util.TimerTask; -import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.entity.Player; import org.dynmap.web.Json; import org.json.simple.JSONArray; import org.json.simple.JSONObject; diff --git a/src/main/java/org/dynmap/MapChunkCache.java b/src/main/java/org/dynmap/MapChunkCache.java index e8d11145..fa6b7cf4 100644 --- a/src/main/java/org/dynmap/MapChunkCache.java +++ b/src/main/java/org/dynmap/MapChunkCache.java @@ -2,7 +2,6 @@ package org.dynmap; import java.lang.reflect.Method; import java.lang.reflect.Field; -import java.util.LinkedList; import org.bukkit.World; import org.bukkit.Chunk; import org.bukkit.entity.Entity; @@ -11,7 +10,6 @@ import org.bukkit.entity.Entity; * Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread */ public class MapChunkCache { - private World w; private static Method getchunkdata = null; private static Method gethandle = null; private static Method poppreservedchunk = null; @@ -164,7 +162,6 @@ public class MapChunkCache { } x_dim = x_max - x_min + 1; } - this.w = w; if(!initialized) { try { diff --git a/src/main/java/org/dynmap/MapManager.java b/src/main/java/org/dynmap/MapManager.java index c0e99199..c7c24723 100644 --- a/src/main/java/org/dynmap/MapManager.java +++ b/src/main/java/org/dynmap/MapManager.java @@ -297,6 +297,7 @@ public class MapManager { dynmapWorld.servertime = (int)(w.getTime() % 24000); dynmapWorld.sendposition = worldConfiguration.getBoolean("sendposition", true); dynmapWorld.sendhealth = worldConfiguration.getBoolean("sendhealth", true); + dynmapWorld.bigworld = worldConfiguration.getBoolean("bigworld", false); if(loclist != null) { for(ConfigurationNode loc : loclist) { Location lx = new Location(w, loc.getDouble("x", 0), loc.getDouble("y", 64), loc.getDouble("z", 0)); diff --git a/src/main/java/org/dynmap/MapTile.java b/src/main/java/org/dynmap/MapTile.java index 552ad561..04f63aea 100644 --- a/src/main/java/org/dynmap/MapTile.java +++ b/src/main/java/org/dynmap/MapTile.java @@ -3,10 +3,14 @@ package org.dynmap; import org.bukkit.World; public abstract class MapTile { - private World world; + protected DynmapWorld world; private MapType map; public World getWorld() { + return world.world; + } + + public DynmapWorld getDynmapWorld() { return world; } @@ -18,7 +22,7 @@ public abstract class MapTile { public abstract String getDayFilename(); - public MapTile(World world, MapType map) { + public MapTile(DynmapWorld world, MapType map) { this.world = world; this.map = map; } @@ -38,6 +42,6 @@ public abstract class MapTile { } public String getKey() { - return world.getName() + "." + map.getName(); + return world.world.getName() + "." + map.getName(); } } diff --git a/src/main/java/org/dynmap/flat/FlatMap.java b/src/main/java/org/dynmap/flat/FlatMap.java index 28496330..1b83b810 100644 --- a/src/main/java/org/dynmap/flat/FlatMap.java +++ b/src/main/java/org/dynmap/flat/FlatMap.java @@ -1,5 +1,6 @@ package org.dynmap.flat; +import org.dynmap.DynmapWorld; import static org.dynmap.JSONUtils.a; import static org.dynmap.JSONUtils.s; import java.awt.image.DataBufferInt; @@ -75,13 +76,14 @@ public class FlatMap extends MapType { @Override 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 public MapTile[] getAdjecentTiles(MapTile tile) { FlatMapTile t = (FlatMapTile) tile; - World w = t.getWorld(); + DynmapWorld w = t.getDynmapWorld(); int x = t.x; int y = t.y; int s = t.size; @@ -257,6 +259,8 @@ public class FlatMap extends MapType { if((!outputFile.exists()) || (crc != hashman.getImageHashCode(tile.getKey(), null, t.x, t.y))) { /* Wrap buffer as buffered image */ Debug.debug("saving image " + outputFile.getPath()); + if(!outputFile.getParentFile().exists()) + outputFile.getParentFile().mkdirs(); try { ImageIO.write(im.buf_img, "png", outputFile); } catch (IOException e) { @@ -282,6 +286,8 @@ public class FlatMap extends MapType { crc = hashman.calculateTileHash(argb_buf_day); if((!dayfile.exists()) || (crc != hashman.getImageHashCode(tile.getKey(), "day", t.x, t.y))) { Debug.debug("saving image " + dayfile.getPath()); + if(!dayfile.getParentFile().exists()) + dayfile.getParentFile().mkdirs(); try { ImageIO.write(im_day.buf_img, "png", dayfile); } catch (IOException e) { @@ -387,8 +393,10 @@ public class FlatMap extends MapType { public int x; public int y; 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); this.map = map; this.x = x; @@ -398,11 +406,23 @@ public class FlatMap extends MapType { @Override 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 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() { return getWorld().getName() + ":" + getFilename(); diff --git a/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java b/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java index 0caa498e..cdfa854d 100644 --- a/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java +++ b/src/main/java/org/dynmap/kzedmap/DefaultTileRenderer.java @@ -188,7 +188,7 @@ public class DefaultTileRenderer implements MapTileRenderer { } /* Hand encoding and writing file off to MapManager */ - KzedZoomedMapTile zmtile = new KzedZoomedMapTile(tile.getWorld(), + KzedZoomedMapTile zmtile = new KzedZoomedMapTile(tile.getDynmapWorld(), (KzedMap) tile.getMap(), tile); File zoomFile = MapManager.mapman.getTileFile(zmtile); @@ -239,6 +239,8 @@ public class DefaultTileRenderer implements MapTileRenderer { int ty = mtile.py/KzedMap.tileHeight; if((!fname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(), null, tx, ty))) { Debug.debug("saving image " + fname.getPath()); + if(!fname.getParentFile().exists()) + fname.getParentFile().mkdirs(); try { ImageIO.write(img.buf_img, "png", fname); } catch (IOException e) { @@ -263,6 +265,8 @@ public class DefaultTileRenderer implements MapTileRenderer { crc = hashman.calculateTileHash(img.argb_buf); if((!dfname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(), "day", tx, ty))) { Debug.debug("saving image " + dfname.getPath()); + if(!dfname.getParentFile().exists()) + dfname.getParentFile().mkdirs(); try { ImageIO.write(img_day.buf_img, "png", dfname); } catch (IOException e) { @@ -334,6 +338,8 @@ public class DefaultTileRenderer implements MapTileRenderer { zIm.setRGB(ox, oy, KzedMap.tileWidth/2, KzedMap.tileHeight/2, zimg.argb_buf, 0, KzedMap.tileWidth/2); /* save zoom-out tile */ + if(!zoomFile.getParentFile().exists()) + zoomFile.getParentFile().mkdirs(); try { ImageIO.write(zIm, "png", zoomFile); diff --git a/src/main/java/org/dynmap/kzedmap/KzedMap.java b/src/main/java/org/dynmap/kzedmap/KzedMap.java index 201ef50e..078694ed 100644 --- a/src/main/java/org/dynmap/kzedmap/KzedMap.java +++ b/src/main/java/org/dynmap/kzedmap/KzedMap.java @@ -1,5 +1,6 @@ package org.dynmap.kzedmap; +import org.dynmap.DynmapWorld; import java.awt.image.BufferedImage; import java.io.File; import java.util.ArrayList; @@ -14,6 +15,7 @@ import org.bukkit.World; import org.dynmap.ConfigurationNode; import org.dynmap.DynmapChunk; import org.dynmap.Log; +import org.dynmap.MapManager; import org.dynmap.MapTile; import org.dynmap.MapType; import org.dynmap.MapChunkCache; @@ -45,7 +47,6 @@ public class KzedMap extends MapType { public static final int anchorz = 0; MapTileRenderer[] renderers; - ZoomedTileRenderer zoomrenderer; /* BufferedImage with direct access to its ARGB-formatted data buffer */ public static class KzedBufferedImage { @@ -67,13 +68,11 @@ public class KzedMap extends MapType { this.renderers = new MapTileRenderer[renderers.size()]; renderers.toArray(this.renderers); Log.info("Loaded " + renderers.size() + " renderers for map '" + getClass().toString() + "'."); - - zoomrenderer = new ZoomedTileRenderer(configuration); } @Override public MapTile[] getTiles(Location l) { - World world = l.getWorld(); + DynmapWorld world = MapManager.mapman.getWorld(l.getWorld().getName()); int x = l.getBlockX(); int y = l.getBlockY(); @@ -124,7 +123,7 @@ public class KzedMap extends MapType { public MapTile[] getAdjecentTiles(MapTile tile) { if (tile instanceof KzedMapTile) { KzedMapTile t = (KzedMapTile) tile; - World world = tile.getWorld(); + DynmapWorld world = tile.getDynmapWorld(); MapTileRenderer renderer = t.renderer; return new MapTile[] { new KzedMapTile(world, this, renderer, t.px - tileWidth, t.py), @@ -135,7 +134,7 @@ public class KzedMap extends MapType { return new MapTile[0]; } - public void addTile(ArrayList tiles, World world, int px, int py) { + public void addTile(ArrayList tiles, DynmapWorld world, int px, int py) { for (int i = 0; i < renderers.length; i++) { tiles.add(new KzedMapTile(world, this, renderers[i], px, py)); } @@ -229,10 +228,7 @@ public class KzedMap extends MapType { @Override public boolean render(MapChunkCache cache, MapTile tile, File outputFile) { - if (tile instanceof KzedZoomedMapTile) { - zoomrenderer.render(cache, (KzedZoomedMapTile) tile, outputFile); - return true; - } else if (tile instanceof KzedMapTile) { + if (tile instanceof KzedMapTile) { return ((KzedMapTile) tile).renderer.render(cache, (KzedMapTile) tile, outputFile); } return false; diff --git a/src/main/java/org/dynmap/kzedmap/KzedMapTile.java b/src/main/java/org/dynmap/kzedmap/KzedMapTile.java index 14ab7baf..3d958c35 100644 --- a/src/main/java/org/dynmap/kzedmap/KzedMapTile.java +++ b/src/main/java/org/dynmap/kzedmap/KzedMapTile.java @@ -1,5 +1,6 @@ package org.dynmap.kzedmap; +import org.dynmap.DynmapWorld; import java.io.File; import org.bukkit.World; @@ -9,11 +10,13 @@ public class KzedMapTile extends MapTile { public KzedMap map; public MapTileRenderer renderer; public int px, py; + private String fname; + private String fname_day; // Hack. 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); this.map = map; this.renderer = renderer; @@ -23,12 +26,24 @@ public class KzedMapTile extends MapTile { @Override 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 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 diff --git a/src/main/java/org/dynmap/kzedmap/KzedZoomedMapTile.java b/src/main/java/org/dynmap/kzedmap/KzedZoomedMapTile.java index 5d33bffe..7516b992 100644 --- a/src/main/java/org/dynmap/kzedmap/KzedZoomedMapTile.java +++ b/src/main/java/org/dynmap/kzedmap/KzedZoomedMapTile.java @@ -1,22 +1,40 @@ package org.dynmap.kzedmap; +import org.dynmap.DynmapWorld; import org.bukkit.World; import org.dynmap.MapTile; public class KzedZoomedMapTile extends MapTile { + private String fname; + private String fname_day; + @Override 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 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 KzedZoomedMapTile(World world, KzedMap map, KzedMapTile original) { + public KzedZoomedMapTile(DynmapWorld world, KzedMap map, KzedMapTile original) { super(world, map); this.originalTile = original; } diff --git a/src/main/java/org/dynmap/kzedmap/ZoomedTileRenderer.java b/src/main/java/org/dynmap/kzedmap/ZoomedTileRenderer.java deleted file mode 100644 index 7e1d5d09..00000000 --- a/src/main/java/org/dynmap/kzedmap/ZoomedTileRenderer.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.dynmap.kzedmap; - -import java.io.File; -import java.util.Map; -import org.dynmap.MapChunkCache; -public class ZoomedTileRenderer { - public ZoomedTileRenderer(Map configuration) { - } - - public void render(MapChunkCache cache, final KzedZoomedMapTile zt, final File outputPath) { - return; /* Doing this in Default render, since image already loaded */ - } -} diff --git a/web/js/flatmap.js b/web/js/flatmap.js index 88a7429d..63d51d52 100644 --- a/web/js/flatmap.js +++ b/web/js/flatmap.js @@ -28,8 +28,12 @@ FlatMapType.prototype = $.extend(new DynMapType(), { var dnprefix = ''; if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].nightandday && this.dynmap.serverday) dnprefix = '_day'; - - tileName = this.prefix + dnprefix + '_128_' + coord.x + '_' + coord.y + '.png'; + + 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'; imgSize = Math.pow(2, 7+zoom); var tile = $('
') .addClass('tile') diff --git a/web/js/kzedmaps.js b/web/js/kzedmaps.js index 239efafa..6cda0d67 100644 --- a/web/js/kzedmaps.js +++ b/web/js/kzedmaps.js @@ -50,14 +50,28 @@ KzedMapType.prototype = $.extend(new DynMapType(), { if (zoom == 0) { // Most zoomed out tiles. tileSize = 128; - imgSize = tileSize; - tileName = 'z' + this.prefix + dnprefix + '_' + (-coord.x * tileSize*2) + '_' + (coord.y * tileSize*2) + '.png'; + 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'; + } } else { // Other zoom levels. tileSize = 128; imgSize = Math.pow(2, 6+zoom); - tileName = this.prefix + dnprefix + '_' + (-coord.x*tileSize) + '_' + (coord.y*tileSize) + '.png'; + 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'; + } } var img; var tile = $('
') From 2f22560f3d3aef933f9eab4282569882c40705e1 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Mon, 13 Jun 2011 22:05:14 -0500 Subject: [PATCH 3/4] Clean up warnings --- src/main/java/org/dynmap/ClientComponent.java | 2 ++ src/main/java/org/dynmap/ConfigurationNode.java | 5 +++++ src/main/java/org/dynmap/Events.java | 3 +++ src/main/java/org/dynmap/JSONUtils.java | 3 +++ .../java/org/dynmap/JsonFileClientUpdateComponent.java | 1 + src/main/java/org/dynmap/MapChunkCache.java | 2 ++ src/main/java/org/dynmap/flat/FlatMap.java | 4 ---- src/main/java/org/dynmap/herochat/HeroChatHandler.java | 4 +++- src/main/java/org/dynmap/kzedmap/KzedMap.java | 1 - src/main/java/org/dynmap/kzedmap/KzedMapTile.java | 2 -- .../java/org/dynmap/kzedmap/KzedZoomedMapTile.java | 1 - .../web/handlers/ClientConfigurationHandler.java | 2 -- .../org/dynmap/web/handlers/ClientUpdateHandler.java | 10 ---------- src/main/java/org/dynmap/web/handlers/FileHandler.java | 1 - 14 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/dynmap/ClientComponent.java b/src/main/java/org/dynmap/ClientComponent.java index 112bf5ea..8d006976 100644 --- a/src/main/java/org/dynmap/ClientComponent.java +++ b/src/main/java/org/dynmap/ClientComponent.java @@ -39,6 +39,7 @@ public class ClientComponent extends Component { return o; } + @SuppressWarnings("unchecked") protected static final JSONArray convertList(List l) { JSONArray o = new JSONArray(); for(Object entry : l) { @@ -47,6 +48,7 @@ public class ClientComponent extends Component { return o; } + @SuppressWarnings("unchecked") protected static final Object convert(Object o) { if (o instanceof Map) { return convertMap((Map)o); diff --git a/src/main/java/org/dynmap/ConfigurationNode.java b/src/main/java/org/dynmap/ConfigurationNode.java index eb50106c..8e4bb87e 100644 --- a/src/main/java/org/dynmap/ConfigurationNode.java +++ b/src/main/java/org/dynmap/ConfigurationNode.java @@ -29,6 +29,7 @@ public class ConfigurationNode implements Map { entries = map; } + @SuppressWarnings("unchecked") public Object getObject(String path) { if (path.isEmpty()) return entries; @@ -60,6 +61,7 @@ public class ConfigurationNode implements Map { return o; } + @SuppressWarnings("unchecked") public T getGeneric(String path, T def) { Object o = getObject(path, def); try { @@ -112,6 +114,7 @@ public class ConfigurationNode implements Map { return o.toString(); } + @SuppressWarnings("unchecked") public List getList(String path) { try { List list = (List)getObject(path, null); @@ -139,6 +142,7 @@ public class ConfigurationNode implements Map { return new ConfigurationNode(v); } + @SuppressWarnings("unchecked") public List getNodes(String path) { List o = getList(path); @@ -165,6 +169,7 @@ public class ConfigurationNode implements Map { extendMap(this, other); } + @SuppressWarnings("unchecked") private final static void extendMap(Map left, Map right) { ConfigurationNode original = new ConfigurationNode(left); for(Map.Entry entry : right.entrySet()) { diff --git a/src/main/java/org/dynmap/Events.java b/src/main/java/org/dynmap/Events.java index 81933180..3804fc56 100644 --- a/src/main/java/org/dynmap/Events.java +++ b/src/main/java/org/dynmap/Events.java @@ -5,6 +5,7 @@ import java.util.Map; public class Events { public Map> events = new HashMap>(); + @SuppressWarnings("unchecked") public void addListener(String eventName, Event.Listener listener) { Event genericEvent = events.get(eventName); Event event = null; @@ -16,6 +17,7 @@ public class Events { event.addListener(listener); } + @SuppressWarnings("unchecked") public void removeListener(String eventName, Event.Listener listener) { Event genericEvent = events.get(eventName); Event event = null; @@ -25,6 +27,7 @@ public class Events { } } + @SuppressWarnings("unchecked") public void trigger(String eventName, T argument) { Event genericEvent = events.get(eventName); if (genericEvent == null) diff --git a/src/main/java/org/dynmap/JSONUtils.java b/src/main/java/org/dynmap/JSONUtils.java index a685b112..333eadb9 100644 --- a/src/main/java/org/dynmap/JSONUtils.java +++ b/src/main/java/org/dynmap/JSONUtils.java @@ -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. + @SuppressWarnings("unchecked") public static void s(JSONObject o, String path, Object value) { int index = path.indexOf('/'); 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. + @SuppressWarnings("unchecked") public static void a(JSONObject o, String path, Object value) { Object oo = g(o, path); JSONArray array; @@ -58,6 +60,7 @@ public class JSONUtils { } // Simply creates a JSONArray. + @SuppressWarnings("unchecked") public static JSONArray l(Object... items) { JSONArray arr = new JSONArray(); for(Object item : items) { diff --git a/src/main/java/org/dynmap/JsonFileClientUpdateComponent.java b/src/main/java/org/dynmap/JsonFileClientUpdateComponent.java index 57723b26..737db67b 100644 --- a/src/main/java/org/dynmap/JsonFileClientUpdateComponent.java +++ b/src/main/java/org/dynmap/JsonFileClientUpdateComponent.java @@ -102,6 +102,7 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent { } } + @SuppressWarnings("unchecked") protected void writeUpdates() { File outputFile; File outputTempFile; diff --git a/src/main/java/org/dynmap/MapChunkCache.java b/src/main/java/org/dynmap/MapChunkCache.java index fa6b7cf4..e7483a59 100644 --- a/src/main/java/org/dynmap/MapChunkCache.java +++ b/src/main/java/org/dynmap/MapChunkCache.java @@ -165,6 +165,7 @@ public class MapChunkCache { if(!initialized) { try { + @SuppressWarnings("rawtypes") Class c = Class.forName("net.minecraft.server.Chunk"); getchunkdata = c.getDeclaredMethod("a", new Class[] { byte[].class, int.class, int.class, int.class, int.class, int.class, int.class, int.class }); @@ -177,6 +178,7 @@ public class MapChunkCache { } /* Get CraftWorld.popPreservedChunk(x,z) - reduces memory bloat from map traversals (optional) */ try { + @SuppressWarnings("rawtypes") Class c = Class.forName("org.bukkit.craftbukkit.CraftWorld"); poppreservedchunk = c.getDeclaredMethod("popPreservedChunk", new Class[] { int.class, int.class }); } catch (ClassNotFoundException cnfx) { diff --git a/src/main/java/org/dynmap/flat/FlatMap.java b/src/main/java/org/dynmap/flat/FlatMap.java index 1b83b810..afe026e3 100644 --- a/src/main/java/org/dynmap/flat/FlatMap.java +++ b/src/main/java/org/dynmap/flat/FlatMap.java @@ -3,10 +3,6 @@ package org.dynmap.flat; import org.dynmap.DynmapWorld; import static org.dynmap.JSONUtils.a; import static org.dynmap.JSONUtils.s; -import java.awt.image.DataBufferInt; -import java.awt.image.BufferedImage; -import java.awt.image.WritableRaster; -import java.awt.image.ColorModel; import java.io.File; import java.io.IOException; diff --git a/src/main/java/org/dynmap/herochat/HeroChatHandler.java b/src/main/java/org/dynmap/herochat/HeroChatHandler.java index 0b4d593f..c92ffef1 100644 --- a/src/main/java/org/dynmap/herochat/HeroChatHandler.java +++ b/src/main/java/org/dynmap/herochat/HeroChatHandler.java @@ -10,7 +10,6 @@ import org.bukkit.event.Event; import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.ServerListener; import org.bukkit.plugin.Plugin; -import java.lang.reflect.Field; import org.dynmap.Client; import org.dynmap.ConfigurationNode; import org.dynmap.DynmapPlugin; @@ -40,6 +39,7 @@ public class HeroChatHandler { /* Reflection-based access wrapper for ChannelChatEvent from HeroChat */ private static class HeroChatChannelChatEvent { + @SuppressWarnings("rawtypes") private static Class channelchatevent; private static Method getsource; private static Method getmessage; @@ -97,6 +97,7 @@ public class HeroChatHandler { /* Reflection-based access wrapper for ChannelEvent from HeroChat */ private static class HeroChatChannelEvent { + @SuppressWarnings("rawtypes") private static Class channelevent; private static Method getchannel; private static Method iscancelled; @@ -148,6 +149,7 @@ public class HeroChatHandler { /* Reflection-based access wrapper for Channel from HeroChat */ private static class HeroChatChannel { + @SuppressWarnings("rawtypes") private static Class channel; private static Method getname; private static Method getnick; diff --git a/src/main/java/org/dynmap/kzedmap/KzedMap.java b/src/main/java/org/dynmap/kzedmap/KzedMap.java index 078694ed..43037570 100644 --- a/src/main/java/org/dynmap/kzedmap/KzedMap.java +++ b/src/main/java/org/dynmap/kzedmap/KzedMap.java @@ -11,7 +11,6 @@ import java.util.List; import java.util.logging.Logger; import org.bukkit.Location; -import org.bukkit.World; import org.dynmap.ConfigurationNode; import org.dynmap.DynmapChunk; import org.dynmap.Log; diff --git a/src/main/java/org/dynmap/kzedmap/KzedMapTile.java b/src/main/java/org/dynmap/kzedmap/KzedMapTile.java index 3d958c35..5df90cdc 100644 --- a/src/main/java/org/dynmap/kzedmap/KzedMapTile.java +++ b/src/main/java/org/dynmap/kzedmap/KzedMapTile.java @@ -2,8 +2,6 @@ package org.dynmap.kzedmap; import org.dynmap.DynmapWorld; import java.io.File; - -import org.bukkit.World; import org.dynmap.MapTile; public class KzedMapTile extends MapTile { diff --git a/src/main/java/org/dynmap/kzedmap/KzedZoomedMapTile.java b/src/main/java/org/dynmap/kzedmap/KzedZoomedMapTile.java index 7516b992..b7fec488 100644 --- a/src/main/java/org/dynmap/kzedmap/KzedZoomedMapTile.java +++ b/src/main/java/org/dynmap/kzedmap/KzedZoomedMapTile.java @@ -1,7 +1,6 @@ package org.dynmap.kzedmap; import org.dynmap.DynmapWorld; -import org.bukkit.World; import org.dynmap.MapTile; public class KzedZoomedMapTile extends MapTile { diff --git a/src/main/java/org/dynmap/web/handlers/ClientConfigurationHandler.java b/src/main/java/org/dynmap/web/handlers/ClientConfigurationHandler.java index c65f20f3..9a899f07 100644 --- a/src/main/java/org/dynmap/web/handlers/ClientConfigurationHandler.java +++ b/src/main/java/org/dynmap/web/handlers/ClientConfigurationHandler.java @@ -2,8 +2,6 @@ package org.dynmap.web.handlers; import java.io.BufferedOutputStream; import java.util.Date; -import java.util.Map; - import org.dynmap.DynmapPlugin; import org.dynmap.DynmapWorld; import org.dynmap.Event; diff --git a/src/main/java/org/dynmap/web/handlers/ClientUpdateHandler.java b/src/main/java/org/dynmap/web/handlers/ClientUpdateHandler.java index df2ed713..90b3ed43 100644 --- a/src/main/java/org/dynmap/web/handlers/ClientUpdateHandler.java +++ b/src/main/java/org/dynmap/web/handlers/ClientUpdateHandler.java @@ -5,24 +5,14 @@ import java.util.Date; import java.util.regex.Matcher; 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.DynmapPlugin; import org.dynmap.DynmapWorld; -import org.dynmap.MapManager; -import org.dynmap.PlayerList; import org.dynmap.web.HttpField; import org.dynmap.web.HttpHandler; import org.dynmap.web.HttpRequest; import org.dynmap.web.HttpResponse; import org.dynmap.web.HttpStatus; -import org.dynmap.web.Json; -import org.json.simple.JSONArray; import org.json.simple.JSONObject; import static org.dynmap.JSONUtils.*; diff --git a/src/main/java/org/dynmap/web/handlers/FileHandler.java b/src/main/java/org/dynmap/web/handlers/FileHandler.java index 9ee75128..950b7df9 100644 --- a/src/main/java/org/dynmap/web/handlers/FileHandler.java +++ b/src/main/java/org/dynmap/web/handlers/FileHandler.java @@ -13,7 +13,6 @@ import org.dynmap.web.HttpHandler; import org.dynmap.web.HttpRequest; import org.dynmap.web.HttpResponse; import org.dynmap.web.HttpStatus; -import org.dynmap.utils.FileLockManager; public abstract class FileHandler implements HttpHandler { protected static final Logger log = Logger.getLogger("Minecraft"); From 9286cfff66c1aa11b90e9530a08ad1fe2b6f4c77 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Mon, 13 Jun 2011 23:19:02 -0500 Subject: [PATCH 4/4] Add blockburn, snowform, leavesdecay render events --- configuration.txt | 3 ++ src/main/java/org/dynmap/DynmapPlugin.java | 33 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/configuration.txt b/configuration.txt index 1cb80333..13ff9835 100644 --- a/configuration.txt +++ b/configuration.txt @@ -78,6 +78,9 @@ render-triggers: # - playerjoin - blockplaced - blockbreak + - snowform + - leavesdecay + - blockburn # The path where the tile-files are placed. tilespath: web/tiles diff --git a/src/main/java/org/dynmap/DynmapPlugin.java b/src/main/java/org/dynmap/DynmapPlugin.java index ff45f8da..d703c812 100644 --- a/src/main/java/org/dynmap/DynmapPlugin.java +++ b/src/main/java/org/dynmap/DynmapPlugin.java @@ -18,8 +18,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockListener; 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.PlayerListener; import org.bukkit.event.player.PlayerMoveEvent; @@ -180,11 +183,35 @@ public class DynmapPlugin extends JavaPlugin { BlockListener renderTrigger = new BlockListener() { @Override public void onBlockPlace(BlockPlaceEvent event) { + if(event.isCancelled()) + return; mm.touch(event.getBlockPlaced().getLocation()); } @Override 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()); } }; @@ -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); if (isTrigger("blockbreak")) 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() {