From 3ddce85f89911bfaf4f9d5f23881306ac391a02e Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sun, 24 Jul 2011 20:34:39 -0500 Subject: [PATCH] Make HDMap fall back to default perspective, shader or lighting as needed if unable to find configured preset. --- src/main/java/org/dynmap/MapManager.java | 32 +++++++++++++------- src/main/java/org/dynmap/hdmap/HDMap.java | 37 +++++++++++++++++------ src/main/resources/perspectives.txt | 13 ++++++++ src/main/resources/shaders.txt | 17 ++++++++--- 4 files changed, 75 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/dynmap/MapManager.java b/src/main/java/org/dynmap/MapManager.java index 65e4b1b6..1c5106e4 100644 --- a/src/main/java/org/dynmap/MapManager.java +++ b/src/main/java/org/dynmap/MapManager.java @@ -351,16 +351,27 @@ public class MapManager { private class CheckWorldTimes implements Runnable { public void run() { - for(DynmapWorld w : worlds) { - int new_servertime = (int)(w.world.getTime() % 24000); - /* Check if we went from night to day */ - boolean wasday = w.servertime >= 0 && w.servertime < 13700; - boolean isday = new_servertime >= 0 && new_servertime < 13700; - w.servertime = new_servertime; - if(wasday != isday) { - MapManager.mapman.pushUpdate(w.world, new Client.DayNight(isday)); + Future f = scheduler.callSyncMethod(plug_in, new Callable() { + public Integer call() throws Exception { + for(DynmapWorld w : worlds) { + int new_servertime = (int)(w.world.getTime() % 24000); + /* Check if we went from night to day */ + boolean wasday = w.servertime >= 0 && w.servertime < 13700; + boolean isday = new_servertime >= 0 && new_servertime < 13700; + w.servertime = new_servertime; + if(wasday != isday) { + MapManager.mapman.pushUpdate(w.world, new Client.DayNight(isday)); + } + } + return 0; } + }); + try { + f.get(); + } catch (Exception ix) { + Log.severe(ix); } + renderpool.schedule(this, 5, TimeUnit.SECONDS); } } @@ -409,9 +420,7 @@ public class MapManager { for (World world : plug_in.getServer().getWorlds()) { activateWorld(world); - } - - scheduler.scheduleSyncRepeatingTask(plugin, new CheckWorldTimes(), 5*20, 5*20); /* Check very 5 seconds */ + } } void renderFullWorld(Location l, CommandSender sender) { @@ -578,6 +587,7 @@ public class MapManager { tileQueue.start(); renderpool = new DynmapScheduledThreadPoolExecutor(); renderpool.schedule(new DoZoomOutProcessing(), 60000, TimeUnit.MILLISECONDS); + renderpool.schedule(new CheckWorldTimes(), 5, TimeUnit.SECONDS); } public void stopRendering() { diff --git a/src/main/java/org/dynmap/hdmap/HDMap.java b/src/main/java/org/dynmap/hdmap/HDMap.java index 0106388d..66d3ba63 100644 --- a/src/main/java/org/dynmap/hdmap/HDMap.java +++ b/src/main/java/org/dynmap/hdmap/HDMap.java @@ -36,23 +36,42 @@ public class HDMap extends MapType { String perspectiveid = configuration.getString("perspective", "default"); perspective = MapManager.mapman.hdmapman.perspectives.get(perspectiveid); if(perspective == null) { - Log.severe("HDMap '"+name+"' loading invalid perspective '" + perspectiveid + "' - map disabled"); - name = null; - return; + /* Try to use default */ + perspective = MapManager.mapman.hdmapman.perspectives.get("default"); + if(perspective == null) { + Log.severe("HDMap '"+name+"' loaded invalid perspective '" + perspectiveid + "' - map disabled"); + name = null; + return; + } + else { + Log.severe("HDMap '"+name+"' loaded invalid perspective '" + perspectiveid + "' - using 'default' perspective"); + } } String shaderid = configuration.getString("shader", "default"); shader = MapManager.mapman.hdmapman.shaders.get(shaderid); if(shader == null) { - Log.severe("HDMap '"+name+"' loading invalid shader '" + shaderid + "' - map disabled"); - name = null; - return; + shader = MapManager.mapman.hdmapman.shaders.get("default"); + if(shader == null) { + Log.severe("HDMap '"+name+"' loading invalid shader '" + shaderid + "' - map disabled"); + name = null; + return; + } + else { + Log.severe("HDMap '"+name+"' loading invalid shader '" + shaderid + "' - using 'default' shader"); + } } String lightingid = configuration.getString("lighting", "default"); lighting = MapManager.mapman.hdmapman.lightings.get(lightingid); if(lighting == null) { - Log.severe("HDMap '"+name+"' loading invalid lighting '" + lighting + "' - map disabled"); - name = null; - return; + lighting = MapManager.mapman.hdmapman.lightings.get("default"); + if(lighting == null) { + Log.severe("HDMap '"+name+"' loading invalid lighting '" + lighting + "' - map disabled"); + name = null; + return; + } + else { + Log.severe("HDMap '"+name+"' loading invalid lighting '" + lighting + "' - using 'default' lighting"); + } } prefix = configuration.getString("prefix", name); this.configuration = configuration; diff --git a/src/main/resources/perspectives.txt b/src/main/resources/perspectives.txt index 30961ee8..0bb3104f 100644 --- a/src/main/resources/perspectives.txt +++ b/src/main/resources/perspectives.txt @@ -4,6 +4,19 @@ version: 0.20 # during upgrades, so new or updated perspective definitions should be done in the custom-perspectives.txt file # perspectives: + # Default - used if bad or no perspective name supplied + - class: org.dynmap.hdmap.IsoHDPerspective + name: default + azimuth: 135 + inclination: 60 + scale: 4 + # iso_classic is very close to KzedMap view + - class: org.dynmap.hdmap.IsoHDPerspective + name: classic + azimuth: 135 + inclination: 60 + scale: 1.4 + # High angle (60 degree) views - class: org.dynmap.hdmap.IsoHDPerspective name: iso_S_60_lowres azimuth: 180 diff --git a/src/main/resources/shaders.txt b/src/main/resources/shaders.txt index 25e2a82a..e13fae30 100644 --- a/src/main/resources/shaders.txt +++ b/src/main/resources/shaders.txt @@ -3,10 +3,16 @@ # during upgrades, so new or updated shader definitions should be done in the custom-shaders.txt file # shaders: - - class: org.dynmap.hdmap.DefaultHDShader + # Default shader - used if shader not specified or invalid + - class: org.dynmap.hdmap.TexturePackHDShader name: default + texturepack: standard + + # Color scheme based shaders + - class: org.dynmap.hdmap.DefaultHDShader + name: defaultscheme colorscheme: default - + - class: org.dynmap.hdmap.DefaultHDShader name: ovocean colorscheme: ovocean @@ -19,6 +25,7 @@ shaders: name: sk89q colorscheme: sk89q + # Biome based shaders - class: org.dynmap.hdmap.DefaultHDShader name: biome biomecolored: biome @@ -31,21 +38,23 @@ shaders: name: rainfall biomecolored: rainfall + # No transparency default color scheme shader - class: org.dynmap.hdmap.DefaultHDShader name: no_transparency colorscheme: default transparency: false + # Cave view shader - class: org.dynmap.hdmap.CaveHDShader name: cave + # Texture pack based shader for standard Minecraft textures - class: org.dynmap.hdmap.TexturePackHDShader name: stdtexture texturepack: standard + # Texture pack based shader for standard Minecraft textures, without biome-tinted grass/leaves - class: org.dynmap.hdmap.TexturePackHDShader name: stdtexture-nobiome texturepack: standard biomeshaded: false - - \ No newline at end of file