diff --git a/configuration.txt.sample-hd b/configuration.txt.sample-hd index 66ddf6c3..2dede449 100644 --- a/configuration.txt.sample-hd +++ b/configuration.txt.sample-hd @@ -154,7 +154,7 @@ templates: title: "Flat" prefix: flat perspective: iso_S_90_lowres - shader: default + shader: stdtexture lighting: default # # To render a world as a "night view", switch to lighting: night # lighting: night @@ -171,7 +171,7 @@ templates: title: "Surface" prefix: t perspective: iso_SE_60_lowres - shader: default + shader: stdtexture lighting: default # # Add shadows to world (based on top-down shadows from chunk data) # lighting: shadows @@ -221,7 +221,7 @@ templates: title: "Flat" prefix: flat perspective: iso_S_90_lowres - shader: default + shader: stdtexture lighting: default # Map background color (day or night) background: "#300806" @@ -230,7 +230,7 @@ templates: title: "Surface" prefix: nt perspective: iso_SE_60_lowres - shader: default + shader: stdtexture lighting: default # Map background color (day or night) background: "#300806" @@ -251,7 +251,7 @@ templates: title: "Flat" prefix: flat perspective: iso_S_90_lowres - shader: default + shader: stdtexture lighting: default # Background color for map during the day backgroundday: "#153E7E" @@ -262,7 +262,7 @@ templates: title: "Surface" prefix: st perspective: iso_SE_60_lowres - shader: default + shader: stdtexture lighting: nightandday # Background color for map during the day backgroundday: "#153E7E" diff --git a/src/main/java/org/dynmap/DynmapPlugin.java b/src/main/java/org/dynmap/DynmapPlugin.java index c61f8ff5..c2597b0c 100644 --- a/src/main/java/org/dynmap/DynmapPlugin.java +++ b/src/main/java/org/dynmap/DynmapPlugin.java @@ -48,9 +48,6 @@ public class DynmapPlugin extends JavaPlugin { public MapManager mapManager = null; public PlayerList playerList; public ConfigurationNode configuration; - public ConfigurationNode shaderconfig; - public ConfigurationNode perspectiveconfig; - public ConfigurationNode lightingsconfig; public HashSet enabledTriggers = new HashSet(); public PermissionProvider permissions; public ComponentManager componentManager = new ComponentManager(); @@ -58,7 +55,7 @@ public class DynmapPlugin extends JavaPlugin { /* Flag to let code know that we're doing reload - make sure we don't double-register event handlers */ public boolean is_reload = false; private boolean generate_only = false; - private static boolean ignore_chunk_loads = false; /* Flat to keep us from processing our own chunk loads */ + private static boolean ignore_chunk_loads = false; /* Flag keep us from processing our own chunk loads */ public static File dataDirectory; public static File tilesDirectory; @@ -86,17 +83,7 @@ public class DynmapPlugin extends JavaPlugin { org.bukkit.util.config.Configuration bukkitConfiguration = new org.bukkit.util.config.Configuration(new File(this.getDataFolder(), "configuration.txt")); bukkitConfiguration.load(); configuration = new ConfigurationNode(bukkitConfiguration); - /* Load shaders and perspectives */ - org.bukkit.util.config.Configuration bukkitShaderConfig = new org.bukkit.util.config.Configuration(new File(this.getDataFolder(), "shaders.txt")); - bukkitShaderConfig.load(); - shaderconfig = new ConfigurationNode(bukkitShaderConfig); - org.bukkit.util.config.Configuration bukkitPerspectiveConfig = new org.bukkit.util.config.Configuration(new File(this.getDataFolder(), "perspectives.txt")); - bukkitPerspectiveConfig.load(); - perspectiveconfig = new ConfigurationNode(bukkitPerspectiveConfig); - org.bukkit.util.config.Configuration bukkitLightingsConfig = new org.bukkit.util.config.Configuration(new File(this.getDataFolder(), "lightings.txt")); - bukkitLightingsConfig.load(); - lightingsconfig = new ConfigurationNode(bukkitLightingsConfig); - + Log.verbose = configuration.getBoolean("verbose", true); loadDebuggers(); @@ -109,7 +96,7 @@ public class DynmapPlugin extends JavaPlugin { playerList = new PlayerList(getServer(), getFile("hiddenplayers.txt"), configuration); playerList.load(); - mapManager = new MapManager(this, configuration, shaderconfig, perspectiveconfig, lightingsconfig); + mapManager = new MapManager(this, configuration); mapManager.startRendering(); loadWebserver(); diff --git a/src/main/java/org/dynmap/MapManager.java b/src/main/java/org/dynmap/MapManager.java index 8f7c6f8d..2d2e8b65 100644 --- a/src/main/java/org/dynmap/MapManager.java +++ b/src/main/java/org/dynmap/MapManager.java @@ -335,15 +335,14 @@ public class MapManager { } } - public MapManager(DynmapPlugin plugin, ConfigurationNode configuration, ConfigurationNode shadercfg, ConfigurationNode perspectivecfg, - ConfigurationNode lightingscfg) { + public MapManager(DynmapPlugin plugin, ConfigurationNode configuration) { plug_in = plugin; mapman = this; /* Initialize HD map manager */ hdmapman = new HDMapManager(); - hdmapman.loadHDShaders(shadercfg); - hdmapman.loadHDPerspectives(perspectivecfg); - hdmapman.loadHDLightings(lightingscfg); + hdmapman.loadHDShaders(plugin); + hdmapman.loadHDPerspectives(plugin); + hdmapman.loadHDLightings(plugin); sscache = new SnapshotCache(configuration.getInteger("snapshotcachesize", 500)); this.tileQueue = new AsynchronousQueue(new Handler() { diff --git a/src/main/java/org/dynmap/hdmap/HDMapManager.java b/src/main/java/org/dynmap/hdmap/HDMapManager.java index 654a6317..92cda092 100644 --- a/src/main/java/org/dynmap/hdmap/HDMapManager.java +++ b/src/main/java/org/dynmap/hdmap/HDMapManager.java @@ -10,6 +10,7 @@ import java.util.HashSet; import java.util.List; import org.bukkit.World; +import org.bukkit.plugin.Plugin; import org.dynmap.ConfigurationNode; import org.dynmap.DynmapChunk; import org.dynmap.DynmapWorld; @@ -27,45 +28,105 @@ public class HDMapManager { public HashSet maps = new HashSet(); public HashMap> maps_by_world_perspective = new HashMap>(); - public void loadHDShaders(ConfigurationNode shadercfg) { + public void loadHDShaders(Plugin plugin) { Log.verboseinfo("Loading shaders..."); + + org.bukkit.util.config.Configuration bukkitShaderConfig = new org.bukkit.util.config.Configuration(new File(plugin.getDataFolder(), "shaders.txt")); + bukkitShaderConfig.load(); + ConfigurationNode shadercfg = new ConfigurationNode(bukkitShaderConfig); + for(HDShader shader : shadercfg.createInstances("shaders", new Class[0], new Object[0])) { if(shader.getName() == null) continue; - if(shaders.containsKey(shader.getName())) { - Log.severe("Duplicate shader name '" + shader.getName() + "' - shader ignored"); - } - else { + shaders.put(shader.getName(), shader); + } + /* Load custom shaders, if file is defined - or create empty one if not */ + File f = new File(plugin.getDataFolder(), "custom-shaders.txt"); + if(f.exists()) { + bukkitShaderConfig = new org.bukkit.util.config.Configuration(f); + bukkitShaderConfig.load(); + ConfigurationNode customshadercfg = new ConfigurationNode(bukkitShaderConfig); + for(HDShader shader : customshadercfg.createInstances("shaders", new Class[0], new Object[0])) { + if(shader.getName() == null) continue; shaders.put(shader.getName(), shader); } } + else { + try { + FileWriter fw = new FileWriter(f); + fw.write("# The user is free to add new and custom shaders here, including replacements for standard ones\n"); + fw.write("# Dynmap's install will not overwrite it\n"); + fw.write("shaders:\n"); + fw.close(); + } catch (IOException iox) { + } + } Log.info("Loaded " + shaders.size() + " shaders."); } - public void loadHDPerspectives(ConfigurationNode perspectivecfg) { + public void loadHDPerspectives(Plugin plugin) { Log.verboseinfo("Loading perspectives..."); + org.bukkit.util.config.Configuration bukkitPerspectiveConfig = new org.bukkit.util.config.Configuration(new File(plugin.getDataFolder(), "perspectives.txt")); + bukkitPerspectiveConfig.load(); + ConfigurationNode perspectivecfg = new ConfigurationNode(bukkitPerspectiveConfig); for(HDPerspective perspective : perspectivecfg.createInstances("perspectives", new Class[0], new Object[0])) { if(perspective.getName() == null) continue; - if(perspectives.containsKey(perspective.getName())) { - Log.severe("Duplicate perspective name '" + perspective.getName() + "' - perspective ignored"); - } - else { + perspectives.put(perspective.getName(), perspective); + } + /* Load custom perspectives, if file is defined - or create empty one if not */ + File f = new File(plugin.getDataFolder(), "custom-perspectives.txt"); + if(f.exists()) { + bukkitPerspectiveConfig = new org.bukkit.util.config.Configuration(f); + bukkitPerspectiveConfig.load(); + perspectivecfg = new ConfigurationNode(bukkitPerspectiveConfig); + for(HDPerspective perspective : perspectivecfg.createInstances("perspectives", new Class[0], new Object[0])) { + if(perspective.getName() == null) continue; perspectives.put(perspective.getName(), perspective); } } + else { + try { + FileWriter fw = new FileWriter(f); + fw.write("# The user is free to add new and custom perspectives here, including replacements for standard ones\n"); + fw.write("# Dynmap's install will not overwrite it\n"); + fw.write("perspectives:\n"); + fw.close(); + } catch (IOException iox) { + } + } Log.info("Loaded " + perspectives.size() + " perspectives."); } - public void loadHDLightings(ConfigurationNode lightingcfg) { + public void loadHDLightings(Plugin plugin) { Log.verboseinfo("Loading lightings..."); + org.bukkit.util.config.Configuration bukkitLightingsConfig = new org.bukkit.util.config.Configuration(new File(plugin.getDataFolder(), "lightings.txt")); + bukkitLightingsConfig.load(); + ConfigurationNode lightingcfg = new ConfigurationNode(bukkitLightingsConfig); + for(HDLighting lighting : lightingcfg.createInstances("lightings", new Class[0], new Object[0])) { if(lighting.getName() == null) continue; - if(lightings.containsKey(lighting.getName())) { - Log.severe("Duplicate lighting name '" + lighting.getName() + "' - lighting ignored"); - } - else { + lightings.put(lighting.getName(), lighting); + } + /* Load custom lightings, if file is defined - or create empty one if not */ + File f = new File(plugin.getDataFolder(), "custom-lightings.txt"); + if(f.exists()) { + bukkitLightingsConfig = new org.bukkit.util.config.Configuration(f); + bukkitLightingsConfig.load(); + lightingcfg = new ConfigurationNode(bukkitLightingsConfig); + for(HDLighting lighting : lightingcfg.createInstances("lightings", new Class[0], new Object[0])) { + if(lighting.getName() == null) continue; lightings.put(lighting.getName(), lighting); } } + else { + try { + FileWriter fw = new FileWriter(f); + fw.write("# The user is free to add new and custom lightings here, including replacements for standard ones\n"); + fw.write("# Dynmap's install will not overwrite it\n"); + fw.write("lightings:\n"); + fw.close(); + } catch (IOException iox) { + } + } Log.info("Loaded " + lightings.size() + " lightings."); }