Code cleanup.
This commit is contained in:
parent
4ae5707505
commit
a080825060
3 changed files with 22 additions and 29 deletions
|
|
@ -15,7 +15,6 @@ import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
import org.dynmap.Event;
|
|
||||||
import org.dynmap.web.Json;
|
import org.dynmap.web.Json;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
@ -24,7 +23,7 @@ import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
class JsonTimerTask extends TimerTask {
|
class JsonTimerTask extends TimerTask {
|
||||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
private final DynmapPlugin plugin;
|
private final DynmapPlugin plugin;
|
||||||
private Server server;
|
private Server server;
|
||||||
private MapManager mapManager;
|
private MapManager mapManager;
|
||||||
|
|
@ -45,33 +44,30 @@ class JsonTimerTask extends TimerTask {
|
||||||
File outputFile;
|
File outputFile;
|
||||||
|
|
||||||
//Handles Reading WebChat
|
//Handles Reading WebChat
|
||||||
if(configuration.getNode("web").getBoolean("allowwebchat", false))
|
if (configuration.getNode("web").getBoolean("allowwebchat", false)) {
|
||||||
{
|
|
||||||
File webChatPath = new File(this.configuration.getString("webpath", "web"), "standalone/dynmap_webchat.json");
|
File webChatPath = new File(this.configuration.getString("webpath", "web"), "standalone/dynmap_webchat.json");
|
||||||
if (webChatPath.isAbsolute())
|
if (webChatPath.isAbsolute())
|
||||||
outputFile = webChatPath;
|
outputFile = webChatPath;
|
||||||
else {
|
else {
|
||||||
outputFile = new File(plugin.getDataFolder(), webChatPath.toString());
|
outputFile = new File(plugin.getDataFolder(), webChatPath.toString());
|
||||||
}
|
}
|
||||||
if(webChatPath.exists() && lastTimestamp != 0)
|
if (webChatPath.exists() && lastTimestamp != 0) {
|
||||||
{
|
|
||||||
JSONArray jsonMsgs = null;
|
JSONArray jsonMsgs = null;
|
||||||
try {
|
try {
|
||||||
FileReader inputFileReader = new FileReader(webChatPath);
|
FileReader inputFileReader = new FileReader(webChatPath);
|
||||||
jsonMsgs = (JSONArray) parser.parse(inputFileReader);
|
jsonMsgs = (JSONArray) parser.parse(inputFileReader);
|
||||||
inputFileReader.close();
|
inputFileReader.close();
|
||||||
} catch(IOException ex){
|
} catch (IOException ex) {
|
||||||
log.log(Level.SEVERE, "Exception while reading JSON-file.", ex);
|
log.log(Level.SEVERE, "Exception while reading JSON-file.", ex);
|
||||||
} catch(ParseException ex) {
|
} catch (ParseException ex) {
|
||||||
log.log(Level.SEVERE, "Exception while parsing JSON-file.", ex);
|
log.log(Level.SEVERE, "Exception while parsing JSON-file.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(jsonMsgs != null) {
|
if (jsonMsgs != null) {
|
||||||
Iterator iter = jsonMsgs.iterator();
|
Iterator iter = jsonMsgs.iterator();
|
||||||
while(iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
JSONObject o = (JSONObject)iter.next();
|
JSONObject o = (JSONObject) iter.next();
|
||||||
if(Long.parseLong(String.valueOf(o.get("timestamp"))) >= (lastTimestamp))
|
if (Long.parseLong(String.valueOf(o.get("timestamp"))) >= (lastTimestamp)) {
|
||||||
{
|
|
||||||
plugin.webChat(String.valueOf(o.get("name")), String.valueOf(o.get("message")));
|
plugin.webChat(String.valueOf(o.get("name")), String.valueOf(o.get("message")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package org.dynmap.flat;
|
package org.dynmap.flat;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.color.ColorSpace;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.WritableRaster;
|
import java.awt.image.WritableRaster;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -23,8 +22,8 @@ public class FlatMap extends MapType {
|
||||||
private ColorScheme colorScheme;
|
private ColorScheme colorScheme;
|
||||||
|
|
||||||
public FlatMap(Map<String, Object> configuration) {
|
public FlatMap(Map<String, Object> configuration) {
|
||||||
prefix = (String)configuration.get("prefix");
|
prefix = (String) configuration.get("prefix");
|
||||||
colorScheme = ColorScheme.getScheme((String)configuration.get("colorscheme"));
|
colorScheme = ColorScheme.getScheme((String) configuration.get("colorscheme"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -71,7 +70,7 @@ public class FlatMap extends MapType {
|
||||||
boolean rendered = false;
|
boolean rendered = false;
|
||||||
BufferedImage im = new BufferedImage(t.size, t.size, BufferedImage.TYPE_INT_RGB);
|
BufferedImage im = new BufferedImage(t.size, t.size, BufferedImage.TYPE_INT_RGB);
|
||||||
WritableRaster raster = im.getRaster();
|
WritableRaster raster = im.getRaster();
|
||||||
|
|
||||||
float[] hsb = new float[4];
|
float[] hsb = new float[4];
|
||||||
int[] pixel = new int[4];
|
int[] pixel = new int[4];
|
||||||
|
|
||||||
|
|
@ -87,25 +86,24 @@ public class FlatMap extends MapType {
|
||||||
Color c = colors[0];
|
Color c = colors[0];
|
||||||
if (c == null)
|
if (c == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsb);
|
Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsb);
|
||||||
|
|
||||||
float normalheight = 64;
|
float normalheight = 64;
|
||||||
float below = Math.min(my, normalheight) / normalheight;
|
float below = Math.min(my, normalheight) / normalheight;
|
||||||
float above = 1.0f - Math.max(0, my - normalheight) / (128 - normalheight);
|
float above = 1.0f - Math.max(0, my - normalheight) / (128 - normalheight);
|
||||||
|
|
||||||
// Saturation will be changed when going higher.
|
// Saturation will be changed when going higher.
|
||||||
hsb[1] *= above;
|
hsb[1] *= above;
|
||||||
|
|
||||||
// Brightness will change when going lower
|
// Brightness will change when going lower
|
||||||
hsb[2] *= below;
|
hsb[2] *= below;
|
||||||
|
|
||||||
int rgb = Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]);
|
int rgb = Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]);
|
||||||
pixel[0] = (rgb&0xff0000) >> 16;
|
pixel[0] = (rgb & 0xff0000) >> 16;
|
||||||
pixel[1] = (rgb&0x00ff00) >> 8;
|
pixel[1] = (rgb & 0x00ff00) >> 8;
|
||||||
pixel[2] = (rgb&0x0000ff)/* >> 0*/;
|
pixel[2] = (rgb & 0x0000ff)/* >> 0 */;
|
||||||
|
|
||||||
raster.setPixel(x, y, pixel);
|
raster.setPixel(x, y, pixel);
|
||||||
rendered = true;
|
rendered = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package org.dynmap.web;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.security.KeyStore.Entry;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue