Make HDMap fall back to default perspective, shader or lighting as needed if unable to find configured preset.

This commit is contained in:
Mike Primm 2011-07-24 20:34:39 -05:00
parent abd7c25d80
commit 3ddce85f89
4 changed files with 75 additions and 24 deletions

View File

@ -351,16 +351,27 @@ public class MapManager {
private class CheckWorldTimes implements Runnable { private class CheckWorldTimes implements Runnable {
public void run() { public void run() {
for(DynmapWorld w : worlds) { Future<Integer> f = scheduler.callSyncMethod(plug_in, new Callable<Integer>() {
int new_servertime = (int)(w.world.getTime() % 24000); public Integer call() throws Exception {
/* Check if we went from night to day */ for(DynmapWorld w : worlds) {
boolean wasday = w.servertime >= 0 && w.servertime < 13700; int new_servertime = (int)(w.world.getTime() % 24000);
boolean isday = new_servertime >= 0 && new_servertime < 13700; /* Check if we went from night to day */
w.servertime = new_servertime; boolean wasday = w.servertime >= 0 && w.servertime < 13700;
if(wasday != isday) { boolean isday = new_servertime >= 0 && new_servertime < 13700;
MapManager.mapman.pushUpdate(w.world, new Client.DayNight(isday)); 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()) { for (World world : plug_in.getServer().getWorlds()) {
activateWorld(world); activateWorld(world);
} }
scheduler.scheduleSyncRepeatingTask(plugin, new CheckWorldTimes(), 5*20, 5*20); /* Check very 5 seconds */
} }
void renderFullWorld(Location l, CommandSender sender) { void renderFullWorld(Location l, CommandSender sender) {
@ -578,6 +587,7 @@ public class MapManager {
tileQueue.start(); tileQueue.start();
renderpool = new DynmapScheduledThreadPoolExecutor(); renderpool = new DynmapScheduledThreadPoolExecutor();
renderpool.schedule(new DoZoomOutProcessing(), 60000, TimeUnit.MILLISECONDS); renderpool.schedule(new DoZoomOutProcessing(), 60000, TimeUnit.MILLISECONDS);
renderpool.schedule(new CheckWorldTimes(), 5, TimeUnit.SECONDS);
} }
public void stopRendering() { public void stopRendering() {

View File

@ -36,23 +36,42 @@ public class HDMap extends MapType {
String perspectiveid = configuration.getString("perspective", "default"); String perspectiveid = configuration.getString("perspective", "default");
perspective = MapManager.mapman.hdmapman.perspectives.get(perspectiveid); perspective = MapManager.mapman.hdmapman.perspectives.get(perspectiveid);
if(perspective == null) { if(perspective == null) {
Log.severe("HDMap '"+name+"' loading invalid perspective '" + perspectiveid + "' - map disabled"); /* Try to use default */
name = null; perspective = MapManager.mapman.hdmapman.perspectives.get("default");
return; 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"); String shaderid = configuration.getString("shader", "default");
shader = MapManager.mapman.hdmapman.shaders.get(shaderid); shader = MapManager.mapman.hdmapman.shaders.get(shaderid);
if(shader == null) { if(shader == null) {
Log.severe("HDMap '"+name+"' loading invalid shader '" + shaderid + "' - map disabled"); shader = MapManager.mapman.hdmapman.shaders.get("default");
name = null; if(shader == null) {
return; 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"); String lightingid = configuration.getString("lighting", "default");
lighting = MapManager.mapman.hdmapman.lightings.get(lightingid); lighting = MapManager.mapman.hdmapman.lightings.get(lightingid);
if(lighting == null) { if(lighting == null) {
Log.severe("HDMap '"+name+"' loading invalid lighting '" + lighting + "' - map disabled"); lighting = MapManager.mapman.hdmapman.lightings.get("default");
name = null; if(lighting == null) {
return; 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); prefix = configuration.getString("prefix", name);
this.configuration = configuration; this.configuration = configuration;

View File

@ -4,6 +4,19 @@ version: 0.20
# during upgrades, so new or updated perspective definitions should be done in the custom-perspectives.txt file # during upgrades, so new or updated perspective definitions should be done in the custom-perspectives.txt file
# #
perspectives: 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 - class: org.dynmap.hdmap.IsoHDPerspective
name: iso_S_60_lowres name: iso_S_60_lowres
azimuth: 180 azimuth: 180

View File

@ -3,10 +3,16 @@
# during upgrades, so new or updated shader definitions should be done in the custom-shaders.txt file # during upgrades, so new or updated shader definitions should be done in the custom-shaders.txt file
# #
shaders: shaders:
- class: org.dynmap.hdmap.DefaultHDShader # Default shader - used if shader not specified or invalid
- class: org.dynmap.hdmap.TexturePackHDShader
name: default name: default
texturepack: standard
# Color scheme based shaders
- class: org.dynmap.hdmap.DefaultHDShader
name: defaultscheme
colorscheme: default colorscheme: default
- class: org.dynmap.hdmap.DefaultHDShader - class: org.dynmap.hdmap.DefaultHDShader
name: ovocean name: ovocean
colorscheme: ovocean colorscheme: ovocean
@ -19,6 +25,7 @@ shaders:
name: sk89q name: sk89q
colorscheme: sk89q colorscheme: sk89q
# Biome based shaders
- class: org.dynmap.hdmap.DefaultHDShader - class: org.dynmap.hdmap.DefaultHDShader
name: biome name: biome
biomecolored: biome biomecolored: biome
@ -31,21 +38,23 @@ shaders:
name: rainfall name: rainfall
biomecolored: rainfall biomecolored: rainfall
# No transparency default color scheme shader
- class: org.dynmap.hdmap.DefaultHDShader - class: org.dynmap.hdmap.DefaultHDShader
name: no_transparency name: no_transparency
colorscheme: default colorscheme: default
transparency: false transparency: false
# Cave view shader
- class: org.dynmap.hdmap.CaveHDShader - class: org.dynmap.hdmap.CaveHDShader
name: cave name: cave
# Texture pack based shader for standard Minecraft textures
- class: org.dynmap.hdmap.TexturePackHDShader - class: org.dynmap.hdmap.TexturePackHDShader
name: stdtexture name: stdtexture
texturepack: standard texturepack: standard
# Texture pack based shader for standard Minecraft textures, without biome-tinted grass/leaves
- class: org.dynmap.hdmap.TexturePackHDShader - class: org.dynmap.hdmap.TexturePackHDShader
name: stdtexture-nobiome name: stdtexture-nobiome
texturepack: standard texturepack: standard
biomeshaded: false biomeshaded: false