From bf4f8a84f071c5e37092988f3ff9e5e16ab0644b Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Wed, 20 Jul 2011 21:52:43 -0500 Subject: [PATCH 1/2] Add support for custom-perspectives.txt, custom-shaders.txt, custom-lightings.txt --- configuration.txt.sample-hd | 12 +-- src/main/java/org/dynmap/DynmapPlugin.java | 19 +--- src/main/java/org/dynmap/MapManager.java | 9 +- .../java/org/dynmap/hdmap/HDMapManager.java | 91 ++++++++++++++++--- 4 files changed, 89 insertions(+), 42 deletions(-) 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."); } From b9882955af76857e7e150f39d1d5c2b5df5871de Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Wed, 20 Jul 2011 23:55:05 -0500 Subject: [PATCH 2/2] start move to break up configuration.txt, stop stomping user configurations on upgrade --- configuration.default | 149 +++++++ configuration.txt | 430 --------------------- configuration.txt.sample-hd | 414 -------------------- lightings.txt | 4 + perspectives.txt | 4 + shaders.txt | 4 + src/main/assembly/package.xml | 7 +- src/main/java/org/dynmap/DynmapPlugin.java | 135 ++++++- templates.txt | 290 ++++++++++++++ worlds.txt.sample | 140 +++++++ 10 files changed, 729 insertions(+), 848 deletions(-) create mode 100644 configuration.default delete mode 100644 configuration.txt delete mode 100644 configuration.txt.sample-hd create mode 100644 templates.txt create mode 100644 worlds.txt.sample diff --git a/configuration.default b/configuration.default new file mode 100644 index 00000000..b55c6b1f --- /dev/null +++ b/configuration.default @@ -0,0 +1,149 @@ +# All paths in this configuration file are relative to Dynmap's data-folder: minecraft_server/plugins/dynmap/ +# NOTE: the 'templates' section is now found in the templates.txt (and can be safely customized using custom-templates.txt) +# NOTE: the 'worlds' section is now found in the worlds.txt (example custom settings can be found in worlds.txt.sample) + +# To use the HDMap map templates as world defaults (normal-HDMap, nether-HDMap and skylands-HDMap), uncomment the following line +# Otherwise, the world defaults will be based on classic templates (normal, nether, skylands) +# Other values will search for templates named normal-, nether-, skylands- +#deftemplatesuffix: HDMap + +components: + - class: org.dynmap.ClientConfigurationComponent + + - class: org.dynmap.InternalClientUpdateComponent + sendhealth: true + sendposition: true + allowwebchat: true + webchat-interval: 5 + hidewebchatip: false + trustclientname: false + #- class: org.dynmap.JsonFileClientUpdateComponent + # writeinterval: 1 + # sendhealth: true + # sendposition: true + # allowwebchat: false + # webchat-interval: 5 + # hidewebchatip: false + + - class: org.dynmap.SimpleWebChatComponent + allowchat: true + #- class: org.dynmap.herochat.HeroWebChatComponent + # # Control which HeroChat channel messages from web are directed to + # herochatwebchannel: Global + # # Control which channels are monitored and reported to the web + # herochatchannels: + # - Global + # #- Trade + # #- Haggle + + - class: org.dynmap.ClientComponent + type: chat + - class: org.dynmap.ClientComponent + type: chatballoon + focuschatballoons: false + - class: org.dynmap.ClientComponent + type: chatbox + showplayerfaces: true + messagettl: 5 + - class: org.dynmap.ClientComponent + type: playermarkers + showplayerfaces: true + showplayerhealth: true + #- class: org.dynmap.ClientComponent + # type: digitalclock + - class: org.dynmap.ClientComponent + type: timeofdayclock + showdigitalclock: true + #showweather: true + #- class: org.dynmap.regions.RegionsComponent + # type: regions + # name: WorldGuard + # useworldpath: true + # filename: regions.yml + # basenode: regions + # use3dregions: true + # infowindow: '
%regionname% - %priority% (%parent%)
Owners %playerowners% %groupowners%
Members %playermembers% %groupmembers%
Flags
%flags%
' + # regionstyle: + # strokeColor: "#FF0000" + # strokeOpacity: 0.8 + # strokeWeight: 3 + # fillColor: "#FF0000" + # fillOpacity: 0.35 + # # Optional setting to limit which regions to show, by name - if commented out, all regions are shown + # visibleregions: + # - homebase + # - miningsite + #- class: org.dynmap.TestComponent + # stuff: "This is some configuration-value" + +# Treat hiddenplayers.txt as a whitelist for players to be shown on the map? (Default false) +display-whitelist: false + +# How often a tile gets rendered (in seconds). +renderinterval: 1 + +# Zoom-out tile update period - how often to scan for and process tile updates into zoom-out tiles (in seconds) +zoomoutperiod: 60 + +# Tile hashing is used to minimize tile file updates when no changes have occurred - set to false to disable +enabletilehash: true + +render-triggers: + #- chunkloaded + #- playermove + #- playerjoin + - blockplaced + - blockbreak + - snowform + - leavesdecay + - blockburn + - chunkgenerated + +# The path where the tile-files are placed. +tilespath: web/tiles + +# The path where the web-files are located. +webpath: web + +# The network-interface the webserver will bind to (0.0.0.0 for all interfaces, 127.0.0.1 for only local access). +webserver-bindaddress: 0.0.0.0 + +# The TCP-port the webserver will listen on. +webserver-port: 8123 + +# Disables Webserver portion of Dynmap (Advanced users only) +disable-webserver: false + +# Enable/disable having the web server allow symbolic links (true=compatible with existing code, false=more secure (default)) +allow-symlinks: true + +# Period between tile renders for fullrender, in seconds (non-zero to pace fullrenders, lessen CPU load) +timesliceinterval: 0.0 + +# Maximum chunk loads per server tick (1/20th of a second) - reducing this below 90 will impact render performance, but also will reduce server thread load +maxchunkspertick: 200 + +# Interval the browser should poll for updates. +updaterate: 2000 + +showplayerfacesinmenu: true + +# Set sidebaropened: true to pin menu sidebar opened +#sidebaropened: true + +joinmessage: "%playername% joined" +quitmessage: "%playername% quit" +spammessage: "You may only chat once every %interval% seconds." +webprefix: "§2[WEB] " +websuffix: "§f" + +defaultzoom: 0 +defaultworld: world + +# Set to true to enable verbose startup messages - can help with debugging map configuration problems +# Set to false for a much quieter startup log +verbose: true + +# Enables debugging. +#debuggers: +# - class: org.dynmap.debug.LogDebugger diff --git a/configuration.txt b/configuration.txt deleted file mode 100644 index ec727650..00000000 --- a/configuration.txt +++ /dev/null @@ -1,430 +0,0 @@ -# All paths in this configuration file are relative to Dynmap's data-folder: minecraft_server/plugins/dynmap/ - -components: - - class: org.dynmap.ClientConfigurationComponent - - - class: org.dynmap.InternalClientUpdateComponent - sendhealth: true - sendposition: true - allowwebchat: true - webchat-interval: 5 - hidewebchatip: false - trustclientname: false - #- class: org.dynmap.JsonFileClientUpdateComponent - # writeinterval: 1 - # sendhealth: true - # sendposition: true - # allowwebchat: false - # webchat-interval: 5 - # hidewebchatip: false - - - class: org.dynmap.SimpleWebChatComponent - allowchat: true - #- class: org.dynmap.herochat.HeroWebChatComponent - # # Control which HeroChat channel messages from web are directed to - # herochatwebchannel: Global - # # Control which channels are monitored and reported to the web - # herochatchannels: - # - Global - # #- Trade - # #- Haggle - - - class: org.dynmap.ClientComponent - type: chat - - class: org.dynmap.ClientComponent - type: chatballoon - focuschatballoons: false - - class: org.dynmap.ClientComponent - type: chatbox - showplayerfaces: true - messagettl: 5 - - class: org.dynmap.ClientComponent - type: playermarkers - showplayerfaces: true - showplayerhealth: true - #- class: org.dynmap.ClientComponent - # type: digitalclock - - class: org.dynmap.ClientComponent - type: timeofdayclock - showdigitalclock: true - #showweather: true - #- class: org.dynmap.regions.RegionsComponent - # type: regions - # name: WorldGuard - # useworldpath: true - # filename: regions.yml - # basenode: regions - # use3dregions: true - # infowindow: '
%regionname% - %priority% (%parent%)
Owners %playerowners% %groupowners%
Members %playermembers% %groupmembers%
Flags
%flags%
' - # regionstyle: - # strokeColor: "#FF0000" - # strokeOpacity: 0.8 - # strokeWeight: 3 - # fillColor: "#FF0000" - # fillOpacity: 0.35 - # # Optional setting to limit which regions to show, by name - if commented out, all regions are shown - # visibleregions: - # - homebase - # - miningsite - #- class: org.dynmap.TestComponent - # stuff: "This is some configuration-value" - -# Treat hiddenplayers.txt as a whitelist for players to be shown on the map? (Default false) -display-whitelist: false - -# How often a tile gets rendered (in seconds). -renderinterval: 1 - -# Zoom-out tile update period - how often to scan for and process tile updates into zoom-out tiles (in seconds) -zoomoutperiod: 60 - -# Tile hashing is used to minimize tile file updates when no changes have occurred - set to false to disable -enabletilehash: true - -render-triggers: - #- chunkloaded - #- playermove - #- playerjoin - - blockplaced - - blockbreak - - snowform - - leavesdecay - - blockburn - - chunkgenerated - -# The path where the tile-files are placed. -tilespath: web/tiles - -# The path where the web-files are located. -webpath: web - -# The network-interface the webserver will bind to (0.0.0.0 for all interfaces, 127.0.0.1 for only local access). -webserver-bindaddress: 0.0.0.0 - -# The TCP-port the webserver will listen on. -webserver-port: 8123 - -# Disables Webserver portion of Dynmap (Advanced users only) -disable-webserver: false - -# Enable/disable having the web server allow symbolic links (true=compatible with existing code, false=more secure (default)) -allow-symlinks: true - -# Period between tile renders for fullrender, in seconds (non-zero to pace fullrenders, lessen CPU load) -timesliceinterval: 0.0 - -# Maximum chunk loads per server tick (1/20th of a second) - reducing this below 90 will impact render performance, but also will reduce server thread load -maxchunkspertick: 200 - -# Interval the browser should poll for updates. -updaterate: 2000 - -showplayerfacesinmenu: true - -# Set sidebaropened: true to pin menu sidebar opened -#sidebaropened: true - -joinmessage: "%playername% joined" -quitmessage: "%playername% quit" -spammessage: "You may only chat once every %interval% seconds." -webprefix: "§2[WEB] " -websuffix: "§f" - -defaultzoom: 0 -defaultworld: world - -# template world - this is used for worlds that exist but aren't defined in the worlds section. -# Also, it supplies the "maps" section for worlds lacking a maps section, and the "center" -# for worlds lacking a "center" section. -templates: - # Template for normal world - normal: - enabled: true - # # If bigworld set to true, use alternate directory layout better suited to large worlds - # bigworld: true - # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) - # extrazoomout: 3 - center: - x: 0 - y: 64 - z: 0 - maps: - - class: org.dynmap.flat.FlatMap - name: flat - title: "Flat" - prefix: flat - colorscheme: default - # The textured setting makes the flat render toning much more consistent with the other maps: set to 'none' for the original flat texture, 'smooth' for blended tile top colors, 'dither' for dither pattern - textured: smooth - # # To render a world as a "night view", set shadowstrength and ambientlight - # shadowstrength: 1.0 - # ambientlight: 4 - # # To render both night and day versions of tiles (when ambientlight is set), set true - # night-and-day: true - # # Option to turn on transparency support (off by default) - slows render - # transparency: true - # # Background color for map during the day - # backgroundday: "#153E7E" - # # Background color for map during the night - # backgroundnight: "#000000" - # # Background color for map (independent of night/day) - # background: "#000000" - - class: org.dynmap.kzedmap.KzedMap - renderers: - - class: org.dynmap.kzedmap.DefaultTileRenderer - name: surface - title: "Surface" - prefix: t - maximumheight: 127 - colorscheme: default - # # Add shadows to world (based on top-down shadows from chunk data) - # shadowstrength: 1.0 - # # To render a world as a "night view", set shadowstrength and ambientlight - # ambientlight: 4 - # # To render both night and day versions of tiles (when ambientlight is set), set true - # night-and-day: true - # # Option to turn off transparency support (on by default) - speeds render - # transparency: false - # # Background color for map during the day - # backgroundday: "#153E7E" - # # Background color for map during the night - # backgroundnight: "#000000" - # # Background color for map (independent of night/day) - # background: "#000000" - # # Sets the icon to 'images/block_custom.png' - # icon: custom - # # Biome-based mapping - # - class: org.dynmap.kzedmap.DefaultTileRenderer - # name: biome - # title: "Biome" - # prefix: b - # maximumheight: 127 - # colorscheme: default - # # Biome-based coloring : biome=biome type, temperature=biome-temperature, rainfall=biome-rainfall - # biomecolored: biome - # - class: org.dynmap.kzedmap.HighlightTileRenderer - # prefix: ht - # maximumheight: 127 - # colorscheme: default - # highlight: # For highlighting multiple block-types. - # - 56 # Highlight diamond-ore - # - 66 # Highlight minecart track - # highlight: 56 # For highlighting a single block-type. - - class: org.dynmap.kzedmap.CaveTileRenderer - name: cave - title: "Cave" - prefix: ct - maximumheight: 127 - # Nether world template - nether: - enabled: true - # # If bigworld set to true, use alternate directory layout better suited to large worlds - # bigworld: true - # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) - # extrazoomout: 3 - center: - x: 0 - y: 64 - z: 0 - maps: - - class: org.dynmap.flat.FlatMap - name: flat - title: "Flat" - prefix: flat - colorscheme: default - # Map background color (day or night) - background: "#300806" - # The textured setting makes the flat render toning much more consistent with the other maps: set to 'none' for the original flat texture, 'smooth' for blended tile top colors, 'dither' for dither pattern - textured: smooth - - class: org.dynmap.kzedmap.KzedMap - renderers: - - class: org.dynmap.kzedmap.DefaultTileRenderer - name: nether - title: "Surface" - prefix: nt - maximumheight: 127 - colorscheme: default - # Map background color (day or night) - background: "#300806" - # Skylands world template - skylands: - enabled: true - # # If bigworld set to true, use alternate directory layout better suited to large worlds - # bigworld: true - # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) - # extrazoomout: 3 - center: - x: 0 - y: 64 - z: 0 - maps: - - class: org.dynmap.flat.FlatMap - name: flat - title: "Flat" - prefix: flat - colorscheme: default - # Background color for map during the day - backgroundday: "#153E7E" - # Background color for map during the night - backgroundnight: "#000000" - # The textured setting makes the flat render toning much more consistent with the other maps: set to 'none' for the original flat texture, 'smooth' for blended tile top colors, 'dither' for dither pattern - textured: smooth - - class: org.dynmap.kzedmap.KzedMap - renderers: - - class: org.dynmap.kzedmap.DefaultTileRenderer - name: skylands - title: "Surface" - prefix: st - maximumheight: 127 - colorscheme: default - # Background color for map during the day - backgroundday: "#153E7E" - # Background color for map during the night - backgroundnight: "#000000" - night-and-day: true - shadowstrength: 1.0 - ambientlight: 4 - -# The maptypes Dynmap will use to render. -worlds: - # Worlds can be handled by templates, based on world type - # You can override the properties of the template by specifying them in this section - # for example 'Title: "My Awesome World"' - #- name: world - # title: "World" - # Use 'enabled: false' to disable a certain world. - # enabled: false - # Use sendposition: false to prevent player positions from showing when on this world (if sendposition is globally enabled) - # sendposition: false - # Use sendhealth: false ot prevent player health from showing when on this world (if sendhealth is globally enabled) - # sendhealth: false - # # If world isn't contiguous chunks (due to teleporting, for example), fullrender needs to be given other locations to scan for tiles on each patch of chunks - # fullrenderlocations: - # - x: 10000 - # y: 64 - # z: 20000 - # - x: -15000 - # y: 64 - # z: -5000 - # # Use visibilitylimits to restrict which areas of maps on your world to render (zero or more rectangles can be defined) - # visibilitylimits: - # - x0: -1000 - # z0: -1000 - # x1: 1000 - # z1: 1000 - # - x0: -2000 - # z0: -1000 - # x1: -1000 - # z1: -500 - # # Use hidestyle to control how hidden-but-existing chunks are to be rendered (air=empty air (same as ungenerated), stone=a flat stone plain, ocean=a flat ocean) - # hidestyle: stone - # # Use 'autogenerate-to-visibilitylimits: true' to choose to force the generation of ungenerated chunks while rendering maps on this world, for any chunks within the defined - # # visibilitylimits (limits must be set). The three options here are: none (default - no autogenerate), map-only (temporarily generate chunks for map, but don't save them (no world change), - # # permanent (generate and save chunks - this permanently adds the chunks to the world, as if a player had visited them - BE SURE THIS IS WHAT YOU WANT) - # autogenerate-to-visibilitylimits: map-only - # Use 'template: mycustomtemplate' to use the properties specified in the template 'mycustomtemplate' to this world. Default it is set to the environment-name (normal or nether). - # template: mycustomtemplate - # Rest of comes from template - uncomment to tailor for world specifically - # center: - # x: 0 - # y: 64 - # z: 0 - # # If bigworld set to true, use alternate directory layout better suited to large worlds - # bigworld: true - # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) - # extrazoomout: 3 - # maps: - # - class: org.dynmap.flat.FlatMap - # name: flat - # title: "Flat" - # prefix: flat - # colorscheme: default - # # The textured setting makes the flat render toning much more consistent with the other maps: set to 'none' for the original flat texture, 'smooth' for blended tile top colors, 'dither' for dither pattern - # textured: smooth - # # To render a world as a "night view", set shadowstrength and ambientlight - # shadowstrength: 1.0 - # ambientlight: 4 - # # To render both night and day versions of tiles (when ambientlight is set), set true - # night-and-day: true - # # Option to turn on transparency support (off by default) - slows render - # transparency: true - # # Background color for map during the day - # backgroundday: "#153E7E" - # # Background color for map during the night - # backgroundnight: "#000000" - # # Backgrounc color for map (independent of night/day) - # background: "#000000" - # - class: org.dynmap.kzedmap.KzedMap - # renderers: - # - class: org.dynmap.kzedmap.DefaultTileRenderer - # name: surface - # title: "Surface" - # prefix: t - # maximumheight: 127 - # colorscheme: default - # # Add shadows to world (based on top-down shadows from chunk data) - # shadowstrength: 1.0 - # # To render a world as a "night view", set shadowstrength and ambientlight - # ambientlight: 4 - # # To render both night and day versions of tiles (when ambientlight is set), set true - # night-and-day: true - # # Option to turn off transparency support (on by default) - speeds render - # transparency: false - # # Background color for map during the day - # backgroundday: "#153E7E" - # # Background color for map during the night - # backgroundnight: "#000000" - # # Backgrounc color for map (independent of night/day) - # background: "#000000" - # # Sets the icon to 'images/block_custom.png' - # icon: custom - # - class: org.dynmap.kzedmap.HighlightTileRenderer - # prefix: ht - # maximumheight: 127 - # colorscheme: default - # highlight: # For highlighting multiple block-types. - # - 56 # Highlight diamond-ore - # - 66 # Highlight minecart track - # highlight: 56 # For highlighting a single block-type. - # - class: org.dynmap.kzedmap.CaveTileRenderer - # name: cave - # title: "Cave" - # prefix: ct - # maximumheight: 127 - # - # To just label world, and inherit rest from template, just provide name and title - #- name: world2 - # title: "Second World" - # - #- name: nether - # title: "Nether" - # center: - # x: 0 - # y: 64 - # z: 0 - # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) - # extrazoomout: 3 - # maps: - # - class: org.dynmap.flat.FlatMap - # name: flat - # title: "Flat" - # prefix: flat - # colorscheme: default - # # The textured setting makes the flat render toning much more consistent with the other maps: set to 'none' for the original flat texture, 'smooth' for blended tile top colors, 'dither' for dither pattern - # textured: smooth - # - class: org.dynmap.kzedmap.KzedMap - # renderers: - # - class: org.dynmap.kzedmap.DefaultTileRenderer - # name: nether - # title: "Surface" - # prefix: nt - # maximumheight: 127 - # colorscheme: default - -# Set to true to enable verbose startup messages - can help with debugging map configuration problems -# Set to false for a much quieter startup log -verbose: true - -# Enables debugging. -#debuggers: -# - class: org.dynmap.debug.LogDebugger diff --git a/configuration.txt.sample-hd b/configuration.txt.sample-hd deleted file mode 100644 index 2dede449..00000000 --- a/configuration.txt.sample-hd +++ /dev/null @@ -1,414 +0,0 @@ -# All paths in this configuration file are relative to Dynmap's data-folder: minecraft_server/plugins/dynmap/ -# NOTE: this is a sample of the standard configuration.txt, with HDMap renders substituted - -components: - - class: org.dynmap.ClientConfigurationComponent - - - class: org.dynmap.InternalClientUpdateComponent - sendhealth: true - sendposition: true - allowwebchat: true - webchat-interval: 5 - hidewebchatip: false - trustclientname: false - #- class: org.dynmap.JsonFileClientUpdateComponent - # writeinterval: 1 - # sendhealth: true - # sendposition: true - # allowwebchat: false - # hidewebchatip: false - - - class: org.dynmap.SimpleWebChatComponent - allowchat: true - #- class: org.dynmap.herochat.HeroWebChatComponent - # # Control which HeroChat channel messages from web are directed to - # herochatwebchannel: Global - # # Control which channels are monitored and reported to the web - # herochatchannels: - # - Global - # #- Trade - # #- Haggle - - - class: org.dynmap.ClientComponent - type: chat - - class: org.dynmap.ClientComponent - type: chatballoon - focuschatballoons: false - - class: org.dynmap.ClientComponent - type: chatbox - showplayerfaces: true - messagettl: 5 - - class: org.dynmap.ClientComponent - type: playermarkers - showplayerfaces: true - showplayerhealth: true - #- class: org.dynmap.ClientComponent - # type: digitalclock - - class: org.dynmap.ClientComponent - type: timeofdayclock - showdigitalclock: true - #showweather: true - #- class: org.dynmap.regions.RegionsComponent - # type: regions - # name: WorldGuard - # useworldpath: true - # filename: regions.yml - # basenode: regions - # use3dregions: true - # infowindow: '
%regionname% - %priority% (%parent%)
Owners %playerowners% %groupowners%
Members %playermembers% %groupmembers%
Flags
%flags%
' - # regionstyle: - # strokeColor: "#FF0000" - # strokeOpacity: 0.8 - # strokeWeight: 3 - # fillColor: "#FF0000" - # fillOpacity: 0.35 - # # Optional setting to limit which regions to show, by name - if commented out, all regions are shown - # visibleregions: - # - homebase - # - miningsite - #- class: org.dynmap.TestComponent - # stuff: "This is some configuration-value" - -# Treat hiddenplayers.txt as a whitelist for players to be shown on the map? (Default false) -display-whitelist: false - -# How often a tile gets rendered (in seconds). -renderinterval: 1 - -# Zoom-out tile update period - how often to scan for and process tile updates into zoom-out tiles (in seconds) -zoomoutperiod: 60 - -# Tile hashing is used to minimize tile file updates when no changes have occurred - set to false to disable -enabletilehash: true - -render-triggers: - #- chunkloaded - #- playermove - #- playerjoin - - blockplaced - - blockbreak - - snowform - - leavesdecay - - blockburn - - chunkgenerated - -# The path where the tile-files are placed. -tilespath: web/tiles - -# The path where the web-files are located. -webpath: web - -# The network-interface the webserver will bind to (0.0.0.0 for all interfaces, 127.0.0.1 for only local access). -webserver-bindaddress: 0.0.0.0 - -# The TCP-port the webserver will listen on. -webserver-port: 8123 - -# Disables Webserver portion of Dynmap (Advanced users only) -disable-webserver: false - -# Enable/disable having the web server allow symbolic links (true=compatible with existing code, false=more secure (default)) -allow-symlinks: true - -# Period between tile renders for fullrender, in seconds (non-zero to pace fullrenders, lessen CPU load) -timesliceinterval: 0.0 - -# Maximum chunk loads per server tick (1/20th of a second) - reducing this below 90 will impact render performance, but also will reduce server thread load -maxchunkspertick: 200 - -# Interval the browser should poll for updates. -updaterate: 2000 - -showplayerfacesinmenu: true - -# Set sidebaropened: true to pin menu sidebar opened -#sidebaropened: true - -joinmessage: "%playername% joined" -quitmessage: "%playername% quit" -spammessage: "You may only chat once every %interval% seconds." -webprefix: "§2[WEB] " -websuffix: "§f" - -defaultzoom: 0 -defaultworld: world - -# template world - this is used for worlds that exist but aren't defined in the worlds section. -# Also, it supplies the "maps" section for worlds lacking a maps section, and the "center" -# for worlds lacking a "center" section. -templates: - # Template for normal world - normal: - enabled: true - # # If bigworld set to true, use alternate directory layout better suited to large worlds - # bigworld: true - # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) - # extrazoomout: 3 - center: - x: 0 - y: 64 - z: 0 - maps: - - class: org.dynmap.hdmap.HDMap - name: flat - title: "Flat" - prefix: flat - perspective: iso_S_90_lowres - shader: stdtexture - lighting: default - # # To render a world as a "night view", switch to lighting: night - # lighting: night - # # To render both night and day versions of tiles, set light: nightandday - # lighting: nightandday - # # Background color for map during the day - # backgroundday: "#153E7E" - # # Background color for map during the night - # backgroundnight: "#000000" - # # Background color for map (independent of night/day) - # background: "#000000" - - class: org.dynmap.hdmap.HDMap - name: surface - title: "Surface" - prefix: t - perspective: iso_SE_60_lowres - shader: stdtexture - lighting: default - # # Add shadows to world (based on top-down shadows from chunk data) - # lighting: shadows - # # To render a world as a "night view", set lighting: night - # lighting: night - # # To render both night and day versions of tiles, set lighting: nightandday - # lighting: nightandday - # # Background color for map during the day - # backgroundday: "#153E7E" - # # Background color for map during the night - # backgroundnight: "#000000" - # # Background color for map (independent of night/day) - # background: "#000000" - # # Sets the icon to 'images/block_custom.png' - # icon: custom - # # Biome-based mapping - # - class: org.dynmap.hdmap.HDMap - # name: biome - # title: "Biome" - # prefix: b - # perspective: iso_SE_60_lowres - # lighting: default - # # Biome-based shading : biome=biome type, temperature=biome-temperature, rainfall=biome-rainfall - # shader: biome - - class: org.dynmap.hdmap.HDMap - name: cave - title: "Cave" - prefix: ct - perspective: iso_SE_60_lowres - shader: cave - lighting: default - - # Nether world template - nether: - enabled: true - # # If bigworld set to true, use alternate directory layout better suited to large worlds - # bigworld: true - # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) - # extrazoomout: 3 - center: - x: 0 - y: 64 - z: 0 - maps: - - class: org.dynmap.hdmap.HDMap - name: flat - title: "Flat" - prefix: flat - perspective: iso_S_90_lowres - shader: stdtexture - lighting: default - # Map background color (day or night) - background: "#300806" - - class: org.dynmap.hdmap.HDMap - name: nether - title: "Surface" - prefix: nt - perspective: iso_SE_60_lowres - shader: stdtexture - lighting: default - # Map background color (day or night) - background: "#300806" - # Skylands world template - skylands: - enabled: true - # # If bigworld set to true, use alternate directory layout better suited to large worlds - # bigworld: true - # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) - # extrazoomout: 3 - center: - x: 0 - y: 64 - z: 0 - maps: - - class: org.dynmap.hdmap.HDMap - name: flat - title: "Flat" - prefix: flat - perspective: iso_S_90_lowres - shader: stdtexture - lighting: default - # Background color for map during the day - backgroundday: "#153E7E" - # Background color for map during the night - backgroundnight: "#000000" - - class: org.dynmap.hdmap.HDMap - name: skylands - title: "Surface" - prefix: st - perspective: iso_SE_60_lowres - shader: stdtexture - lighting: nightandday - # Background color for map during the day - backgroundday: "#153E7E" - # Background color for map during the night - backgroundnight: "#000000" - -# The maptypes Dynmap will use to render. -worlds: - # Worlds can be handled by templates, based on world type - # You can override the properties of the template by specifying them in this section - # for example 'Title: "My Awesome World"' - #- name: world - # title: "World" - # Use 'enabled: false' to disable a certain world. - # enabled: false - # Use sendposition: false to prevent player positions from showing when on this world (if sendposition is globally enabled) - # sendposition: false - # Use sendhealth: false ot prevent player health from showing when on this world (if sendhealth is globally enabled) - # sendhealth: false - # # If world isn't contiguous chunks (due to teleporting, for example), fullrender needs to be given other locations to scan for tiles on each patch of chunks - # fullrenderlocations: - # - x: 10000 - # y: 64 - # z: 20000 - # - x: -15000 - # y: 64 - # z: -5000 - # # Use visibilitylimits to restrict which areas of maps on your world to render (zero or more rectangles can be defined) - # visibilitylimits: - # - x0: -1000 - # z0: -1000 - # x1: 1000 - # z1: 1000 - # - x0: -2000 - # z0: -1000 - # x1: -1000 - # z1: -500 - # # Use hidestyle to control how hidden-but-existing chunks are to be rendered (air=empty air (same as ungenerated), stone=a flat stone plain, ocean=a flat ocean) - # hidestyle: stone - # # Use 'autogenerate-to-visibilitylimits: true' to choose to force the generation of ungenerated chunks while rendering maps on this world, for any chunks within the defined - # # visibilitylimits (limits must be set). The three options here are: none (default - no autogenerate), map-only (temporarily generate chunks for map, but don't save them (no world change), - # # permanent (generate and save chunks - this permanently adds the chunks to the world, as if a player had visited them - BE SURE THIS IS WHAT YOU WANT) - # autogenerate-to-visibilitylimits: map-only - # Use 'template: mycustomtemplate' to use the properties specified in the template 'mycustomtemplate' to this world. Default it is set to the environment-name (normal or nether). - # template: mycustomtemplate - # Rest of comes from template - uncomment to tailor for world specifically - # center: - # x: 0 - # y: 64 - # z: 0 - # # If bigworld set to true, use alternate directory layout better suited to large worlds - # bigworld: true - # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) - # extrazoomout: 3 - # maps: - # - class: org.dynmap.hdmap.HDMap - # name: flat - # title: "Flat" - # prefix: flat - # perspective: iso_S_90_lowres - # shader: default - # lighting: default - # # To render a world as a "night view", switch to lighting: night - # lighting: night - # # To render both night and day versions of tiles, set light: nightandday - # lighting: nightandday - # # Background color for map during the day - # backgroundday: "#153E7E" - # # Background color for map during the night - # backgroundnight: "#000000" - # # Background color for map (independent of night/day) - # background: "#000000" - # - class: org.dynmap.hdmap.HDMap - # name: surface - # title: "Surface" - # prefix: t - # perspective: iso_SE_60_lowres - # shader: default - # lighting: default - # # Add shadows to world (based on top-down shadows from chunk data) - # lighting: shadows - # # To render a world as a "night view", set lighting: night - # lighting: night - # # To render both night and day versions of tiles, set lighting: nightandday - # lighting: nightandday - # # Background color for map during the day - # backgroundday: "#153E7E" - # # Background color for map during the night - # backgroundnight: "#000000" - # # Background color for map (independent of night/day) - # background: "#000000" - # # Sets the icon to 'images/block_custom.png' - # icon: custom - # # Biome-based mapping - # - class: org.dynmap.hdmap.HDMap - # name: biome - # title: "Biome" - # prefix: b - # perspective: iso_SE_60_lowres - # lighting: default - # # Biome-based shading : biome=biome type, temperature=biome-temperature, rainfall=biome-rainfall - # shader: biome - # - class: org.dynmap.hdmap.HDMap - # name: cave - # title: "Cave" - # prefix: ct - # perspective: iso_SE_60_lowres - # shader: cave - # lighting: default - # - # To just label world, and inherit rest from template, just provide name and title - #- name: world2 - # title: "Second World" - # - #- name: nether - # title: "Nether" - # center: - # x: 0 - # y: 64 - # z: 0 - # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) - # extrazoomout: 3 - # maps: - # - class: org.dynmap.hdmap.HDMap - # name: flat - # title: "Flat" - # prefix: flat - # perspective: iso_S_90_lowres - # shader: default - # lighting: default - # # Map background color (day or night) - # background: "#300806" - # - class: org.dynmap.hdmap.HDMap - # name: nether - # title: "Surface" - # prefix: nt - # perspective: iso_SE_60_lowres - # shader: default - # # Map background color (day or night) - # background: "#300806" - -# Set to true to enable verbose startup messages - can help with debugging map configuration problems -# Set to false for a much quieter startup log -verbose: true - -# Enables debugging. -#debuggers: -# - class: org.dynmap.debug.LogDebugger - diff --git a/lightings.txt b/lightings.txt index f8ec1899..a47b6b8e 100644 --- a/lightings.txt +++ b/lightings.txt @@ -1,3 +1,7 @@ +# +# This file contains default standard lighting profiles. The contents of this file are replaced and updated +# during upgrades, so new or updated lighing definitions should be done in the custom-lightings.txt file +# lightings: # Default lighting - no effects, shadows, day/night - class: org.dynmap.hdmap.DefaultHDLighting diff --git a/perspectives.txt b/perspectives.txt index 48d03b0c..ff489562 100644 --- a/perspectives.txt +++ b/perspectives.txt @@ -1,3 +1,7 @@ +# +# This file contains default standard perspective definitions. The contents of this file are replaced and updated +# during upgrades, so new or updated perspective definitions should be done in the custom-perspectives.txt file +# perspectives: - class: org.dynmap.hdmap.IsoHDPerspective name: iso_S_60_lowres diff --git a/shaders.txt b/shaders.txt index 1ed6eb86..d9c843bf 100644 --- a/shaders.txt +++ b/shaders.txt @@ -1,3 +1,7 @@ +# +# This file contains default standard shader definitions. The contents of this file are replaced and updated +# during upgrades, so new or updated shader definitions should be done in the custom-shaders.txt file +# shaders: - class: org.dynmap.hdmap.DefaultHDShader name: default diff --git a/src/main/assembly/package.xml b/src/main/assembly/package.xml index 417ad924..6b31b3f1 100644 --- a/src/main/assembly/package.xml +++ b/src/main/assembly/package.xml @@ -27,13 +27,14 @@ ${project.basedir} /dynmap/ - configuration.txt + configuration.default shaders.txt perspectives.txt lightings.txt - configuration.txt.sample-hd + templates.txt models.txt - texture.txt + texture.txt + worlds.txt.sample ${project.basedir}/texturepacks /dynmap/texturepacks diff --git a/src/main/java/org/dynmap/DynmapPlugin.java b/src/main/java/org/dynmap/DynmapPlugin.java index c2597b0c..023ffcd9 100644 --- a/src/main/java/org/dynmap/DynmapPlugin.java +++ b/src/main/java/org/dynmap/DynmapPlugin.java @@ -1,6 +1,10 @@ package org.dynmap; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.Constructor; import java.net.InetAddress; @@ -52,6 +56,7 @@ public class DynmapPlugin extends JavaPlugin { public PermissionProvider permissions; public ComponentManager componentManager = new ComponentManager(); public Events events = new Events(); + public String deftemplatesuffix = ""; /* 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; @@ -67,6 +72,63 @@ public class DynmapPlugin extends JavaPlugin { public HttpServer getWebServer() { return webServer; } + + /* Add/Replace branches in configuration tree with contribution from a separate file */ + @SuppressWarnings("unchecked") + private void mergeConfigurationBranch(ConfigurationNode cfgnode, String branch, boolean replace_existing) { + Object srcbranch = cfgnode.getObject(branch); + if(srcbranch == null) + return; + /* See if top branch is in configuration - if not, just add whole thing */ + Object destbranch = configuration.getObject(branch); + if(destbranch == null) { /* Not found */ + configuration.put(branch, srcbranch); /* Add new tree to configuration */ + return; + } + /* If list, merge by "name" attribute */ + if((srcbranch instanceof List) && (destbranch instanceof List)) { + List dest = (List)destbranch; + List src = (List)srcbranch; + /* Go through new records : see what to do with each */ + for(ConfigurationNode node : src) { + String name = node.getString("name", null); + if(name == null) continue; + /* Walk destination - see if match */ + boolean matched = false; + for(ConfigurationNode dnode : dest) { + String dname = node.getString("name", null); + if(dname == null) continue; + if(dname.equals(name)) { /* Match? */ + if(replace_existing) { + dnode.clear(); + dnode.putAll(node); + } + matched = true; + break; + } + } + /* If no match, add to end */ + if(!matched) { + dest.add(node); + } + } + } + /* If configuration node, merge by key */ + else if((srcbranch instanceof ConfigurationNode) && (destbranch instanceof ConfigurationNode)) { + ConfigurationNode src = (ConfigurationNode)srcbranch; + ConfigurationNode dest = (ConfigurationNode)destbranch; + for(String key : src.keySet()) { /* Check each contribution */ + if(dest.containsKey(key)) { /* Exists? */ + if(replace_existing) { /* If replacing, do so */ + dest.put(key, src.getObject(key)); + } + } + else { /* Else, always add if not there */ + dest.put(key, src.getObject(key)); + } + } + } + } @Override public void onEnable() { @@ -80,11 +142,79 @@ public class DynmapPlugin extends JavaPlugin { /* Load texture mappings */ TexturePack.loadTextureMapping(dataDirectory); - org.bukkit.util.config.Configuration bukkitConfiguration = new org.bukkit.util.config.Configuration(new File(this.getDataFolder(), "configuration.txt")); + File f = new File(this.getDataFolder(), "configuration.txt"); + /* If configuration.txt not found, copy the default one */ + if(f.exists() == false) { + Log.info("configuration.txt not found - creating default"); + File deffile = new File(this.getDataFolder(), "configuration.default"); + try { + FileInputStream fis = new FileInputStream(deffile); + FileOutputStream fos = new FileOutputStream(f); + byte[] buf = new byte[512]; + int len; + while((len = fis.read(buf)) > 0) { + fos.write(buf, 0, len); + } + fos.close(); + fis.close(); + } catch (IOException iox) { + Log.severe("ERROR CREATING DEFAULT CONFIGURATION.TXT!"); + this.setEnabled(false); + return; + } + } + org.bukkit.util.config.Configuration bukkitConfiguration = new org.bukkit.util.config.Configuration(f); bukkitConfiguration.load(); configuration = new ConfigurationNode(bukkitConfiguration); + /* Now, process worlds.txt - merge it in as an override of existing values (since it is only user supplied values) */ + f = new File(this.getDataFolder(), "worlds.txt"); + if(f.exists()) { + org.bukkit.util.config.Configuration cfg = new org.bukkit.util.config.Configuration(f); + cfg.load(); + ConfigurationNode cn = new ConfigurationNode(cfg); + mergeConfigurationBranch(cn, "worlds", true); + } + else { + try { + FileWriter fw = new FileWriter(f); + fw.write("# This file is intended to allow the user to define world-specific settings\n"); + fw.write("# Dynmap's install will not overwrite it\n"); + fw.write("worlds:\n"); + fw.close(); + } catch (IOException iox) { + } + } + + /* Now, process templates.txt - supplement existing values (don't replace), since configuration.txt is more custom than these */ + f = new File(this.getDataFolder(), "templates.txt"); + if(f.exists()) { + org.bukkit.util.config.Configuration cfg = new org.bukkit.util.config.Configuration(f); + cfg.load(); + ConfigurationNode cn = new ConfigurationNode(cfg); + mergeConfigurationBranch(cn, "templates", false); + } + + /* Now, process custom-templates.txt - these are user supplied, so override anything matcing */ + f = new File(this.getDataFolder(), "custom-templates.txt"); + if(f.exists()) { + org.bukkit.util.config.Configuration cfg = new org.bukkit.util.config.Configuration(f); + cfg.load(); + ConfigurationNode cn = new ConfigurationNode(cfg); + mergeConfigurationBranch(cn, "templates", true); + } + else { + try { + FileWriter fw = new FileWriter(f); + fw.write("# This file is intended to allow the user to define templates, including replacements for standard templates\n"); + fw.write("# Dynmap's install will not overwrite it\n"); + fw.write("templates:\n"); + fw.close(); + } catch (IOException iox) { + } + } Log.verbose = configuration.getBoolean("verbose", true); + deftemplatesuffix = configuration.getString("deftemplatesuffix", ""); loadDebuggers(); @@ -496,6 +626,9 @@ public class DynmapPlugin extends JavaPlugin { private ConfigurationNode getDefaultTemplateConfigurationNode(World world) { Environment environment = world.getEnvironment(); String environmentName = environment.name().toLowerCase(); + if(deftemplatesuffix.length() > 0) { + environmentName += "-" + deftemplatesuffix; + } Log.verboseinfo("Using environment as template: " + environmentName); return getTemplateConfigurationNode(environmentName); } diff --git a/templates.txt b/templates.txt new file mode 100644 index 00000000..588e947e --- /dev/null +++ b/templates.txt @@ -0,0 +1,290 @@ +# templates provide default definitions for worlds that are not otherwise defined in the worlds.txt. Unless otherwise +# configured, worlds will default to the template corresponding to their environment (normal, nether, skylands). Use of the +# 'deftemplatesuffix' setting in configuration.txt can alter this by appending a dash and a suffix string to the template name +# used by default (for example deftemplatesuffix=HDMap implies default template names of normal-HDMap, nether-HDMap, skylands-HDMap. +# +# NOTE: +# templates.txt is updated frequently: if you wish to customize some or all of the templates, or define your own, place +# the templates you wish to modify in the custom-templates.txt file - these will be preserved, and will override those found +# in templates.txt +templates: + # Template for normal world (classic render) + normal: + enabled: true + # # If bigworld set to true, use alternate directory layout better suited to large worlds + # bigworld: true + # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) + # extrazoomout: 3 + center: + x: 0 + y: 64 + z: 0 + maps: + - class: org.dynmap.flat.FlatMap + name: flat + title: "Flat" + prefix: flat + colorscheme: default + # The textured setting makes the flat render toning much more consistent with the other maps: set to 'none' for the original flat texture, 'smooth' for blended tile top colors, 'dither' for dither pattern + textured: smooth + # # To render a world as a "night view", set shadowstrength and ambientlight + # shadowstrength: 1.0 + # ambientlight: 4 + # # To render both night and day versions of tiles (when ambientlight is set), set true + # night-and-day: true + # # Option to turn on transparency support (off by default) - slows render + # transparency: true + # # Background color for map during the day + # backgroundday: "#153E7E" + # # Background color for map during the night + # backgroundnight: "#000000" + # # Background color for map (independent of night/day) + # background: "#000000" + - class: org.dynmap.kzedmap.KzedMap + renderers: + - class: org.dynmap.kzedmap.DefaultTileRenderer + name: surface + title: "Surface" + prefix: t + maximumheight: 127 + colorscheme: default + # # Add shadows to world (based on top-down shadows from chunk data) + # shadowstrength: 1.0 + # # To render a world as a "night view", set shadowstrength and ambientlight + # ambientlight: 4 + # # To render both night and day versions of tiles (when ambientlight is set), set true + # night-and-day: true + # # Option to turn off transparency support (on by default) - speeds render + # transparency: false + # # Background color for map during the day + # backgroundday: "#153E7E" + # # Background color for map during the night + # backgroundnight: "#000000" + # # Background color for map (independent of night/day) + # background: "#000000" + # # Sets the icon to 'images/block_custom.png' + # icon: custom + # # Biome-based mapping + # - class: org.dynmap.kzedmap.DefaultTileRenderer + # name: biome + # title: "Biome" + # prefix: b + # maximumheight: 127 + # colorscheme: default + # # Biome-based coloring : biome=biome type, temperature=biome-temperature, rainfall=biome-rainfall + # biomecolored: biome + # - class: org.dynmap.kzedmap.HighlightTileRenderer + # prefix: ht + # maximumheight: 127 + # colorscheme: default + # highlight: # For highlighting multiple block-types. + # - 56 # Highlight diamond-ore + # - 66 # Highlight minecart track + # highlight: 56 # For highlighting a single block-type. + - class: org.dynmap.kzedmap.CaveTileRenderer + name: cave + title: "Cave" + prefix: ct + maximumheight: 127 + # Nether world template (classic render) + nether: + enabled: true + # # If bigworld set to true, use alternate directory layout better suited to large worlds + # bigworld: true + # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) + # extrazoomout: 3 + center: + x: 0 + y: 64 + z: 0 + maps: + - class: org.dynmap.flat.FlatMap + name: flat + title: "Flat" + prefix: flat + colorscheme: default + # Map background color (day or night) + background: "#300806" + # The textured setting makes the flat render toning much more consistent with the other maps: set to 'none' for the original flat texture, 'smooth' for blended tile top colors, 'dither' for dither pattern + textured: smooth + - class: org.dynmap.kzedmap.KzedMap + renderers: + - class: org.dynmap.kzedmap.DefaultTileRenderer + name: nether + title: "Surface" + prefix: nt + maximumheight: 127 + colorscheme: default + # Map background color (day or night) + background: "#300806" + # Skylands world template (classic render) + skylands: + enabled: true + # # If bigworld set to true, use alternate directory layout better suited to large worlds + # bigworld: true + # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) + # extrazoomout: 3 + center: + x: 0 + y: 64 + z: 0 + maps: + - class: org.dynmap.flat.FlatMap + name: flat + title: "Flat" + prefix: flat + colorscheme: default + # Background color for map during the day + backgroundday: "#153E7E" + # Background color for map during the night + backgroundnight: "#000000" + # The textured setting makes the flat render toning much more consistent with the other maps: set to 'none' for the original flat texture, 'smooth' for blended tile top colors, 'dither' for dither pattern + textured: smooth + - class: org.dynmap.kzedmap.KzedMap + renderers: + - class: org.dynmap.kzedmap.DefaultTileRenderer + name: skylands + title: "Surface" + prefix: st + maximumheight: 127 + colorscheme: default + # Background color for map during the day + backgroundday: "#153E7E" + # Background color for map during the night + backgroundnight: "#000000" + night-and-day: true + shadowstrength: 1.0 + ambientlight: 4 + + # Template for normal world (HDMap) + normal-HDMap: + enabled: true + # # If bigworld set to true, use alternate directory layout better suited to large worlds + # bigworld: true + # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) + # extrazoomout: 3 + center: + x: 0 + y: 64 + z: 0 + maps: + - class: org.dynmap.hdmap.HDMap + name: flat + title: "Flat" + prefix: flat + perspective: iso_S_90_lowres + shader: stdtexture + lighting: default + # # To render a world as a "night view", switch to lighting: night + # lighting: night + # # To render both night and day versions of tiles, set light: nightandday + # lighting: nightandday + # # Background color for map during the day + # backgroundday: "#153E7E" + # # Background color for map during the night + # backgroundnight: "#000000" + # # Background color for map (independent of night/day) + # background: "#000000" + - class: org.dynmap.hdmap.HDMap + name: surface + title: "Surface" + prefix: t + perspective: iso_SE_60_lowres + shader: stdtexture + lighting: default + # # Add shadows to world (based on top-down shadows from chunk data) + # lighting: shadows + # # To render a world as a "night view", set lighting: night + # lighting: night + # # To render both night and day versions of tiles, set lighting: nightandday + # lighting: nightandday + # # Background color for map during the day + # backgroundday: "#153E7E" + # # Background color for map during the night + # backgroundnight: "#000000" + # # Background color for map (independent of night/day) + # background: "#000000" + # # Sets the icon to 'images/block_custom.png' + # icon: custom + # # Biome-based mapping + # - class: org.dynmap.hdmap.HDMap + # name: biome + # title: "Biome" + # prefix: b + # perspective: iso_SE_60_lowres + # lighting: default + # # Biome-based shading : biome=biome type, temperature=biome-temperature, rainfall=biome-rainfall + # shader: biome + - class: org.dynmap.hdmap.HDMap + name: cave + title: "Cave" + prefix: ct + perspective: iso_SE_60_lowres + shader: cave + lighting: default + + # Nether world template (HDMap) + nether-HDMap: + enabled: true + # # If bigworld set to true, use alternate directory layout better suited to large worlds + # bigworld: true + # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) + # extrazoomout: 3 + center: + x: 0 + y: 64 + z: 0 + maps: + - class: org.dynmap.hdmap.HDMap + name: flat + title: "Flat" + prefix: flat + perspective: iso_S_90_lowres + shader: stdtexture + lighting: default + # Map background color (day or night) + background: "#300806" + - class: org.dynmap.hdmap.HDMap + name: nether + title: "Surface" + prefix: nt + perspective: iso_SE_60_lowres + shader: stdtexture + lighting: default + # Map background color (day or night) + background: "#300806" + # Skylands world template (HDMap) + skylands-HDMap: + enabled: true + # # If bigworld set to true, use alternate directory layout better suited to large worlds + # bigworld: true + # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) + # extrazoomout: 3 + center: + x: 0 + y: 64 + z: 0 + maps: + - class: org.dynmap.hdmap.HDMap + name: flat + title: "Flat" + prefix: flat + perspective: iso_S_90_lowres + shader: stdtexture + lighting: default + # Background color for map during the day + backgroundday: "#153E7E" + # Background color for map during the night + backgroundnight: "#000000" + - class: org.dynmap.hdmap.HDMap + name: skylands + title: "Surface" + prefix: st + perspective: iso_SE_60_lowres + shader: stdtexture + lighting: nightandday + # Background color for map during the day + backgroundday: "#153E7E" + # Background color for map during the night + backgroundnight: "#000000" + \ No newline at end of file diff --git a/worlds.txt.sample b/worlds.txt.sample new file mode 100644 index 00000000..be93643b --- /dev/null +++ b/worlds.txt.sample @@ -0,0 +1,140 @@ +# These are examples of world-specific settings, which can be defined in the worlds.txt file +# +# NOTE: +# This file only contains samples: actual world customizations must be done in the worlds.txt file (or the worlds: section of +# configuration.txt). All lines here are commented with the # symbol - delete the # symbol on copied lines you wish to enable +# +worlds: + # Worlds can be handled by templates, based on world type + # You can override the properties of the template by specifying them in this section + # for example 'Title: "My Awesome World"' + #- name: world + # title: "World" + # Use 'enabled: false' to disable a certain world. + # enabled: false + # Use sendposition: false to prevent player positions from showing when on this world (if sendposition is globally enabled) + # sendposition: false + # Use sendhealth: false ot prevent player health from showing when on this world (if sendhealth is globally enabled) + # sendhealth: false + # # If world isn't contiguous chunks (due to teleporting, for example), fullrender needs to be given other locations to scan for tiles on each patch of chunks + # fullrenderlocations: + # - x: 10000 + # y: 64 + # z: 20000 + # - x: -15000 + # y: 64 + # z: -5000 + # # Use visibilitylimits to restrict which areas of maps on your world to render (zero or more rectangles can be defined) + # visibilitylimits: + # - x0: -1000 + # z0: -1000 + # x1: 1000 + # z1: 1000 + # - x0: -2000 + # z0: -1000 + # x1: -1000 + # z1: -500 + # # Use hidestyle to control how hidden-but-existing chunks are to be rendered (air=empty air (same as ungenerated), stone=a flat stone plain, ocean=a flat ocean) + # hidestyle: stone + # # Use 'autogenerate-to-visibilitylimits: true' to choose to force the generation of ungenerated chunks while rendering maps on this world, for any chunks within the defined + # # visibilitylimits (limits must be set). The three options here are: none (default - no autogenerate), map-only (temporarily generate chunks for map, but don't save them (no world change), + # # permanent (generate and save chunks - this permanently adds the chunks to the world, as if a player had visited them - BE SURE THIS IS WHAT YOU WANT) + # autogenerate-to-visibilitylimits: map-only + # Use 'template: mycustomtemplate' to use the properties specified in the template 'mycustomtemplate' to this world. Default it is set to the environment-name (normal or nether). + # template: mycustomtemplate + # Rest of comes from template - uncomment to tailor for world specifically + # center: + # x: 0 + # y: 64 + # z: 0 + # # If bigworld set to true, use alternate directory layout better suited to large worlds + # bigworld: true + # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) + # extrazoomout: 3 + # maps: + # - class: org.dynmap.flat.FlatMap + # name: flat + # title: "Flat" + # prefix: flat + # colorscheme: default + # # The textured setting makes the flat render toning much more consistent with the other maps: set to 'none' for the original flat texture, 'smooth' for blended tile top colors, 'dither' for dither pattern + # textured: smooth + # # To render a world as a "night view", set shadowstrength and ambientlight + # shadowstrength: 1.0 + # ambientlight: 4 + # # To render both night and day versions of tiles (when ambientlight is set), set true + # night-and-day: true + # # Option to turn on transparency support (off by default) - slows render + # transparency: true + # # Background color for map during the day + # backgroundday: "#153E7E" + # # Background color for map during the night + # backgroundnight: "#000000" + # # Backgrounc color for map (independent of night/day) + # background: "#000000" + # - class: org.dynmap.kzedmap.KzedMap + # renderers: + # - class: org.dynmap.kzedmap.DefaultTileRenderer + # name: surface + # title: "Surface" + # prefix: t + # maximumheight: 127 + # colorscheme: default + # # Add shadows to world (based on top-down shadows from chunk data) + # shadowstrength: 1.0 + # # To render a world as a "night view", set shadowstrength and ambientlight + # ambientlight: 4 + # # To render both night and day versions of tiles (when ambientlight is set), set true + # night-and-day: true + # # Option to turn off transparency support (on by default) - speeds render + # transparency: false + # # Background color for map during the day + # backgroundday: "#153E7E" + # # Background color for map during the night + # backgroundnight: "#000000" + # # Backgrounc color for map (independent of night/day) + # background: "#000000" + # # Sets the icon to 'images/block_custom.png' + # icon: custom + # - class: org.dynmap.kzedmap.HighlightTileRenderer + # prefix: ht + # maximumheight: 127 + # colorscheme: default + # highlight: # For highlighting multiple block-types. + # - 56 # Highlight diamond-ore + # - 66 # Highlight minecart track + # highlight: 56 # For highlighting a single block-type. + # - class: org.dynmap.kzedmap.CaveTileRenderer + # name: cave + # title: "Cave" + # prefix: ct + # maximumheight: 127 + # + # To just label world, and inherit rest from template, just provide name and title + #- name: world2 + # title: "Second World" + # + #- name: nether + # title: "Nether" + # center: + # x: 0 + # y: 64 + # z: 0 + # # Number of extra zoom-out levels for world (each level is twice as big as the previous one) + # extrazoomout: 3 + # maps: + # - class: org.dynmap.flat.FlatMap + # name: flat + # title: "Flat" + # prefix: flat + # colorscheme: default + # # The textured setting makes the flat render toning much more consistent with the other maps: set to 'none' for the original flat texture, 'smooth' for blended tile top colors, 'dither' for dither pattern + # textured: smooth + # - class: org.dynmap.kzedmap.KzedMap + # renderers: + # - class: org.dynmap.kzedmap.DefaultTileRenderer + # name: nether + # title: "Surface" + # prefix: nt + # maximumheight: 127 + # colorscheme: default