mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-09-30 06:37:28 +02:00
Add support for custom-perspectives.txt, custom-shaders.txt, custom-lightings.txt
This commit is contained in:
parent
4987ac3fe1
commit
bf4f8a84f0
@ -154,7 +154,7 @@ templates:
|
|||||||
title: "Flat"
|
title: "Flat"
|
||||||
prefix: flat
|
prefix: flat
|
||||||
perspective: iso_S_90_lowres
|
perspective: iso_S_90_lowres
|
||||||
shader: default
|
shader: stdtexture
|
||||||
lighting: default
|
lighting: default
|
||||||
# # To render a world as a "night view", switch to lighting: night
|
# # To render a world as a "night view", switch to lighting: night
|
||||||
# lighting: night
|
# lighting: night
|
||||||
@ -171,7 +171,7 @@ templates:
|
|||||||
title: "Surface"
|
title: "Surface"
|
||||||
prefix: t
|
prefix: t
|
||||||
perspective: iso_SE_60_lowres
|
perspective: iso_SE_60_lowres
|
||||||
shader: default
|
shader: stdtexture
|
||||||
lighting: default
|
lighting: default
|
||||||
# # Add shadows to world (based on top-down shadows from chunk data)
|
# # Add shadows to world (based on top-down shadows from chunk data)
|
||||||
# lighting: shadows
|
# lighting: shadows
|
||||||
@ -221,7 +221,7 @@ templates:
|
|||||||
title: "Flat"
|
title: "Flat"
|
||||||
prefix: flat
|
prefix: flat
|
||||||
perspective: iso_S_90_lowres
|
perspective: iso_S_90_lowres
|
||||||
shader: default
|
shader: stdtexture
|
||||||
lighting: default
|
lighting: default
|
||||||
# Map background color (day or night)
|
# Map background color (day or night)
|
||||||
background: "#300806"
|
background: "#300806"
|
||||||
@ -230,7 +230,7 @@ templates:
|
|||||||
title: "Surface"
|
title: "Surface"
|
||||||
prefix: nt
|
prefix: nt
|
||||||
perspective: iso_SE_60_lowres
|
perspective: iso_SE_60_lowres
|
||||||
shader: default
|
shader: stdtexture
|
||||||
lighting: default
|
lighting: default
|
||||||
# Map background color (day or night)
|
# Map background color (day or night)
|
||||||
background: "#300806"
|
background: "#300806"
|
||||||
@ -251,7 +251,7 @@ templates:
|
|||||||
title: "Flat"
|
title: "Flat"
|
||||||
prefix: flat
|
prefix: flat
|
||||||
perspective: iso_S_90_lowres
|
perspective: iso_S_90_lowres
|
||||||
shader: default
|
shader: stdtexture
|
||||||
lighting: default
|
lighting: default
|
||||||
# Background color for map during the day
|
# Background color for map during the day
|
||||||
backgroundday: "#153E7E"
|
backgroundday: "#153E7E"
|
||||||
@ -262,7 +262,7 @@ templates:
|
|||||||
title: "Surface"
|
title: "Surface"
|
||||||
prefix: st
|
prefix: st
|
||||||
perspective: iso_SE_60_lowres
|
perspective: iso_SE_60_lowres
|
||||||
shader: default
|
shader: stdtexture
|
||||||
lighting: nightandday
|
lighting: nightandday
|
||||||
# Background color for map during the day
|
# Background color for map during the day
|
||||||
backgroundday: "#153E7E"
|
backgroundday: "#153E7E"
|
||||||
|
@ -48,9 +48,6 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
public MapManager mapManager = null;
|
public MapManager mapManager = null;
|
||||||
public PlayerList playerList;
|
public PlayerList playerList;
|
||||||
public ConfigurationNode configuration;
|
public ConfigurationNode configuration;
|
||||||
public ConfigurationNode shaderconfig;
|
|
||||||
public ConfigurationNode perspectiveconfig;
|
|
||||||
public ConfigurationNode lightingsconfig;
|
|
||||||
public HashSet<String> enabledTriggers = new HashSet<String>();
|
public HashSet<String> enabledTriggers = new HashSet<String>();
|
||||||
public PermissionProvider permissions;
|
public PermissionProvider permissions;
|
||||||
public ComponentManager componentManager = new ComponentManager();
|
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 */
|
/* Flag to let code know that we're doing reload - make sure we don't double-register event handlers */
|
||||||
public boolean is_reload = false;
|
public boolean is_reload = false;
|
||||||
private boolean generate_only = 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 dataDirectory;
|
||||||
public static File tilesDirectory;
|
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"));
|
org.bukkit.util.config.Configuration bukkitConfiguration = new org.bukkit.util.config.Configuration(new File(this.getDataFolder(), "configuration.txt"));
|
||||||
bukkitConfiguration.load();
|
bukkitConfiguration.load();
|
||||||
configuration = new ConfigurationNode(bukkitConfiguration);
|
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);
|
Log.verbose = configuration.getBoolean("verbose", true);
|
||||||
|
|
||||||
loadDebuggers();
|
loadDebuggers();
|
||||||
@ -109,7 +96,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
playerList = new PlayerList(getServer(), getFile("hiddenplayers.txt"), configuration);
|
playerList = new PlayerList(getServer(), getFile("hiddenplayers.txt"), configuration);
|
||||||
playerList.load();
|
playerList.load();
|
||||||
|
|
||||||
mapManager = new MapManager(this, configuration, shaderconfig, perspectiveconfig, lightingsconfig);
|
mapManager = new MapManager(this, configuration);
|
||||||
mapManager.startRendering();
|
mapManager.startRendering();
|
||||||
|
|
||||||
loadWebserver();
|
loadWebserver();
|
||||||
|
@ -335,15 +335,14 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapManager(DynmapPlugin plugin, ConfigurationNode configuration, ConfigurationNode shadercfg, ConfigurationNode perspectivecfg,
|
public MapManager(DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||||
ConfigurationNode lightingscfg) {
|
|
||||||
plug_in = plugin;
|
plug_in = plugin;
|
||||||
mapman = this;
|
mapman = this;
|
||||||
/* Initialize HD map manager */
|
/* Initialize HD map manager */
|
||||||
hdmapman = new HDMapManager();
|
hdmapman = new HDMapManager();
|
||||||
hdmapman.loadHDShaders(shadercfg);
|
hdmapman.loadHDShaders(plugin);
|
||||||
hdmapman.loadHDPerspectives(perspectivecfg);
|
hdmapman.loadHDPerspectives(plugin);
|
||||||
hdmapman.loadHDLightings(lightingscfg);
|
hdmapman.loadHDLightings(plugin);
|
||||||
sscache = new SnapshotCache(configuration.getInteger("snapshotcachesize", 500));
|
sscache = new SnapshotCache(configuration.getInteger("snapshotcachesize", 500));
|
||||||
|
|
||||||
this.tileQueue = new AsynchronousQueue<MapTile>(new Handler<MapTile>() {
|
this.tileQueue = new AsynchronousQueue<MapTile>(new Handler<MapTile>() {
|
||||||
|
@ -10,6 +10,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.dynmap.ConfigurationNode;
|
import org.dynmap.ConfigurationNode;
|
||||||
import org.dynmap.DynmapChunk;
|
import org.dynmap.DynmapChunk;
|
||||||
import org.dynmap.DynmapWorld;
|
import org.dynmap.DynmapWorld;
|
||||||
@ -27,45 +28,105 @@ public class HDMapManager {
|
|||||||
public HashSet<HDMap> maps = new HashSet<HDMap>();
|
public HashSet<HDMap> maps = new HashSet<HDMap>();
|
||||||
public HashMap<String, ArrayList<HDMap>> maps_by_world_perspective = new HashMap<String, ArrayList<HDMap>>();
|
public HashMap<String, ArrayList<HDMap>> maps_by_world_perspective = new HashMap<String, ArrayList<HDMap>>();
|
||||||
|
|
||||||
public void loadHDShaders(ConfigurationNode shadercfg) {
|
public void loadHDShaders(Plugin plugin) {
|
||||||
Log.verboseinfo("Loading shaders...");
|
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.<HDShader>createInstances("shaders", new Class<?>[0], new Object[0])) {
|
for(HDShader shader : shadercfg.<HDShader>createInstances("shaders", new Class<?>[0], new Object[0])) {
|
||||||
if(shader.getName() == null) continue;
|
if(shader.getName() == null) continue;
|
||||||
if(shaders.containsKey(shader.getName())) {
|
shaders.put(shader.getName(), shader);
|
||||||
Log.severe("Duplicate shader name '" + shader.getName() + "' - shader ignored");
|
}
|
||||||
}
|
/* Load custom shaders, if file is defined - or create empty one if not */
|
||||||
else {
|
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.<HDShader>createInstances("shaders", new Class<?>[0], new Object[0])) {
|
||||||
|
if(shader.getName() == null) continue;
|
||||||
shaders.put(shader.getName(), shader);
|
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.");
|
Log.info("Loaded " + shaders.size() + " shaders.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadHDPerspectives(ConfigurationNode perspectivecfg) {
|
public void loadHDPerspectives(Plugin plugin) {
|
||||||
Log.verboseinfo("Loading perspectives...");
|
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.<HDPerspective>createInstances("perspectives", new Class<?>[0], new Object[0])) {
|
for(HDPerspective perspective : perspectivecfg.<HDPerspective>createInstances("perspectives", new Class<?>[0], new Object[0])) {
|
||||||
if(perspective.getName() == null) continue;
|
if(perspective.getName() == null) continue;
|
||||||
if(perspectives.containsKey(perspective.getName())) {
|
perspectives.put(perspective.getName(), perspective);
|
||||||
Log.severe("Duplicate perspective name '" + perspective.getName() + "' - perspective ignored");
|
}
|
||||||
}
|
/* Load custom perspectives, if file is defined - or create empty one if not */
|
||||||
else {
|
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.<HDPerspective>createInstances("perspectives", new Class<?>[0], new Object[0])) {
|
||||||
|
if(perspective.getName() == null) continue;
|
||||||
perspectives.put(perspective.getName(), perspective);
|
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.");
|
Log.info("Loaded " + perspectives.size() + " perspectives.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadHDLightings(ConfigurationNode lightingcfg) {
|
public void loadHDLightings(Plugin plugin) {
|
||||||
Log.verboseinfo("Loading lightings...");
|
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.<HDLighting>createInstances("lightings", new Class<?>[0], new Object[0])) {
|
for(HDLighting lighting : lightingcfg.<HDLighting>createInstances("lightings", new Class<?>[0], new Object[0])) {
|
||||||
if(lighting.getName() == null) continue;
|
if(lighting.getName() == null) continue;
|
||||||
if(lightings.containsKey(lighting.getName())) {
|
lightings.put(lighting.getName(), lighting);
|
||||||
Log.severe("Duplicate lighting name '" + lighting.getName() + "' - lighting ignored");
|
}
|
||||||
}
|
/* Load custom lightings, if file is defined - or create empty one if not */
|
||||||
else {
|
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.<HDLighting>createInstances("lightings", new Class<?>[0], new Object[0])) {
|
||||||
|
if(lighting.getName() == null) continue;
|
||||||
lightings.put(lighting.getName(), lighting);
|
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.");
|
Log.info("Loaded " + lightings.size() + " lightings.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user