mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 13:15:30 +01:00
More cleanup and refactoring - get ready to split out core
This commit is contained in:
parent
1f6eb62cc1
commit
eb35dbe1a6
@ -3,9 +3,9 @@ package org.dynmap;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.json.simple.JSONAware;
|
import org.json.simple.JSONAware;
|
||||||
import org.json.simple.JSONStreamAware;
|
import org.json.simple.JSONStreamAware;
|
||||||
|
import org.dynmap.common.DynmapChatColor;
|
||||||
|
|
||||||
public class Client {
|
public class Client {
|
||||||
public static class Update implements JSONAware, JSONStreamAware {
|
public static class Update implements JSONAware, JSONStreamAware {
|
||||||
@ -33,7 +33,7 @@ public class Client {
|
|||||||
public ChatMessage(String source, String channel, String playerName, String message, String playeraccount) {
|
public ChatMessage(String source, String channel, String playerName, String message, String playeraccount) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.playerName = Client.stripColor(playerName);
|
this.playerName = Client.stripColor(playerName);
|
||||||
this.message = ChatColor.stripColor(message);
|
this.message = DynmapChatColor.stripColor(message);
|
||||||
this.account = playeraccount;
|
this.account = playeraccount;
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ public class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String stripColor(String s) {
|
public static String stripColor(String s) {
|
||||||
s = ChatColor.stripColor(s); /* Strip standard color encoding */
|
s = DynmapChatColor.stripColor(s); /* Strip standard color encoding */
|
||||||
/* Handle Essentials nickname encoding too */
|
/* Handle Essentials nickname encoding too */
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
while((idx = s.indexOf('&', idx)) >= 0) {
|
while((idx = s.indexOf('&', idx)) >= 0) {
|
||||||
|
@ -7,8 +7,8 @@ import java.io.InputStream;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import org.dynmap.common.BiomeMap;
|
||||||
import org.dynmap.debug.Debug;
|
import org.dynmap.debug.Debug;
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
|
|
||||||
public class ColorScheme {
|
public class ColorScheme {
|
||||||
private static final HashMap<String, ColorScheme> cache = new HashMap<String, ColorScheme>();
|
private static final HashMap<String, ColorScheme> cache = new HashMap<String, ColorScheme>();
|
||||||
@ -58,7 +58,7 @@ public class ColorScheme {
|
|||||||
File colorSchemeFile = new File(getColorSchemeDirectory(core), name + ".txt");
|
File colorSchemeFile = new File(getColorSchemeDirectory(core), name + ".txt");
|
||||||
Color[][] colors = new Color[256][];
|
Color[][] colors = new Color[256][];
|
||||||
Color[][][] datacolors = new Color[256][][];
|
Color[][][] datacolors = new Color[256][][];
|
||||||
Color[][] biomecolors = new Color[Biome.values().length][];
|
Color[][] biomecolors = new Color[BiomeMap.values().length][];
|
||||||
Color[][] raincolors = new Color[64][];
|
Color[][] raincolors = new Color[64][];
|
||||||
Color[][] tempcolors = new Color[64][];
|
Color[][] tempcolors = new Color[64][];
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ public class ColorScheme {
|
|||||||
if(idx >= 0) bio = bio.substring(0, idx);
|
if(idx >= 0) bio = bio.substring(0, idx);
|
||||||
isbiome = true;
|
isbiome = true;
|
||||||
id = -1;
|
id = -1;
|
||||||
for(Biome b : Biome.values()) {
|
for(BiomeMap b : BiomeMap.values()) {
|
||||||
if(b.toString().equalsIgnoreCase(bio)) {
|
if(b.toString().equalsIgnoreCase(bio)) {
|
||||||
id = b.ordinal();
|
id = b.ordinal();
|
||||||
break;
|
break;
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
package org.dynmap;
|
package org.dynmap;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -8,19 +14,44 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||||
|
import org.yaml.snakeyaml.introspector.Property;
|
||||||
|
import org.yaml.snakeyaml.nodes.CollectionNode;
|
||||||
|
import org.yaml.snakeyaml.nodes.MappingNode;
|
||||||
|
import org.yaml.snakeyaml.nodes.Node;
|
||||||
|
import org.yaml.snakeyaml.nodes.NodeTuple;
|
||||||
|
import org.yaml.snakeyaml.nodes.SequenceNode;
|
||||||
|
import org.yaml.snakeyaml.nodes.Tag;
|
||||||
|
import org.yaml.snakeyaml.reader.UnicodeReader;
|
||||||
|
import org.yaml.snakeyaml.representer.Represent;
|
||||||
|
import org.yaml.snakeyaml.representer.Representer;
|
||||||
|
|
||||||
public class ConfigurationNode implements Map<String, Object> {
|
public class ConfigurationNode implements Map<String, Object> {
|
||||||
public Map<String, Object> entries;
|
public Map<String, Object> entries;
|
||||||
|
private File f;
|
||||||
|
private Yaml yaml;
|
||||||
|
|
||||||
public ConfigurationNode() {
|
public ConfigurationNode() {
|
||||||
entries = new HashMap<String, Object>();
|
entries = new HashMap<String, Object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigurationNode(org.bukkit.util.config.ConfigurationNode node) {
|
private void initparse() {
|
||||||
entries = new HashMap<String, Object>();
|
if(yaml == null) {
|
||||||
for(String key : node.getKeys(null)) {
|
DumperOptions options = new DumperOptions();
|
||||||
entries.put(key, node.getProperty(key));
|
|
||||||
|
options.setIndent(4);
|
||||||
|
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||||
|
|
||||||
|
yaml = new Yaml(new SafeConstructor(), new EmptyNullRepresenter(), options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public ConfigurationNode(File f) {
|
||||||
|
this.f = f;
|
||||||
|
entries = new HashMap<String, Object>();
|
||||||
|
}
|
||||||
|
|
||||||
public ConfigurationNode(Map<String, Object> map) {
|
public ConfigurationNode(Map<String, Object> map) {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
@ -29,6 +60,71 @@ public class ConfigurationNode implements Map<String, Object> {
|
|||||||
entries = map;
|
entries = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConfigurationNode(InputStream in) {
|
||||||
|
load(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean load(InputStream in) {
|
||||||
|
initparse();
|
||||||
|
|
||||||
|
Object o = yaml.load(new UnicodeReader(in));
|
||||||
|
if((o != null) && (o instanceof Map))
|
||||||
|
entries = (Map<String, Object>)o;
|
||||||
|
return (entries != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean load() {
|
||||||
|
initparse();
|
||||||
|
|
||||||
|
FileInputStream fis = null;
|
||||||
|
try {
|
||||||
|
fis = new FileInputStream(f);
|
||||||
|
Object o = yaml.load(new UnicodeReader(fis));
|
||||||
|
if((o != null) && (o instanceof Map))
|
||||||
|
entries = (Map<String, Object>)o;
|
||||||
|
fis.close();
|
||||||
|
} catch(IOException iox) {
|
||||||
|
Log.severe("Error reading " + f.getPath());
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
if(fis != null) {
|
||||||
|
try { fis.close(); } catch (IOException x) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (entries != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean save() {
|
||||||
|
return save(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean save(File file) {
|
||||||
|
initparse();
|
||||||
|
|
||||||
|
FileOutputStream stream = null;
|
||||||
|
|
||||||
|
File parent = file.getParentFile();
|
||||||
|
|
||||||
|
if (parent != null) {
|
||||||
|
parent.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
stream = new FileOutputStream(file);
|
||||||
|
OutputStreamWriter writer = new OutputStreamWriter(stream, "UTF-8");
|
||||||
|
yaml.dump(entries, writer);
|
||||||
|
return true;
|
||||||
|
} catch (IOException e) {
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (stream != null) {
|
||||||
|
stream.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Object getObject(String path) {
|
public Object getObject(String path) {
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
@ -134,6 +230,10 @@ public class ConfigurationNode implements Map<String, Object> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Map<String,Object>> getMapList(String path) {
|
||||||
|
return getList(path);
|
||||||
|
}
|
||||||
|
|
||||||
public ConfigurationNode getNode(String path) {
|
public ConfigurationNode getNode(String path) {
|
||||||
Map<String, Object> v = null;
|
Map<String, Object> v = null;
|
||||||
v = getGeneric(path, v);
|
v = getGeneric(path, v);
|
||||||
@ -282,4 +382,43 @@ public class ConfigurationNode implements Map<String, Object> {
|
|||||||
public Set<java.util.Map.Entry<String, Object>> entrySet() {
|
public Set<java.util.Map.Entry<String, Object>> entrySet() {
|
||||||
return entries.entrySet();
|
return entries.entrySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class EmptyNullRepresenter extends Representer {
|
||||||
|
|
||||||
|
public EmptyNullRepresenter() {
|
||||||
|
super();
|
||||||
|
this.nullRepresenter = new EmptyRepresentNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class EmptyRepresentNull implements Represent {
|
||||||
|
public Node representData(Object data) {
|
||||||
|
return representScalar(Tag.NULL, ""); // Changed "null" to "" so as to avoid writing nulls
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code borrowed from snakeyaml (http://code.google.com/p/snakeyaml/source/browse/src/test/java/org/yaml/snakeyaml/issues/issue60/SkipBeanTest.java)
|
||||||
|
@Override
|
||||||
|
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object propertyValue, Tag customTag) {
|
||||||
|
NodeTuple tuple = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
|
||||||
|
Node valueNode = tuple.getValueNode();
|
||||||
|
if (valueNode instanceof CollectionNode) {
|
||||||
|
// Removed null check
|
||||||
|
if (Tag.SEQ.equals(valueNode.getTag())) {
|
||||||
|
SequenceNode seq = (SequenceNode) valueNode;
|
||||||
|
if (seq.getValue().isEmpty()) {
|
||||||
|
return null; // skip empty lists
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Tag.MAP.equals(valueNode.getTag())) {
|
||||||
|
MappingNode seq = (MappingNode) valueNode;
|
||||||
|
if (seq.getValue().isEmpty()) {
|
||||||
|
return null; // skip empty maps
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tuple;
|
||||||
|
}
|
||||||
|
// End of borrowed code
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.dynmap.common.DynmapCommandSender;
|
import org.dynmap.common.DynmapCommandSender;
|
||||||
import org.dynmap.common.DynmapListenerManager;
|
import org.dynmap.common.DynmapListenerManager;
|
||||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||||
@ -37,16 +36,12 @@ import org.dynmap.web.FilterHandler;
|
|||||||
import org.dynmap.web.HandlerRouter;
|
import org.dynmap.web.HandlerRouter;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||||
import org.eclipse.jetty.servlet.FilterHolder;
|
|
||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
|
||||||
import org.eclipse.jetty.servlet.ServletHandler;
|
|
||||||
import org.eclipse.jetty.servlet.ServletHolder;
|
import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
import org.eclipse.jetty.util.resource.FileResource;
|
import org.eclipse.jetty.util.resource.FileResource;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import javax.servlet.*;
|
import javax.servlet.*;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
public class DynmapCore {
|
public class DynmapCore {
|
||||||
private DynmapServerInterface server;
|
private DynmapServerInterface server;
|
||||||
@ -206,9 +201,8 @@ public class DynmapCore {
|
|||||||
/* If matches naming convention */
|
/* If matches naming convention */
|
||||||
if(tname.endsWith(".txt") && (!tname.startsWith(CUSTOM_PREFIX))) {
|
if(tname.endsWith(".txt") && (!tname.startsWith(CUSTOM_PREFIX))) {
|
||||||
File tf = new File(templatedir, tname);
|
File tf = new File(templatedir, tname);
|
||||||
org.bukkit.util.config.Configuration cfg = new org.bukkit.util.config.Configuration(tf);
|
ConfigurationNode cn = new ConfigurationNode(tf);
|
||||||
cfg.load();
|
cn.load();
|
||||||
ConfigurationNode cn = new ConfigurationNode(cfg);
|
|
||||||
/* Supplement existing values (don't replace), since configuration.txt is more custom than these */
|
/* Supplement existing values (don't replace), since configuration.txt is more custom than these */
|
||||||
mergeConfigurationBranch(cn, "templates", false, false);
|
mergeConfigurationBranch(cn, "templates", false, false);
|
||||||
}
|
}
|
||||||
@ -218,9 +212,8 @@ public class DynmapCore {
|
|||||||
/* If matches naming convention */
|
/* If matches naming convention */
|
||||||
if(tname.endsWith(".txt") && tname.startsWith(CUSTOM_PREFIX)) {
|
if(tname.endsWith(".txt") && tname.startsWith(CUSTOM_PREFIX)) {
|
||||||
File tf = new File(templatedir, tname);
|
File tf = new File(templatedir, tname);
|
||||||
org.bukkit.util.config.Configuration cfg = new org.bukkit.util.config.Configuration(tf);
|
ConfigurationNode cn = new ConfigurationNode(tf);
|
||||||
cfg.load();
|
cn.load();
|
||||||
ConfigurationNode cn = new ConfigurationNode(cfg);
|
|
||||||
/* This are overrides - replace even configuration.txt content */
|
/* This are overrides - replace even configuration.txt content */
|
||||||
mergeConfigurationBranch(cn, "templates", true, false);
|
mergeConfigurationBranch(cn, "templates", true, false);
|
||||||
}
|
}
|
||||||
@ -241,9 +234,8 @@ public class DynmapCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Load configuration.txt */
|
/* Load configuration.txt */
|
||||||
org.bukkit.util.config.Configuration bukkitConfiguration = new org.bukkit.util.config.Configuration(f);
|
configuration = new ConfigurationNode(f);
|
||||||
bukkitConfiguration.load();
|
configuration.load();
|
||||||
configuration = new ConfigurationNode(bukkitConfiguration);
|
|
||||||
|
|
||||||
/* Add options to avoid 0.29 re-render (fixes very inconsistent with previous maps) */
|
/* Add options to avoid 0.29 re-render (fixes very inconsistent with previous maps) */
|
||||||
HDMapManager.usegeneratedtextures = configuration.getBoolean("use-generated-textures", false);
|
HDMapManager.usegeneratedtextures = configuration.getBoolean("use-generated-textures", false);
|
||||||
@ -260,9 +252,8 @@ public class DynmapCore {
|
|||||||
if(!createDefaultFileFromResource("/worlds.txt", f)) {
|
if(!createDefaultFileFromResource("/worlds.txt", f)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
org.bukkit.util.config.Configuration cfg = new org.bukkit.util.config.Configuration(f);
|
ConfigurationNode cn = new ConfigurationNode(f);
|
||||||
cfg.load();
|
cn.load();
|
||||||
ConfigurationNode cn = new ConfigurationNode(cfg);
|
|
||||||
mergeConfigurationBranch(cn, "worlds", true, true);
|
mergeConfigurationBranch(cn, "worlds", true, true);
|
||||||
|
|
||||||
/* Now, process templates */
|
/* Now, process templates */
|
||||||
@ -419,6 +410,8 @@ public class DynmapCore {
|
|||||||
|
|
||||||
public void loadWebserver() {
|
public void loadWebserver() {
|
||||||
webServer = new Server(new InetSocketAddress(configuration.getString("webserver-bindaddress", "0.0.0.0"), configuration.getInteger("webserver-port", 8123)));
|
webServer = new Server(new InetSocketAddress(configuration.getString("webserver-bindaddress", "0.0.0.0"), configuration.getInteger("webserver-port", 8123)));
|
||||||
|
webServer.setStopAtShutdown(true);
|
||||||
|
webServer.setGracefulShutdown(1000);
|
||||||
|
|
||||||
final boolean allow_symlinks = configuration.getBoolean("allow-symlinks", false);
|
final boolean allow_symlinks = configuration.getBoolean("allow-symlinks", false);
|
||||||
int maxconnections = configuration.getInteger("max-sessions", 30);
|
int maxconnections = configuration.getInteger("max-sessions", 30);
|
||||||
@ -498,6 +491,8 @@ public class DynmapCore {
|
|||||||
if (webServer != null) {
|
if (webServer != null) {
|
||||||
try {
|
try {
|
||||||
webServer.stop();
|
webServer.stop();
|
||||||
|
while(webServer.isStopping())
|
||||||
|
Thread.sleep(100);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.severe("Failed to stop WebServer!", e);
|
Log.severe("Failed to stop WebServer!", e);
|
||||||
}
|
}
|
||||||
@ -994,9 +989,10 @@ public class DynmapCore {
|
|||||||
return createDefaultFileFromResource(resourcename, deffile);
|
return createDefaultFileFromResource(resourcename, deffile);
|
||||||
}
|
}
|
||||||
/* Load default from resource */
|
/* Load default from resource */
|
||||||
YamlConfiguration def_fc = YamlConfiguration.loadConfiguration(in);
|
ConfigurationNode def_fc = new ConfigurationNode(in);
|
||||||
/* Load existing from file */
|
/* Load existing from file */
|
||||||
YamlConfiguration fc = YamlConfiguration.loadConfiguration(deffile);
|
ConfigurationNode fc = new ConfigurationNode(deffile);
|
||||||
|
fc.load();
|
||||||
/* Now, get the list associated with the base node default */
|
/* Now, get the list associated with the base node default */
|
||||||
List<Map<String,Object>> existing = fc.getMapList(basenode);
|
List<Map<String,Object>> existing = fc.getMapList(basenode);
|
||||||
Set<String> existing_names = new HashSet<String>();
|
Set<String> existing_names = new HashSet<String>();
|
||||||
@ -1025,13 +1021,8 @@ public class DynmapCore {
|
|||||||
}
|
}
|
||||||
/* If we did update, save existing */
|
/* If we did update, save existing */
|
||||||
if(did_update) {
|
if(did_update) {
|
||||||
try {
|
fc.put(basenode, existing);
|
||||||
fc.set(basenode, existing);
|
|
||||||
fc.save(deffile);
|
fc.save(deffile);
|
||||||
} catch (IOException iox) {
|
|
||||||
Log.severe("Error saving migrated file - " + deffile.getPath());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Log.info("Updated file " + deffile.getPath());
|
Log.info("Updated file " + deffile.getPath());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1118,13 +1109,12 @@ public class DynmapCore {
|
|||||||
File f = new File(getDataFolder(), "ids-by-ip.txt");
|
File f = new File(getDataFolder(), "ids-by-ip.txt");
|
||||||
if(f.exists() == false)
|
if(f.exists() == false)
|
||||||
return;
|
return;
|
||||||
YamlConfiguration fc = new YamlConfiguration();
|
ConfigurationNode fc = new ConfigurationNode(new File(getDataFolder(), "ids-by-ip.txt"));
|
||||||
try {
|
try {
|
||||||
fc.load(new File(getDataFolder(), "ids-by-ip.txt"));
|
fc.load();
|
||||||
ids_by_ip.clear();
|
ids_by_ip.clear();
|
||||||
Map<String,Object> v = fc.getValues(false);
|
for(String k : fc.keySet()) {
|
||||||
for(String k : v.keySet()) {
|
List<String> ids = fc.getList(k);
|
||||||
List<String> ids = fc.getStringList(k);
|
|
||||||
if(ids != null) {
|
if(ids != null) {
|
||||||
k = k.replace("_", ".");
|
k = k.replace("_", ".");
|
||||||
ids_by_ip.put(k, new LinkedList<String>(ids));
|
ids_by_ip.put(k, new LinkedList<String>(ids));
|
||||||
@ -1136,12 +1126,12 @@ public class DynmapCore {
|
|||||||
}
|
}
|
||||||
private void saveIDsByIP() {
|
private void saveIDsByIP() {
|
||||||
File f = new File(getDataFolder(), "ids-by-ip.txt");
|
File f = new File(getDataFolder(), "ids-by-ip.txt");
|
||||||
YamlConfiguration fc = new YamlConfiguration();
|
ConfigurationNode fc = new ConfigurationNode();
|
||||||
for(String k : ids_by_ip.keySet()) {
|
for(String k : ids_by_ip.keySet()) {
|
||||||
List<String> v = ids_by_ip.get(k);
|
List<String> v = ids_by_ip.get(k);
|
||||||
if(v != null) {
|
if(v != null) {
|
||||||
k = k.replace(".", "_");
|
k = k.replace(".", "_");
|
||||||
fc.set(k, v);
|
fc.put(k, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
package org.dynmap;
|
|
||||||
|
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerListener;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
public class DynmapPlayerChatListener extends PlayerListener {
|
|
||||||
DynmapCore plugin;
|
|
||||||
|
|
||||||
public DynmapPlayerChatListener(DynmapCore plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerChat(PlayerChatEvent event) {
|
|
||||||
if(event.isCancelled()) return;
|
|
||||||
if(plugin.mapManager != null)
|
|
||||||
plugin.mapManager.pushUpdate(new Client.ChatMessage("player", "",
|
|
||||||
event.getPlayer().getDisplayName(), event.getMessage(),
|
|
||||||
event.getPlayer().getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
if(plugin.mapManager != null)
|
|
||||||
plugin.mapManager.pushUpdate(new Client.PlayerJoinMessage(event.getPlayer().getDisplayName(), event.getPlayer().getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
if(plugin.mapManager != null)
|
|
||||||
plugin.mapManager.pushUpdate(new Client.PlayerQuitMessage(event.getPlayer().getDisplayName(), event.getPlayer().getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,16 +1,10 @@
|
|||||||
package org.dynmap;
|
package org.dynmap;
|
||||||
|
|
||||||
import static org.dynmap.JSONUtils.s;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.dynmap.bukkit.NewMapChunkCache;
|
|
||||||
import org.dynmap.debug.Debug;
|
import org.dynmap.debug.Debug;
|
||||||
import org.dynmap.utils.BlockLightLevel;
|
|
||||||
import org.dynmap.utils.DynmapBufferedImage;
|
import org.dynmap.utils.DynmapBufferedImage;
|
||||||
import org.dynmap.utils.FileLockManager;
|
import org.dynmap.utils.FileLockManager;
|
||||||
import org.dynmap.utils.MapChunkCache;
|
import org.dynmap.utils.MapChunkCache;
|
||||||
|
@ -24,12 +24,12 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||||||
|
|
||||||
import org.dynmap.DynmapCore.CompassMode;
|
import org.dynmap.DynmapCore.CompassMode;
|
||||||
import org.dynmap.DynmapWorld.AutoGenerateOption;
|
import org.dynmap.DynmapWorld.AutoGenerateOption;
|
||||||
|
import org.dynmap.bukkit.SnapshotCache;
|
||||||
import org.dynmap.common.DynmapCommandSender;
|
import org.dynmap.common.DynmapCommandSender;
|
||||||
import org.dynmap.common.DynmapPlayer;
|
import org.dynmap.common.DynmapPlayer;
|
||||||
import org.dynmap.debug.Debug;
|
import org.dynmap.debug.Debug;
|
||||||
import org.dynmap.hdmap.HDMapManager;
|
import org.dynmap.hdmap.HDMapManager;
|
||||||
import org.dynmap.utils.MapChunkCache;
|
import org.dynmap.utils.MapChunkCache;
|
||||||
import org.dynmap.utils.SnapshotCache;
|
|
||||||
import org.dynmap.utils.TileFlags;
|
import org.dynmap.utils.TileFlags;
|
||||||
|
|
||||||
public class MapManager {
|
public class MapManager {
|
||||||
@ -51,6 +51,8 @@ public class MapManager {
|
|||||||
private boolean pauseupdaterenders = false;
|
private boolean pauseupdaterenders = false;
|
||||||
private boolean pausefullrenders = false;
|
private boolean pausefullrenders = false;
|
||||||
|
|
||||||
|
private boolean did_start = false;
|
||||||
|
|
||||||
private int zoomout_period = DEFAULT_ZOOMOUT_PERIOD; /* Zoom-out tile processing period, in seconds */
|
private int zoomout_period = DEFAULT_ZOOMOUT_PERIOD; /* Zoom-out tile processing period, in seconds */
|
||||||
/* Which fullrenders are active */
|
/* Which fullrenders are active */
|
||||||
private HashMap<String, FullWorldRenderState> active_renders = new HashMap<String, FullWorldRenderState>();
|
private HashMap<String, FullWorldRenderState> active_renders = new HashMap<String, FullWorldRenderState>();
|
||||||
@ -975,9 +977,8 @@ public class MapManager {
|
|||||||
String wname = w.getName();
|
String wname = w.getName();
|
||||||
File f = new File(core.getDataFolder(), wname + ".pending");
|
File f = new File(core.getDataFolder(), wname + ".pending");
|
||||||
if(f.exists()) {
|
if(f.exists()) {
|
||||||
org.bukkit.util.config.Configuration saved = new org.bukkit.util.config.Configuration(f);
|
ConfigurationNode cn = new ConfigurationNode(f);
|
||||||
saved.load();
|
cn.load();
|
||||||
ConfigurationNode cn = new ConfigurationNode(saved);
|
|
||||||
/* Get the saved tile definitions */
|
/* Get the saved tile definitions */
|
||||||
List<ConfigurationNode> tiles = cn.getNodes("tiles");
|
List<ConfigurationNode> tiles = cn.getNodes("tiles");
|
||||||
if(tiles != null) {
|
if(tiles != null) {
|
||||||
@ -998,6 +999,9 @@ public class MapManager {
|
|||||||
try {
|
try {
|
||||||
FullWorldRenderState j = new FullWorldRenderState(job);
|
FullWorldRenderState j = new FullWorldRenderState(job);
|
||||||
active_renders.put(wname, j);
|
active_renders.put(wname, j);
|
||||||
|
if(did_start) /* Past initial start */
|
||||||
|
scheduleDelayedJob(j, 5000);
|
||||||
|
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
Log.info("Unable to restore render job for world '" + wname + "' - map configuration changed");
|
Log.info("Unable to restore render job for world '" + wname + "' - map configuration changed");
|
||||||
}
|
}
|
||||||
@ -1012,7 +1016,7 @@ public class MapManager {
|
|||||||
for(DynmapWorld w : worlds) {
|
for(DynmapWorld w : worlds) {
|
||||||
boolean dosave = false;
|
boolean dosave = false;
|
||||||
File f = new File(core.getDataFolder(), w.getName() + ".pending");
|
File f = new File(core.getDataFolder(), w.getName() + ".pending");
|
||||||
org.bukkit.util.config.Configuration saved = new org.bukkit.util.config.Configuration(f);
|
ConfigurationNode saved = new ConfigurationNode();
|
||||||
ArrayList<ConfigurationNode> savedtiles = new ArrayList<ConfigurationNode>();
|
ArrayList<ConfigurationNode> savedtiles = new ArrayList<ConfigurationNode>();
|
||||||
for(MapTile tile : mt) {
|
for(MapTile tile : mt) {
|
||||||
if(tile.getDynmapWorld() != w) continue;
|
if(tile.getDynmapWorld() != w) continue;
|
||||||
@ -1022,18 +1026,18 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(savedtiles.size() > 0) { /* Something to save? */
|
if(savedtiles.size() > 0) { /* Something to save? */
|
||||||
saved.setProperty("tiles", savedtiles);
|
saved.put("tiles", savedtiles);
|
||||||
dosave = true;
|
dosave = true;
|
||||||
Log.info("Saved " + savedtiles.size() + " pending tile renders in world '" + w.getName());
|
Log.info("Saved " + savedtiles.size() + " pending tile renders in world '" + w.getName());
|
||||||
}
|
}
|
||||||
FullWorldRenderState job = active_renders.get(w.getName());
|
FullWorldRenderState job = active_renders.get(w.getName());
|
||||||
if(job != null) {
|
if(job != null) {
|
||||||
saved.setProperty("job", job.saveState());
|
saved.put("job", job.saveState());
|
||||||
dosave = true;
|
dosave = true;
|
||||||
Log.info("Saved active render job in world '" + w.getName());
|
Log.info("Saved active render job in world '" + w.getName());
|
||||||
}
|
}
|
||||||
if(dosave) {
|
if(dosave) {
|
||||||
saved.save();
|
saved.save(f);
|
||||||
Log.info("Saved " + savedtiles.size() + " pending tile renders in world '" + w.getName());
|
Log.info("Saved " + savedtiles.size() + " pending tile renders in world '" + w.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1091,6 +1095,7 @@ public class MapManager {
|
|||||||
scheduleDelayedJob(job, 5000);
|
scheduleDelayedJob(job, 5000);
|
||||||
Log.info("Resumed render starting on world '" + job.world.getName() + "'...");
|
Log.info("Resumed render starting on world '" + job.world.getName() + "'...");
|
||||||
}
|
}
|
||||||
|
did_start = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopRendering() {
|
public void stopRendering() {
|
||||||
@ -1112,6 +1117,7 @@ public class MapManager {
|
|||||||
sscache.cleanup();
|
sscache.cleanup();
|
||||||
sscache = null;
|
sscache = null;
|
||||||
}
|
}
|
||||||
|
did_start = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getTileFile(MapTile tile) {
|
public File getTileFile(MapTile tile) {
|
||||||
|
@ -2,10 +2,6 @@ package org.dynmap;
|
|||||||
|
|
||||||
import static org.dynmap.JSONUtils.s;
|
import static org.dynmap.JSONUtils.s;
|
||||||
|
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerListener;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.dynmap.common.DynmapListenerManager;
|
import org.dynmap.common.DynmapListenerManager;
|
||||||
import org.dynmap.common.DynmapListenerManager.ChatEventListener;
|
import org.dynmap.common.DynmapListenerManager.ChatEventListener;
|
||||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.dynmap.utils;
|
package org.dynmap.bukkit;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
@ -9,7 +9,6 @@ import org.bukkit.World;
|
|||||||
import org.dynmap.DynmapChunk;
|
import org.dynmap.DynmapChunk;
|
||||||
import org.dynmap.DynmapLocation;
|
import org.dynmap.DynmapLocation;
|
||||||
import org.dynmap.DynmapWorld;
|
import org.dynmap.DynmapWorld;
|
||||||
import org.dynmap.utils.BlockLightLevel;
|
|
||||||
import org.dynmap.utils.MapChunkCache;
|
import org.dynmap.utils.MapChunkCache;
|
||||||
|
|
||||||
public class BukkitWorld extends DynmapWorld {
|
public class BukkitWorld extends DynmapWorld {
|
||||||
@ -88,7 +87,11 @@ public class BukkitWorld extends DynmapWorld {
|
|||||||
@Override
|
@Override
|
||||||
public MapChunkCache getChunkCache(List<DynmapChunk> chunks) {
|
public MapChunkCache getChunkCache(List<DynmapChunk> chunks) {
|
||||||
MapChunkCache c = new NewMapChunkCache();
|
MapChunkCache c = new NewMapChunkCache();
|
||||||
c.setChunks(world, chunks);
|
c.setChunks(this, chunks);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,15 +57,16 @@ import org.dynmap.DynmapWebChatEvent;
|
|||||||
import org.dynmap.DynmapWorld;
|
import org.dynmap.DynmapWorld;
|
||||||
import org.dynmap.Log;
|
import org.dynmap.Log;
|
||||||
import org.dynmap.MapManager;
|
import org.dynmap.MapManager;
|
||||||
|
import org.dynmap.bukkit.permissions.BukkitPermissions;
|
||||||
|
import org.dynmap.bukkit.permissions.NijikokunPermissions;
|
||||||
|
import org.dynmap.bukkit.permissions.OpPermissions;
|
||||||
|
import org.dynmap.bukkit.permissions.PermissionProvider;
|
||||||
|
import org.dynmap.common.BiomeMap;
|
||||||
import org.dynmap.common.DynmapCommandSender;
|
import org.dynmap.common.DynmapCommandSender;
|
||||||
import org.dynmap.common.DynmapPlayer;
|
import org.dynmap.common.DynmapPlayer;
|
||||||
import org.dynmap.common.DynmapServerInterface;
|
import org.dynmap.common.DynmapServerInterface;
|
||||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||||
import org.dynmap.markers.MarkerAPI;
|
import org.dynmap.markers.MarkerAPI;
|
||||||
import org.dynmap.permissions.BukkitPermissions;
|
|
||||||
import org.dynmap.permissions.NijikokunPermissions;
|
|
||||||
import org.dynmap.permissions.OpPermissions;
|
|
||||||
import org.dynmap.permissions.PermissionProvider;
|
|
||||||
|
|
||||||
public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||||
private DynmapCore core;
|
private DynmapCore core;
|
||||||
@ -217,6 +218,15 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||||||
public void broadcastMessage(String msg) {
|
public void broadcastMessage(String msg) {
|
||||||
getServer().broadcastMessage(msg);
|
getServer().broadcastMessage(msg);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public String[] getBiomeIDs() {
|
||||||
|
BiomeMap[] b = BiomeMap.values();
|
||||||
|
String[] bname = new String[b.length];
|
||||||
|
for(int i = 0; i < bname.length; i++)
|
||||||
|
bname[i] = b[i].toString();
|
||||||
|
return bname;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Player access abstraction class
|
* Player access abstraction class
|
||||||
|
@ -18,10 +18,9 @@ import org.dynmap.DynmapCore;
|
|||||||
import org.dynmap.DynmapWorld;
|
import org.dynmap.DynmapWorld;
|
||||||
import org.dynmap.Log;
|
import org.dynmap.Log;
|
||||||
import org.dynmap.MapManager;
|
import org.dynmap.MapManager;
|
||||||
|
import org.dynmap.common.BiomeMap;
|
||||||
import org.dynmap.utils.MapChunkCache;
|
import org.dynmap.utils.MapChunkCache;
|
||||||
import org.dynmap.utils.MapIterator;
|
import org.dynmap.utils.MapIterator;
|
||||||
import org.dynmap.utils.MapChunkCache.HiddenChunkStyle;
|
|
||||||
import org.dynmap.utils.MapChunkCache.VisibilityLimit;
|
|
||||||
import org.dynmap.utils.MapIterator.BlockStep;
|
import org.dynmap.utils.MapIterator.BlockStep;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,6 +40,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
|||||||
private static final int MAX_TICKLIST = 20000;
|
private static final int MAX_TICKLIST = 20000;
|
||||||
|
|
||||||
private World w;
|
private World w;
|
||||||
|
private DynmapWorld dw;
|
||||||
private Object craftworld;
|
private Object craftworld;
|
||||||
private List<DynmapChunk> chunks;
|
private List<DynmapChunk> chunks;
|
||||||
private ListIterator<DynmapChunk> iterator;
|
private ListIterator<DynmapChunk> iterator;
|
||||||
@ -54,7 +54,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
|||||||
private boolean do_save = false;
|
private boolean do_save = false;
|
||||||
private boolean isempty = true;
|
private boolean isempty = true;
|
||||||
private ChunkSnapshot[] snaparray; /* Index = (x-x_min) + ((z-z_min)*x_dim) */
|
private ChunkSnapshot[] snaparray; /* Index = (x-x_min) + ((z-z_min)*x_dim) */
|
||||||
private Biome[][] snapbiomes; /* Biome cache - getBiome() is expensive */
|
private BiomeMap[][] snapbiomes; /* Biome cache - getBiome() is expensive */
|
||||||
private TreeSet<?> ourticklist;
|
private TreeSet<?> ourticklist;
|
||||||
|
|
||||||
private int chunks_read; /* Number of chunks actually loaded */
|
private int chunks_read; /* Number of chunks actually loaded */
|
||||||
@ -66,6 +66,8 @@ public class NewMapChunkCache implements MapChunkCache {
|
|||||||
private static final BlockStep unstep[] = { BlockStep.X_MINUS, BlockStep.Y_MINUS, BlockStep.Z_MINUS,
|
private static final BlockStep unstep[] = { BlockStep.X_MINUS, BlockStep.Y_MINUS, BlockStep.Z_MINUS,
|
||||||
BlockStep.X_PLUS, BlockStep.Y_PLUS, BlockStep.Z_PLUS };
|
BlockStep.X_PLUS, BlockStep.Y_PLUS, BlockStep.Z_PLUS };
|
||||||
|
|
||||||
|
private static BiomeMap[] biome_to_bmap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterator for traversing map chunk cache (base is for non-snapshot)
|
* Iterator for traversing map chunk cache (base is for non-snapshot)
|
||||||
*/
|
*/
|
||||||
@ -114,15 +116,17 @@ public class NewMapChunkCache implements MapChunkCache {
|
|||||||
public final int getBlockEmittedLight() {
|
public final int getBlockEmittedLight() {
|
||||||
return snap.getBlockEmittedLight(bx, y, bz);
|
return snap.getBlockEmittedLight(bx, y, bz);
|
||||||
}
|
}
|
||||||
public final Biome getBiome() {
|
public final BiomeMap getBiome() {
|
||||||
Biome[] b = snapbiomes[chunkindex];
|
BiomeMap[] b = snapbiomes[chunkindex];
|
||||||
if(b == null) {
|
if(b == null) {
|
||||||
b = snapbiomes[chunkindex] = new Biome[256];
|
b = snapbiomes[chunkindex] = new BiomeMap[256];
|
||||||
}
|
}
|
||||||
int off = bx + (bz << 4);
|
int off = bx + (bz << 4);
|
||||||
Biome bio = b[off];
|
BiomeMap bio = b[off];
|
||||||
if(bio == null) {
|
if(bio == null) {
|
||||||
bio = b[off] = snap.getBiome(bx, bz);
|
Biome bb = snap.getBiome(bx, bz);
|
||||||
|
if(bb != null)
|
||||||
|
bio = b[off] = biome_to_bmap[bb.ordinal()];
|
||||||
}
|
}
|
||||||
return bio;
|
return bio;
|
||||||
}
|
}
|
||||||
@ -403,8 +407,9 @@ public class NewMapChunkCache implements MapChunkCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@SuppressWarnings({ "rawtypes" })
|
@SuppressWarnings({ "rawtypes" })
|
||||||
public void setChunks(World w, List<DynmapChunk> chunks) {
|
public void setChunks(DynmapWorld dw, List<DynmapChunk> chunks) {
|
||||||
this.w = w;
|
this.dw = dw;
|
||||||
|
this.w = ((BukkitWorld)dw).getWorld();
|
||||||
if((getworldhandle != null) && (craftworld == null)) {
|
if((getworldhandle != null) && (craftworld == null)) {
|
||||||
try {
|
try {
|
||||||
craftworld = getworldhandle.invoke(w); /* World.getHandle() */
|
craftworld = getworldhandle.invoke(w); /* World.getHandle() */
|
||||||
@ -439,7 +444,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
snaparray = new ChunkSnapshot[x_dim * (z_max-z_min+1)];
|
snaparray = new ChunkSnapshot[x_dim * (z_max-z_min+1)];
|
||||||
snapbiomes = new Biome[x_dim * (z_max-z_min+1)][];
|
snapbiomes = new BiomeMap[x_dim * (z_max-z_min+1)][];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int loadChunks(int max_to_load) {
|
public int loadChunks(int max_to_load) {
|
||||||
@ -634,9 +639,10 @@ public class NewMapChunkCache implements MapChunkCache {
|
|||||||
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||||
return ss.getBlockEmittedLight(x & 0xF, y, z & 0xF);
|
return ss.getBlockEmittedLight(x & 0xF, y, z & 0xF);
|
||||||
}
|
}
|
||||||
public Biome getBiome(int x, int z) {
|
public BiomeMap getBiome(int x, int z) {
|
||||||
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||||
return ss.getBiome(x & 0xF, z & 0xF);
|
Biome b = ss.getBiome(x & 0xF, z & 0xF);
|
||||||
|
return (b != null)?biome_to_bmap[b.ordinal()]:null;
|
||||||
}
|
}
|
||||||
public double getRawBiomeTemperature(int x, int z) {
|
public double getRawBiomeTemperature(int x, int z) {
|
||||||
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
ChunkSnapshot ss = snaparray[((x>>4) - x_min) + ((z>>4) - z_min) * x_dim];
|
||||||
@ -727,8 +733,8 @@ public class NewMapChunkCache implements MapChunkCache {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public World getWorld() {
|
public DynmapWorld getWorld() {
|
||||||
return w;
|
return dw;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getChunksLoaded() {
|
public int getChunksLoaded() {
|
||||||
@ -767,4 +773,31 @@ public class NewMapChunkCache implements MapChunkCache {
|
|||||||
}
|
}
|
||||||
return isok;
|
return isok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
Biome[] b = Biome.values();
|
||||||
|
biome_to_bmap = new BiomeMap[b.length];
|
||||||
|
biome_to_bmap[Biome.RAINFOREST.ordinal()] = BiomeMap.RAINFOREST;
|
||||||
|
biome_to_bmap[Biome.SWAMPLAND.ordinal()] = BiomeMap.SWAMPLAND;
|
||||||
|
biome_to_bmap[Biome.SEASONAL_FOREST.ordinal()] = BiomeMap.SEASONAL_FOREST;
|
||||||
|
biome_to_bmap[Biome.FOREST.ordinal()] = BiomeMap.FOREST;
|
||||||
|
biome_to_bmap[Biome.SAVANNA.ordinal()] = BiomeMap.SAVANNA;
|
||||||
|
biome_to_bmap[Biome.SHRUBLAND.ordinal()] = BiomeMap.SHRUBLAND;
|
||||||
|
biome_to_bmap[Biome.TAIGA.ordinal()] = BiomeMap.TAIGA;
|
||||||
|
biome_to_bmap[Biome.DESERT.ordinal()] = BiomeMap.DESERT;
|
||||||
|
biome_to_bmap[Biome.PLAINS.ordinal()] = BiomeMap.PLAINS;
|
||||||
|
biome_to_bmap[Biome.ICE_DESERT.ordinal()] = BiomeMap.ICE_DESERT;
|
||||||
|
biome_to_bmap[Biome.TUNDRA.ordinal()] = BiomeMap.TUNDRA;
|
||||||
|
biome_to_bmap[Biome.HELL.ordinal()] = BiomeMap.HELL;
|
||||||
|
biome_to_bmap[Biome.SKY.ordinal()] = BiomeMap.SKY;
|
||||||
|
biome_to_bmap[Biome.OCEAN.ordinal()] = BiomeMap.OCEAN;
|
||||||
|
biome_to_bmap[Biome.RIVER.ordinal()] = BiomeMap.RIVER;
|
||||||
|
biome_to_bmap[Biome.EXTREME_HILLS.ordinal()] = BiomeMap.EXTREME_HILLS;
|
||||||
|
biome_to_bmap[Biome.FROZEN_OCEAN.ordinal()] = BiomeMap.FROZEN_OCEAN;
|
||||||
|
biome_to_bmap[Biome.FROZEN_RIVER.ordinal()] = BiomeMap.FROZEN_RIVER;
|
||||||
|
biome_to_bmap[Biome.ICE_PLAINS.ordinal()] = BiomeMap.ICE_PLAINS;
|
||||||
|
biome_to_bmap[Biome.ICE_MOUNTAINS.ordinal()] = BiomeMap.ICE_MOUNTAINS;
|
||||||
|
biome_to_bmap[Biome.MUSHROOM_ISLAND.ordinal()] = BiomeMap.MUSHROOM_ISLAND;
|
||||||
|
biome_to_bmap[Biome.MUSHROOM_SHORE.ordinal()] = BiomeMap.MUSHROOM_SHORE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.dynmap.utils;
|
package org.dynmap.bukkit;
|
||||||
|
|
||||||
import java.lang.ref.Reference;
|
import java.lang.ref.Reference;
|
||||||
import java.lang.ref.ReferenceQueue;
|
import java.lang.ref.ReferenceQueue;
|
@ -1,4 +1,4 @@
|
|||||||
package org.dynmap.permissions;
|
package org.dynmap.bukkit.permissions;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
@ -1,4 +1,4 @@
|
|||||||
package org.dynmap.permissions;
|
package org.dynmap.bukkit.permissions;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
@ -1,4 +1,4 @@
|
|||||||
package org.dynmap.permissions;
|
package org.dynmap.bukkit.permissions;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.dynmap.permissions;
|
package org.dynmap.bukkit.permissions;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
27
src/main/java/org/dynmap/common/BiomeMap.java
Normal file
27
src/main/java/org/dynmap/common/BiomeMap.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package org.dynmap.common;
|
||||||
|
|
||||||
|
/* Generic biome mapping */
|
||||||
|
public enum BiomeMap {
|
||||||
|
RAINFOREST,
|
||||||
|
SWAMPLAND,
|
||||||
|
SEASONAL_FOREST,
|
||||||
|
FOREST,
|
||||||
|
SAVANNA,
|
||||||
|
SHRUBLAND,
|
||||||
|
TAIGA,
|
||||||
|
DESERT,
|
||||||
|
PLAINS,
|
||||||
|
ICE_DESERT,
|
||||||
|
TUNDRA,
|
||||||
|
HELL,
|
||||||
|
SKY,
|
||||||
|
OCEAN,
|
||||||
|
RIVER,
|
||||||
|
EXTREME_HILLS,
|
||||||
|
FROZEN_OCEAN,
|
||||||
|
FROZEN_RIVER,
|
||||||
|
ICE_PLAINS,
|
||||||
|
ICE_MOUNTAINS,
|
||||||
|
MUSHROOM_ISLAND,
|
||||||
|
MUSHROOM_SHORE
|
||||||
|
}
|
@ -1,9 +1,5 @@
|
|||||||
package org.dynmap.common;
|
package org.dynmap.common;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public enum DynmapChatColor {
|
public enum DynmapChatColor {
|
||||||
BLACK(0x0),
|
BLACK(0x0),
|
||||||
@ -34,4 +30,10 @@ public enum DynmapChatColor {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
public static String stripColor(final String input) {
|
||||||
|
if (input == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return input.replaceAll("(?i)\u00A7[0-9A-F]", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package org.dynmap.common;
|
|||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.dynmap.DynmapLocation;
|
import org.dynmap.DynmapLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,4 +72,8 @@ public interface DynmapServerInterface {
|
|||||||
* @param msg
|
* @param msg
|
||||||
*/
|
*/
|
||||||
public void broadcastMessage(String msg);
|
public void broadcastMessage(String msg);
|
||||||
|
/**
|
||||||
|
* Get Biome ID list
|
||||||
|
*/
|
||||||
|
public String[] getBiomeIDs();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package org.dynmap.debug;
|
package org.dynmap.debug;
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.dynmap.ConfigurationNode;
|
import org.dynmap.ConfigurationNode;
|
||||||
|
import org.dynmap.DynmapCore;
|
||||||
import org.dynmap.Log;
|
import org.dynmap.Log;
|
||||||
|
|
||||||
public class LogDebugger implements Debugger {
|
public class LogDebugger implements Debugger {
|
||||||
public LogDebugger(JavaPlugin plugin, ConfigurationNode configuration) {
|
public LogDebugger(DynmapCore core, ConfigurationNode configuration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package org.dynmap.debug;
|
package org.dynmap.debug;
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.dynmap.ConfigurationNode;
|
import org.dynmap.ConfigurationNode;
|
||||||
|
import org.dynmap.DynmapCore;
|
||||||
|
|
||||||
public class NullDebugger implements Debugger {
|
public class NullDebugger implements Debugger {
|
||||||
public static final NullDebugger instance = new NullDebugger(null, null);
|
public static final NullDebugger instance = new NullDebugger(null, null);
|
||||||
|
|
||||||
public NullDebugger(JavaPlugin plugin, ConfigurationNode configuration) {
|
public NullDebugger(DynmapCore core, ConfigurationNode configuration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug(String message) {
|
public void debug(String message) {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package org.dynmap.hdmap;
|
package org.dynmap.hdmap;
|
||||||
|
|
||||||
import static org.dynmap.JSONUtils.s;
|
import static org.dynmap.JSONUtils.s;
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.dynmap.Color;
|
import org.dynmap.Color;
|
||||||
import org.dynmap.ColorScheme;
|
import org.dynmap.ColorScheme;
|
||||||
import org.dynmap.ConfigurationNode;
|
import org.dynmap.ConfigurationNode;
|
||||||
import org.dynmap.DynmapCore;
|
import org.dynmap.DynmapCore;
|
||||||
|
import org.dynmap.common.BiomeMap;
|
||||||
import org.dynmap.utils.MapChunkCache;
|
import org.dynmap.utils.MapChunkCache;
|
||||||
import org.dynmap.utils.MapIterator;
|
import org.dynmap.utils.MapIterator;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
@ -225,7 +225,7 @@ public class DefaultHDShader implements HDShader {
|
|||||||
super(mapiter, map);
|
super(mapiter, map);
|
||||||
}
|
}
|
||||||
protected Color[] getBlockColors(int blocktype, int blockdata) {
|
protected Color[] getBlockColors(int blocktype, int blockdata) {
|
||||||
Biome bio = mapiter.getBiome();
|
BiomeMap bio = mapiter.getBiome();
|
||||||
if(bio != null)
|
if(bio != null)
|
||||||
return colorScheme.biomecolors[bio.ordinal()];
|
return colorScheme.biomecolors[bio.ordinal()];
|
||||||
return null;
|
return null;
|
||||||
|
@ -11,7 +11,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.dynmap.ConfigurationNode;
|
import org.dynmap.ConfigurationNode;
|
||||||
import org.dynmap.Log;
|
import org.dynmap.Log;
|
||||||
|
|
||||||
@ -43,26 +42,6 @@ public class HDBlockModels {
|
|||||||
|
|
||||||
private static HashMap<Integer, HDScaledBlockModels> scaled_models_by_scale = new HashMap<Integer, HDScaledBlockModels>();
|
private static HashMap<Integer, HDScaledBlockModels> scaled_models_by_scale = new HashMap<Integer, HDScaledBlockModels>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Block definition - copy from other
|
|
||||||
*/
|
|
||||||
public HDBlockModels(Material blocktype, int databits, HDBlockModels m) {
|
|
||||||
this.blockid = blocktype.getId();
|
|
||||||
this.databits = databits;
|
|
||||||
this.nativeres = m.nativeres;
|
|
||||||
this.blockflags = m.blockflags;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Block definition - positions correspond to Bukkit coordinates (+X is south, +Y is up, +Z is west)
|
|
||||||
* @param blockid - block ID
|
|
||||||
* @param databits - bitmap of block data bits matching this model (bit N is set if data=N would match)
|
|
||||||
* @param nativeres - native subblocks per edge of cube (up to 64)
|
|
||||||
* @param blockflags - array of native^2 long integers representing volume of block (bit X of element (nativeres*Y+Z) is set if that subblock is filled)
|
|
||||||
* if array is short, other elements area are assumed to be zero (fills from bottom of block up)
|
|
||||||
*/
|
|
||||||
public HDBlockModels(Material blocktype, int databits, int nativeres, long[] blockflags) {
|
|
||||||
this(blocktype.getId(), databits, nativeres, blockflags);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Block definition - positions correspond to Bukkit coordinates (+X is south, +Y is up, +Z is west)
|
* Block definition - positions correspond to Bukkit coordinates (+X is south, +Y is up, +Z is west)
|
||||||
* @param blockid - block ID
|
* @param blockid - block ID
|
||||||
|
@ -32,9 +32,8 @@ public class HDMapManager {
|
|||||||
if(!core.updateUsingDefaultResource("/shaders.txt", f, "shaders")) {
|
if(!core.updateUsingDefaultResource("/shaders.txt", f, "shaders")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
org.bukkit.util.config.Configuration bukkitShaderConfig = new org.bukkit.util.config.Configuration(f);
|
ConfigurationNode shadercfg = new ConfigurationNode(f);
|
||||||
bukkitShaderConfig.load();
|
shadercfg.load();
|
||||||
ConfigurationNode shadercfg = new ConfigurationNode(bukkitShaderConfig);
|
|
||||||
|
|
||||||
for(HDShader shader : shadercfg.<HDShader>createInstances("shaders", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
for(HDShader shader : shadercfg.<HDShader>createInstances("shaders", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||||
if(shader.getName() == null) continue;
|
if(shader.getName() == null) continue;
|
||||||
@ -44,9 +43,8 @@ public class HDMapManager {
|
|||||||
f = new File(core.getDataFolder(), "custom-shaders.txt");
|
f = new File(core.getDataFolder(), "custom-shaders.txt");
|
||||||
core.createDefaultFileFromResource("/custom-shaders.txt", f);
|
core.createDefaultFileFromResource("/custom-shaders.txt", f);
|
||||||
if(f.exists()) {
|
if(f.exists()) {
|
||||||
bukkitShaderConfig = new org.bukkit.util.config.Configuration(f);
|
ConfigurationNode customshadercfg = new ConfigurationNode(f);
|
||||||
bukkitShaderConfig.load();
|
customshadercfg.load();
|
||||||
ConfigurationNode customshadercfg = new ConfigurationNode(bukkitShaderConfig);
|
|
||||||
for(HDShader shader : customshadercfg.<HDShader>createInstances("shaders", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
for(HDShader shader : customshadercfg.<HDShader>createInstances("shaders", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||||
if(shader.getName() == null) continue;
|
if(shader.getName() == null) continue;
|
||||||
shaders.put(shader.getName(), shader);
|
shaders.put(shader.getName(), shader);
|
||||||
@ -63,9 +61,8 @@ public class HDMapManager {
|
|||||||
if(!core.updateUsingDefaultResource("/perspectives.txt", f, "perspectives")) {
|
if(!core.updateUsingDefaultResource("/perspectives.txt", f, "perspectives")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
org.bukkit.util.config.Configuration bukkitPerspectiveConfig = new org.bukkit.util.config.Configuration(f);
|
ConfigurationNode perspectivecfg = new ConfigurationNode(f);
|
||||||
bukkitPerspectiveConfig.load();
|
perspectivecfg.load();
|
||||||
ConfigurationNode perspectivecfg = new ConfigurationNode(bukkitPerspectiveConfig);
|
|
||||||
for(HDPerspective perspective : perspectivecfg.<HDPerspective>createInstances("perspectives", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
for(HDPerspective perspective : perspectivecfg.<HDPerspective>createInstances("perspectives", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||||
if(perspective.getName() == null) continue;
|
if(perspective.getName() == null) continue;
|
||||||
perspectives.put(perspective.getName(), perspective);
|
perspectives.put(perspective.getName(), perspective);
|
||||||
@ -74,9 +71,8 @@ public class HDMapManager {
|
|||||||
f = new File(core.getDataFolder(), "custom-perspectives.txt");
|
f = new File(core.getDataFolder(), "custom-perspectives.txt");
|
||||||
core.createDefaultFileFromResource("/custom-perspectives.txt", f);
|
core.createDefaultFileFromResource("/custom-perspectives.txt", f);
|
||||||
if(f.exists()) {
|
if(f.exists()) {
|
||||||
bukkitPerspectiveConfig = new org.bukkit.util.config.Configuration(f);
|
perspectivecfg = new ConfigurationNode(f);
|
||||||
bukkitPerspectiveConfig.load();
|
perspectivecfg.load();
|
||||||
perspectivecfg = new ConfigurationNode(bukkitPerspectiveConfig);
|
|
||||||
for(HDPerspective perspective : perspectivecfg.<HDPerspective>createInstances("perspectives", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
for(HDPerspective perspective : perspectivecfg.<HDPerspective>createInstances("perspectives", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||||
if(perspective.getName() == null) continue;
|
if(perspective.getName() == null) continue;
|
||||||
perspectives.put(perspective.getName(), perspective);
|
perspectives.put(perspective.getName(), perspective);
|
||||||
@ -91,9 +87,8 @@ public class HDMapManager {
|
|||||||
if(!core.updateUsingDefaultResource("/lightings.txt", f, "lightings")) {
|
if(!core.updateUsingDefaultResource("/lightings.txt", f, "lightings")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
org.bukkit.util.config.Configuration bukkitLightingsConfig = new org.bukkit.util.config.Configuration(f);
|
ConfigurationNode lightingcfg = new ConfigurationNode(f);
|
||||||
bukkitLightingsConfig.load();
|
lightingcfg.load();
|
||||||
ConfigurationNode lightingcfg = new ConfigurationNode(bukkitLightingsConfig);
|
|
||||||
|
|
||||||
for(HDLighting lighting : lightingcfg.<HDLighting>createInstances("lightings", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
for(HDLighting lighting : lightingcfg.<HDLighting>createInstances("lightings", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||||
if(lighting.getName() == null) continue;
|
if(lighting.getName() == null) continue;
|
||||||
@ -103,9 +98,8 @@ public class HDMapManager {
|
|||||||
f = new File(core.getDataFolder(), "custom-lightings.txt");
|
f = new File(core.getDataFolder(), "custom-lightings.txt");
|
||||||
core.createDefaultFileFromResource("/custom-lightings.txt", f);
|
core.createDefaultFileFromResource("/custom-lightings.txt", f);
|
||||||
if(f.exists()) {
|
if(f.exists()) {
|
||||||
bukkitLightingsConfig = new org.bukkit.util.config.Configuration(f);
|
lightingcfg = new ConfigurationNode(f);
|
||||||
bukkitLightingsConfig.load();
|
lightingcfg.load();
|
||||||
lightingcfg = new ConfigurationNode(bukkitLightingsConfig);
|
|
||||||
for(HDLighting lighting : lightingcfg.<HDLighting>createInstances("lightings", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
for(HDLighting lighting : lightingcfg.<HDLighting>createInstances("lightings", new Class<?>[] { DynmapCore.class }, new Object[] { core })) {
|
||||||
if(lighting.getName() == null) continue;
|
if(lighting.getName() == null) continue;
|
||||||
lightings.put(lighting.getName(), lighting);
|
lightings.put(lighting.getName(), lighting);
|
||||||
|
@ -19,12 +19,12 @@ import java.util.zip.ZipFile;
|
|||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.dynmap.Color;
|
import org.dynmap.Color;
|
||||||
import org.dynmap.ConfigurationNode;
|
import org.dynmap.ConfigurationNode;
|
||||||
import org.dynmap.DynmapCore;
|
import org.dynmap.DynmapCore;
|
||||||
import org.dynmap.Log;
|
import org.dynmap.Log;
|
||||||
import org.dynmap.MapManager;
|
import org.dynmap.MapManager;
|
||||||
|
import org.dynmap.common.BiomeMap;
|
||||||
import org.dynmap.utils.DynmapBufferedImage;
|
import org.dynmap.utils.DynmapBufferedImage;
|
||||||
import org.dynmap.utils.MapIterator.BlockStep;
|
import org.dynmap.utils.MapIterator.BlockStep;
|
||||||
import org.dynmap.utils.MapIterator;
|
import org.dynmap.utils.MapIterator;
|
||||||
@ -1310,7 +1310,7 @@ public class TexturePack {
|
|||||||
li = imgs[IMG_FOLIAGECOLOR];
|
li = imgs[IMG_FOLIAGECOLOR];
|
||||||
break;
|
break;
|
||||||
case COLORMOD_WATERTONED:
|
case COLORMOD_WATERTONED:
|
||||||
if(ss.do_swamp_shading && (mapiter.getBiome() == Biome.SWAMPLAND))
|
if(ss.do_swamp_shading && (mapiter.getBiome() == BiomeMap.SWAMPLAND))
|
||||||
clrmult = 0xFFE0FF70;
|
clrmult = 0xFFE0FF70;
|
||||||
break;
|
break;
|
||||||
case COLORMOD_BIRCHTONED:
|
case COLORMOD_BIRCHTONED:
|
||||||
@ -1334,7 +1334,7 @@ public class TexturePack {
|
|||||||
else {
|
else {
|
||||||
clrmult = biomeLookup(li.argb, li.width, mapiter.getRawBiomeRainfall(), mapiter.getRawBiomeTemperature());
|
clrmult = biomeLookup(li.argb, li.width, mapiter.getRawBiomeRainfall(), mapiter.getRawBiomeTemperature());
|
||||||
}
|
}
|
||||||
if(ss.do_swamp_shading && (mapiter.getBiome() == Biome.SWAMPLAND))
|
if(ss.do_swamp_shading && (mapiter.getBiome() == BiomeMap.SWAMPLAND))
|
||||||
clrmult = (clrmult & 0xFF000000) | (((clrmult & 0x00FEFEFE) + 0x4E0E4E) / 2);
|
clrmult = (clrmult & 0xFF000000) | (((clrmult & 0x00FEFEFE) + 0x4E0E4E) / 2);
|
||||||
}
|
}
|
||||||
if((clrmult != -1) && (clrmult != 0)) {
|
if((clrmult != -1) && (clrmult != 0)) {
|
||||||
|
@ -9,7 +9,6 @@ import java.util.HashSet;
|
|||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.dynmap.Client;
|
import org.dynmap.Client;
|
||||||
import org.dynmap.Color;
|
import org.dynmap.Color;
|
||||||
import org.dynmap.ColorScheme;
|
import org.dynmap.ColorScheme;
|
||||||
@ -20,6 +19,7 @@ import org.dynmap.MapManager;
|
|||||||
import org.dynmap.DynmapCore.CompassMode;
|
import org.dynmap.DynmapCore.CompassMode;
|
||||||
import org.dynmap.MapType.ImageFormat;
|
import org.dynmap.MapType.ImageFormat;
|
||||||
import org.dynmap.TileHashManager;
|
import org.dynmap.TileHashManager;
|
||||||
|
import org.dynmap.common.BiomeMap;
|
||||||
import org.dynmap.debug.Debug;
|
import org.dynmap.debug.Debug;
|
||||||
import org.dynmap.utils.DynmapBufferedImage;
|
import org.dynmap.utils.DynmapBufferedImage;
|
||||||
import org.dynmap.utils.FileLockManager;
|
import org.dynmap.utils.FileLockManager;
|
||||||
@ -406,7 +406,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||||||
MapIterator mapiter) {
|
MapIterator mapiter) {
|
||||||
int lightlevel = 15;
|
int lightlevel = 15;
|
||||||
int lightlevel_day = 15;
|
int lightlevel_day = 15;
|
||||||
Biome bio = null;
|
BiomeMap bio = null;
|
||||||
double rain = 0.0;
|
double rain = 0.0;
|
||||||
double temp = 0.0;
|
double temp = 0.0;
|
||||||
result.setTransparent();
|
result.setTransparent();
|
||||||
|
@ -6,8 +6,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.dynmap.ConfigurationNode;
|
||||||
import org.bukkit.util.config.ConfigurationNode;
|
|
||||||
import org.dynmap.markers.AreaMarker;
|
import org.dynmap.markers.AreaMarker;
|
||||||
import org.dynmap.markers.MarkerIcon;
|
import org.dynmap.markers.MarkerIcon;
|
||||||
import org.dynmap.markers.MarkerSet;
|
import org.dynmap.markers.MarkerSet;
|
||||||
@ -89,8 +88,8 @@ class AreaMarkerImpl implements AreaMarker {
|
|||||||
markup = node.getBoolean("markup", false);
|
markup = node.getBoolean("markup", false);
|
||||||
ytop = node.getDouble("ytop", 64.0);
|
ytop = node.getDouble("ytop", 64.0);
|
||||||
ybottom = node.getDouble("ybottom", 64.0);
|
ybottom = node.getDouble("ybottom", 64.0);
|
||||||
List<Double> xx = node.getDoubleList("x", null);
|
List<Double> xx = node.getList("x");
|
||||||
List<Double> zz = node.getDoubleList("z", null);
|
List<Double> zz = node.getList("z");
|
||||||
corners.clear();
|
corners.clear();
|
||||||
if((xx != null) && (zz != null)) {
|
if((xx != null) && (zz != null)) {
|
||||||
for(int i = 0; (i < xx.size()) && (i < zz.size()); i++)
|
for(int i = 0; (i < xx.size()) && (i < zz.size()); i++)
|
||||||
@ -98,11 +97,11 @@ class AreaMarkerImpl implements AreaMarker {
|
|||||||
}
|
}
|
||||||
world = node.getString("world", "world");
|
world = node.getString("world", "world");
|
||||||
desc = node.getString("desc", null);
|
desc = node.getString("desc", null);
|
||||||
lineweight = node.getInt("strokeWeight", 3);
|
lineweight = node.getInteger("strokeWeight", 3);
|
||||||
lineopacity = node.getDouble("strokeOpacity", 0.8);
|
lineopacity = node.getDouble("strokeOpacity", 0.8);
|
||||||
linecolor = node.getInt("strokeColor", 0xFF0000);
|
linecolor = node.getInteger("strokeColor", 0xFF0000);
|
||||||
fillopacity = node.getDouble("fillOpacity", 0.35);
|
fillopacity = node.getDouble("fillOpacity", 0.35);
|
||||||
fillcolor = node.getInt("fillColor", 0xFF0000);
|
fillcolor = node.getInteger("fillColor", 0xFF0000);
|
||||||
ispersistent = true; /* Loaded from config, so must be */
|
ispersistent = true; /* Loaded from config, so must be */
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,8 +20,7 @@ import java.util.TreeSet;
|
|||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
import org.bukkit.util.config.Configuration;
|
import org.dynmap.ConfigurationNode;
|
||||||
import org.bukkit.util.config.ConfigurationNode;
|
|
||||||
import org.dynmap.DynmapCore;
|
import org.dynmap.DynmapCore;
|
||||||
import org.dynmap.DynmapLocation;
|
import org.dynmap.DynmapLocation;
|
||||||
import org.dynmap.DynmapWorld;
|
import org.dynmap.DynmapWorld;
|
||||||
@ -454,7 +453,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
|||||||
}
|
}
|
||||||
private void doSaveMarkers() {
|
private void doSaveMarkers() {
|
||||||
if(api != null) {
|
if(api != null) {
|
||||||
Configuration conf = new Configuration(api.markerpersist); /* Make configuration object */
|
ConfigurationNode conf = new ConfigurationNode(api.markerpersist); /* Make configuration object */
|
||||||
/* First, save icon definitions */
|
/* First, save icon definitions */
|
||||||
HashMap<String, Object> icons = new HashMap<String,Object>();
|
HashMap<String, Object> icons = new HashMap<String,Object>();
|
||||||
for(String id : api.markericons.keySet()) {
|
for(String id : api.markericons.keySet()) {
|
||||||
@ -464,7 +463,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
|||||||
icons.put(id, dat);
|
icons.put(id, dat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conf.setProperty("icons", icons);
|
conf.put("icons", icons);
|
||||||
/* Then, save persistent sets */
|
/* Then, save persistent sets */
|
||||||
HashMap<String, Object> sets = new HashMap<String, Object>();
|
HashMap<String, Object> sets = new HashMap<String, Object>();
|
||||||
for(String id : api.markersets.keySet()) {
|
for(String id : api.markersets.keySet()) {
|
||||||
@ -476,7 +475,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conf.setProperty("sets", sets);
|
conf.put("sets", sets);
|
||||||
/* And shift old file file out */
|
/* And shift old file file out */
|
||||||
if(api.markerpersist_old.exists()) api.markerpersist_old.delete();
|
if(api.markerpersist_old.exists()) api.markerpersist_old.delete();
|
||||||
if(api.markerpersist.exists()) api.markerpersist.renameTo(api.markerpersist_old);
|
if(api.markerpersist.exists()) api.markerpersist.renameTo(api.markerpersist_old);
|
||||||
@ -500,23 +499,24 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
|||||||
* Load persistence
|
* Load persistence
|
||||||
*/
|
*/
|
||||||
private boolean loadMarkers() {
|
private boolean loadMarkers() {
|
||||||
Configuration conf = new Configuration(api.markerpersist); /* Make configuration object */
|
ConfigurationNode conf = new ConfigurationNode(api.markerpersist); /* Make configuration object */
|
||||||
conf.load(); /* Load persistence */
|
conf.load(); /* Load persistence */
|
||||||
/* Get icons */
|
/* Get icons */
|
||||||
Map<String,ConfigurationNode> icons = conf.getNodes("icons");
|
|
||||||
|
ConfigurationNode icons = conf.getNode("icons");
|
||||||
if(icons == null) return false;
|
if(icons == null) return false;
|
||||||
for(String id : icons.keySet()) {
|
for(String id : icons.keySet()) {
|
||||||
MarkerIconImpl ico = new MarkerIconImpl(id);
|
MarkerIconImpl ico = new MarkerIconImpl(id);
|
||||||
if(ico.loadPersistentData(icons.get(id))) {
|
if(ico.loadPersistentData(icons.getNode(id))) {
|
||||||
markericons.put(id, ico);
|
markericons.put(id, ico);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Get marker sets */
|
/* Get marker sets */
|
||||||
Map<String,ConfigurationNode> sets = conf.getNodes("sets");
|
ConfigurationNode sets = conf.getNode("sets");
|
||||||
if(sets != null) {
|
if(sets != null) {
|
||||||
for(String id: sets.keySet()) {
|
for(String id: sets.keySet()) {
|
||||||
MarkerSetImpl set = new MarkerSetImpl(id);
|
MarkerSetImpl set = new MarkerSetImpl(id);
|
||||||
if(set.loadPersistentData(sets.get(id))) {
|
if(set.loadPersistentData(sets.getNode(id))) {
|
||||||
markersets.put(id, set);
|
markersets.put(id, set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import java.io.InputStream;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.util.config.ConfigurationNode;
|
import org.dynmap.ConfigurationNode;
|
||||||
import org.dynmap.Log;
|
import org.dynmap.Log;
|
||||||
import org.dynmap.markers.MarkerIcon;
|
import org.dynmap.markers.MarkerIcon;
|
||||||
|
|
||||||
|
@ -4,8 +4,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.dynmap.ConfigurationNode;
|
||||||
import org.bukkit.util.config.ConfigurationNode;
|
|
||||||
import org.dynmap.markers.Marker;
|
import org.dynmap.markers.Marker;
|
||||||
import org.dynmap.markers.MarkerIcon;
|
import org.dynmap.markers.MarkerIcon;
|
||||||
import org.dynmap.markers.MarkerSet;
|
import org.dynmap.markers.MarkerSet;
|
||||||
|
@ -7,8 +7,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.dynmap.ConfigurationNode;
|
||||||
import org.bukkit.util.config.ConfigurationNode;
|
|
||||||
import org.dynmap.Log;
|
import org.dynmap.Log;
|
||||||
import org.dynmap.markers.AreaMarker;
|
import org.dynmap.markers.AreaMarker;
|
||||||
import org.dynmap.markers.Marker;
|
import org.dynmap.markers.Marker;
|
||||||
@ -263,7 +262,7 @@ class MarkerSetImpl implements MarkerSet {
|
|||||||
label = node.getString("label", setid); /* Get label */
|
label = node.getString("label", setid); /* Get label */
|
||||||
ConfigurationNode markernode = node.getNode("markers");
|
ConfigurationNode markernode = node.getNode("markers");
|
||||||
if(markernode != null) {
|
if(markernode != null) {
|
||||||
for(String id : markernode.getKeys()) {
|
for(String id : markernode.keySet()) {
|
||||||
MarkerImpl marker = new MarkerImpl(id, this); /* Make and load marker */
|
MarkerImpl marker = new MarkerImpl(id, this); /* Make and load marker */
|
||||||
if(marker.loadPersistentData(markernode.getNode(id))) {
|
if(marker.loadPersistentData(markernode.getNode(id))) {
|
||||||
markers.put(id, marker);
|
markers.put(id, marker);
|
||||||
@ -276,7 +275,7 @@ class MarkerSetImpl implements MarkerSet {
|
|||||||
}
|
}
|
||||||
ConfigurationNode areamarkernode = node.getNode("areas");
|
ConfigurationNode areamarkernode = node.getNode("areas");
|
||||||
if(areamarkernode != null) {
|
if(areamarkernode != null) {
|
||||||
for(String id : areamarkernode.getKeys()) {
|
for(String id : areamarkernode.keySet()) {
|
||||||
AreaMarkerImpl marker = new AreaMarkerImpl(id, this); /* Make and load marker */
|
AreaMarkerImpl marker = new AreaMarkerImpl(id, this); /* Make and load marker */
|
||||||
if(marker.loadPersistentData(areamarkernode.getNode(id))) {
|
if(marker.loadPersistentData(areamarkernode.getNode(id))) {
|
||||||
areamarkers.put(id, marker);
|
areamarkers.put(id, marker);
|
||||||
@ -287,7 +286,7 @@ class MarkerSetImpl implements MarkerSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<String> allowed = node.getStringList("allowedicons", null);
|
List<String> allowed = node.getList("allowedicons");
|
||||||
if(allowed != null) {
|
if(allowed != null) {
|
||||||
for(String id : allowed) {
|
for(String id : allowed) {
|
||||||
MarkerIconImpl icon = MarkerAPIImpl.getMarkerIconImpl(id);
|
MarkerIconImpl icon = MarkerAPIImpl.getMarkerIconImpl(id);
|
||||||
@ -298,8 +297,8 @@ class MarkerSetImpl implements MarkerSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hide_by_def = node.getBoolean("hide", false);
|
hide_by_def = node.getBoolean("hide", false);
|
||||||
prio = node.getInt("layerprio", 0);
|
prio = node.getInteger("layerprio", 0);
|
||||||
minzoom = node.getInt("minzoom", 0);
|
minzoom = node.getInteger("minzoom", 0);
|
||||||
ispersistent = true;
|
ispersistent = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package org.dynmap.utils;
|
package org.dynmap.utils;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.dynmap.DynmapChunk;
|
import org.dynmap.DynmapChunk;
|
||||||
import org.dynmap.DynmapWorld;
|
import org.dynmap.DynmapWorld;
|
||||||
|
import org.dynmap.common.BiomeMap;
|
||||||
|
|
||||||
public interface MapChunkCache {
|
public interface MapChunkCache {
|
||||||
public enum HiddenChunkStyle {
|
public enum HiddenChunkStyle {
|
||||||
@ -18,7 +17,7 @@ public interface MapChunkCache {
|
|||||||
/**
|
/**
|
||||||
* Set chunks to load, and world to load from
|
* Set chunks to load, and world to load from
|
||||||
*/
|
*/
|
||||||
void setChunks(World w, List<DynmapChunk> chunks);
|
void setChunks(DynmapWorld w, List<DynmapChunk> chunks);
|
||||||
/**
|
/**
|
||||||
* Set chunk data type needed
|
* Set chunk data type needed
|
||||||
* @param blockdata - need block type and data for chunk
|
* @param blockdata - need block type and data for chunk
|
||||||
@ -69,7 +68,7 @@ public interface MapChunkCache {
|
|||||||
/**
|
/**
|
||||||
* Get biome at coordinates
|
* Get biome at coordinates
|
||||||
*/
|
*/
|
||||||
public Biome getBiome(int x, int z);
|
public BiomeMap getBiome(int x, int z);
|
||||||
/**
|
/**
|
||||||
* Get raw temperature data (0.0-1.0)
|
* Get raw temperature data (0.0-1.0)
|
||||||
*/
|
*/
|
||||||
@ -105,7 +104,7 @@ public interface MapChunkCache {
|
|||||||
/**
|
/**
|
||||||
* Get world
|
* Get world
|
||||||
*/
|
*/
|
||||||
public World getWorld();
|
public DynmapWorld getWorld();
|
||||||
/**
|
/**
|
||||||
* Get total chunks loaded
|
* Get total chunks loaded
|
||||||
* @return
|
* @return
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.dynmap.utils;
|
package org.dynmap.utils;
|
||||||
|
|
||||||
import org.bukkit.block.Biome;
|
import org.dynmap.common.BiomeMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterator for traversing map chunk cache (base is for non-snapshot)
|
* Iterator for traversing map chunk cache (base is for non-snapshot)
|
||||||
@ -52,7 +52,7 @@ public interface MapIterator {
|
|||||||
/**
|
/**
|
||||||
* Get biome at coordinates
|
* Get biome at coordinates
|
||||||
*/
|
*/
|
||||||
public Biome getBiome();
|
public BiomeMap getBiome();
|
||||||
/**
|
/**
|
||||||
* Get raw temperature data (0.0-1.0)
|
* Get raw temperature data (0.0-1.0)
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user