Put classes in package to be more compatible with Bukkit.

This commit is contained in:
FrozenCow 2011-01-05 19:41:21 +01:00
parent 80f9435a1a
commit f0ec375834
12 changed files with 39 additions and 35 deletions

View file

@ -0,0 +1,116 @@
package org.dynmap;
import java.util.HashMap;
public class Cache<K, V>
{
private final int size;
private int len;
private CacheNode head;
private CacheNode tail;
private class CacheNode
{
public CacheNode prev;
public CacheNode next;
public K key;
public V value;
public CacheNode(K key, V value)
{
this.key = key;
this.value = value;
prev = null;
next = null;
}
public void unlink()
{
if(prev == null) {
head = next;
} else {
prev.next = next;
}
if(next == null) {
tail = prev;
} else {
next.prev = prev;
}
prev = null;
next = null;
len --;
}
public void append()
{
if(tail == null) {
head = this;
tail = this;
} else {
tail.next = this;
prev = tail;
tail = this;
}
len ++;
}
}
private HashMap<K, CacheNode> map;
public Cache(int size)
{
this.size = size;
len = 0;
head = null;
tail = null;
map = new HashMap<K, CacheNode>();
}
/* returns value for key, if key exists in the cache
* otherwise null */
public V get(K key)
{
CacheNode n = map.get(key);
if(n == null)
return null;
return n.value;
}
/* puts a new key-value pair in the cache
* if the key existed already, the value is updated, and the old value is returned
* if the key didn't exist, it is added; the oldest value (now pushed out of the
* cache) may be returned, or null if the cache isn't yet full */
public V put(K key, V value)
{
CacheNode n = map.get(key);
if(n == null) {
V ret = null;
if(len >= size) {
CacheNode first = head;
first.unlink();
map.remove(first.key);
ret = first.value;
}
CacheNode add = new CacheNode(key, value);
add.append();
map.put(key, add);
return ret;
} else {
n.unlink();
V old = n.value;
n.value = value;
n.append();
return old;
}
}
}

View file

@ -0,0 +1,163 @@
package org.dynmap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.logging.Logger;
import org.bukkit.*;
import org.bukkit.event.block.*;
public class MapListener extends BlockListener {
private static final Logger log = Logger.getLogger("Minecraft");
private MapManager mgr;
public MapListener(MapManager mgr)
{
this.mgr = mgr;
}
@Override
public void onBlockPlaced(BlockPlacedEvent event) {
Block blockPlaced = event.getBlock();
if(mgr.touch(blockPlaced.getX(), blockPlaced.getY(), blockPlaced.getZ()))
mgr.debug(/*player.getName() + */" touch " + blockPlaced.getX() + "," + blockPlaced.getY() + "," + blockPlaced.getZ() + " from onBlockCreate");
}
/*
@Override
public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicked, int itemInHand)
{
if(mgr.touch(blockPlaced.getX(), blockPlaced.getY(), blockPlaced.getZ()))
mgr.debug(player.getName() + " touch " + blockPlaced.getX() + "," + blockPlaced.getY() + "," + blockPlaced.getZ() + " from onBlockCreate");
return false;
}
@Override
public boolean onBlockDestroy(Player player, Block block)
{
int x = block.getX();
int y = block.getY();
int z = block.getZ();
if(x == 0 && y == 0 && z == 0)
return false;
if(mgr.touch(x, y, z))
mgr.debug(player.getName() + " touch " + x + "," + y + "," + z + " from onBlockBreak");
return false;
}
@Override
public void onLogin(Player player)
{
mgr.getPlayerImage(player);
}
@Override
public boolean onCommand(Player player, String[] split)
{
if(!player.canUseCommand(split[0]))
return false;
if(split[0].equals("/map_wait")) {
if(split.length < 2) {
mgr.renderWait = 1000;
} else {
try {
mgr.renderWait = Integer.parseInt(split[1]);
} catch(NumberFormatException e) {
player.sendMessage(Colors.Rose + "Invalid number");
}
}
return true;
}
if(split[0].equals("/map_regen")) {
mgr.regenerate((int) player.getX(), (int) player.getY(), (int) player.getZ());
player.sendMessage(Colors.Rose + "Map regeneration in progress");
return true;
}
if(split[0].equals("/map_stat")) {
player.sendMessage(Colors.Rose + "Stale tiles: " + mgr.getStaleCount() + " Recent updates: " + mgr.getRecentUpdateCount());
return true;
}
if(split[0].equals("/map_debug")) {
mgr.debugPlayer = player.getName();
return true;
}
if(split[0].equals("/map_nodebug")) {
mgr.debugPlayer = null;
return true;
}
if(split[0].equals("/addsign")) {
if(split.length < 2)
{
player.sendMessage("Map> " + Colors.Red + "Usage: /addsign [name]");
}
else
{
if (mgr.addSign(player, split[1], player.getX(), player.getY(), player.getZ()))
{
player.sendMessage("Map> " + Colors.White + "Sign \"" + split[1] + "\" added successfully");
}
}
return true;
}
if(split[0].equals("/removesign")) {
if(split.length < 2)
{
player.sendMessage("Map> " + Colors.Red + "Usage: /removesign [name]");
}
else
{
if (mgr.removeSign(player, split[1]))
{
player.sendMessage("Map> " + Colors.White + "Sign \"" + split[1] + "\" removed successfully");
}
}
return true;
}
if(split[0].equals("/listsigns")) {
String msg = "";
Collection<Warp> values = mgr.signs.values();
Iterator<Warp> it = values.iterator();
while(it.hasNext())
{
Warp sign = it.next();
String line = " - " + sign.Name + "\t";
msg += line;
}
player.sendMessage("" + Colors.White + msg);
return true;
}
if(split[0].equals("/tpsign")) {
if(split.length < 2)
{
player.sendMessage("Map> " + Colors.Red + "Usage: /tpsign [name]");
}
else
{
if (mgr.teleportToSign(player, split[1]))
{
//player.sendMessage("Map> " + Colors.White + "");
}
}
return true;
}
if(split[0].equals("/map_regenzoom")) {
mgr.regenerateZoom((int) player.getX(), (int) player.getY(), (int) player.getZ());
player.sendMessage(Colors.Rose + "regenerateZoom done");
return true;
}
return false;
}*/
}

View file

@ -0,0 +1,966 @@
package org.dynmap;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.*;
import javax.imageio.ImageIO;
public class MapManager extends Thread {
protected static final Logger log = Logger.getLogger("Minecraft");
public map etc;
/* dimensions of a map tile */
public static final int tileWidth = 128;
public static final int tileHeight = 128;
/* (logical!) dimensions of a zoomed out map tile
* must be twice the size of the normal tile */
public static final int zTileWidth = 256;
public static final int zTileHeight = 256;
/* lock for our data structures */
public static final Object lock = new Object();
/* a hash table of known MapTiles, by their key (projection coords) */
private HashMap<Long, MapTile> tileStore;
/* a list of MapTiles to be updated */
private LinkedList<MapTile> staleTiles;
/* a list of MapTiles for which the cave tile is to be updated */
private LinkedList<MapTile> staleCaveTiles;
/* whether the worker thread should be running now */
private boolean running = false;
/* map x, y, z for projection origin */
public static final int anchorx = 0;
public static final int anchory = 127;
public static final int anchorz = 0;
/* color database: id -> Color */
public HashMap<Integer, Color[]> colors = null;
/* path to colors.txt */
private String colorsetpath = "colors.txt";
/* path to image tile directory */
public String tilepath = "tiles/";
/* path to signs file */
public String signspath = "signs.txt";
/* port to run web server on */
public int serverport = 8123;
/* time to pause between rendering tiles (ms) */
public int renderWait = 500;
/* remember up to this old tile updates (ms) */
private static final int maxTileAge = 60000;
/* this list stores the tile updates */
public LinkedList<TileUpdate> tileUpdates = null;
/* this list stores the cave tile updates */
public LinkedList<TileUpdate> caveTileUpdates = null;
/* map debugging mode (send debugging messages to this player) */
public String debugPlayer = null;
/* hashmap of signs */
//public HashMap<String, Warp> signs = null;
/* cache this many zoomed-out tiles */
public static final int zoomCacheSize = 64;
/* zoomed-out tile cache */
public Cache<String, BufferedImage> zoomCache;
/* data source */
public String datasource = "flatfile";
/* which markers to show (spawn,homes,warps,signs,players,all,none) */
public String showmarkers = "all";
/* booleans designating what to show on the map */
public Boolean showSpawn = false;
public Boolean showHomes = false;
public Boolean showWarps = false;
public Boolean showSigns = false;
public Boolean showPlayers = false;
public Boolean generatePortraits = false;
public void debug(String msg)
{
if(debugPlayer == null) return;
Server s = etc.getServer();
Player p = s.getPlayer(debugPlayer);
if(p == null) return;
p.sendMessage("Map> " + Color.RED + msg);
}
public MapManager(map plugin)
{
etc = plugin;
/* load configuration */
/*PropertiesFile properties;
properties = new PropertiesFile("server.properties");
try {
tilepath = properties.getString("map-tilepath", "tiles/");
colorsetpath = properties.getString("map-colorsetpath", "colors.txt");
signspath = properties.getString("map-signspath", "signs.txt");
serverport = Integer.parseInt(properties.getString("map-serverport", "8123"));
datasource = properties.getString("data-source", "flatfile");
showmarkers = properties.getString("map-showmarkers", "all");
generatePortraits = !properties.getString("map-generateportraits", "0").equals("0");
} catch(Exception ex) {
log.log(Level.SEVERE, "Exception while reading properties for dynamic map", ex);
}*/
tilepath = "/srv/http/dynmap/tiles/";
colorsetpath = "colors.txt";
signspath = "signs.txt";
serverport = 8123;
datasource = "flatfile";
showmarkers = "all";
{
showSpawn = true;
showHomes = true;
showWarps = true;
showSigns = true;
showPlayers = true;
}
generatePortraits = false;
tileStore = new HashMap<Long, MapTile>();
staleTiles = new LinkedList<MapTile>();
staleCaveTiles = new LinkedList<MapTile>();
tileUpdates = new LinkedList<TileUpdate>();
caveTileUpdates = new LinkedList<TileUpdate>();
zoomCache = new Cache<String, BufferedImage>(zoomCacheSize);
// signs = new HashMap<String, Warp>();
// loadShowOptions();
}
/* tile X for position x */
static int tilex(int x)
{
if(x < 0)
return x - (tileWidth + (x % tileWidth));
else
return x - (x % tileWidth);
}
/* tile Y for position y */
static int tiley(int y)
{
if(y < 0)
return y - (tileHeight + (y % tileHeight));
else
return y - (y % tileHeight);
}
/* zoomed-out tile X for tile position x */
static int ztilex(int x)
{
if(x < 0)
return x + x % zTileWidth;
else
return x - (x % zTileWidth);
}
/* zoomed-out tile Y for tile position y */
static int ztiley(int y)
{
if(y < 0)
return y + y % zTileHeight;
//return y - (zTileHeight + (y % zTileHeight));
else
return y - (y % zTileHeight);
}
/* initialize and start map manager */
public void startManager()
{
colors = new HashMap<Integer, Color[]>();
/* load colorset */
File cfile = new File(colorsetpath);
//loadSigns();
try {
Scanner scanner = new Scanner(cfile);
int nc = 0;
while(scanner.hasNextLine()) {
String line = scanner.nextLine();
if (line.startsWith("#") || line.equals("")) {
continue;
}
String[] split = line.split("\t");
if (split.length < 17) {
continue;
}
Integer id = new Integer(split[0]);
Color[] c = new Color[4];
/* store colors by raycast sequence number */
c[0] = new Color(Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]), Integer.parseInt(split[4]));
c[3] = new Color(Integer.parseInt(split[5]), Integer.parseInt(split[6]), Integer.parseInt(split[7]), Integer.parseInt(split[8]));
c[1] = new Color(Integer.parseInt(split[9]), Integer.parseInt(split[10]), Integer.parseInt(split[11]), Integer.parseInt(split[12]));
c[2] = new Color(Integer.parseInt(split[13]), Integer.parseInt(split[14]), Integer.parseInt(split[15]), Integer.parseInt(split[16]));
colors.put(id, c);
nc += 1;
}
scanner.close();
log.info(nc + " colors loaded from " + colorsetpath);
} catch(Exception e) {
log.log(Level.SEVERE, "Failed to load colorset: " + colorsetpath, e);
return;
}
running = true;
this.start();
try {
this.setPriority(MIN_PRIORITY);
log.info("Set minimum priority for worker thread");
} catch(SecurityException e) {
log.info("Failed to set minimum priority for worker thread!");
}
}
/* stop map manager */
public void stopManager()
{
if(!running)
return;
log.info("Stopping map renderer...");
running = false;
try {
this.join();
} catch(InterruptedException e) {
log.info("Waiting for map renderer to stop is interrupted");
}
}
/* update tile update list */
private void updateUpdates(MapTile t, LinkedList<TileUpdate> lst)
{
long now = System.currentTimeMillis();
long deadline = now - maxTileAge;
synchronized(lock) {
ListIterator<TileUpdate> it = lst.listIterator(0);
while(it.hasNext()) {
TileUpdate tu = it.next();
if(tu.at < deadline || tu.tile == t)
it.remove();
}
lst.addLast(new TileUpdate(now, t));
}
}
/* the worker/renderer thread */
public void run()
{
log.info("Map renderer has started.");
while(running) {
boolean found = false;
MapTile t = this.popStaleTile();
if(t != null) {
t.render(this);
updateUpdates(t, tileUpdates);
try {
this.sleep(renderWait);
} catch(InterruptedException e) {
}
found = true;
}
MapTile ct = this.popStaleCaveTile();
if(ct != null) {
ct.renderCave(this);
updateUpdates(ct, caveTileUpdates);
try {
this.sleep(renderWait);
} catch(InterruptedException e) {
}
found = true;
}
if(!found) {
try {
this.sleep(500);
} catch(InterruptedException e) {
}
}
}
log.info("Map renderer has stopped.");
}
/* "touch" a block - its map tile will be regenerated */
public boolean touch(int x, int y, int z)
{
int dx = x - anchorx;
int dy = y - anchory;
int dz = z - anchorz;
int px = dx + dz;
int py = dx - dz - dy;
int tx = tilex(px);
int ty = tiley(py);
boolean r;
r = pushStaleTile(tx, ty);
boolean ledge = tilex(px - 4) != tx;
boolean tedge = tiley(py - 4) != ty;
boolean redge = tilex(px + 4) != tx;
boolean bedge = tiley(py + 4) != ty;
if(ledge)
r = pushStaleTile(tx - tileWidth, ty) || r;
if(redge)
r = pushStaleTile(tx + tileWidth, ty) || r;
if(tedge)
r = pushStaleTile(tx, ty - tileHeight) || r;
if(bedge)
r = pushStaleTile(tx, ty + tileHeight) || r;
if(ledge && tedge)
r = pushStaleTile(tx - tileWidth, ty - tileHeight) || r;
if(ledge && bedge)
r = pushStaleTile(tx - tileWidth, ty + tileHeight) || r;
if(redge && tedge)
r = pushStaleTile(tx + tileWidth, ty - tileHeight) || r;
if(redge && bedge)
r = pushStaleTile(tx + tileWidth, ty + tileHeight) || r;
return r;
}
/* get next MapTile that needs to be regenerated, or null
* the mapTile is removed from the list of stale tiles! */
public MapTile popStaleTile()
{
synchronized(lock) {
try {
MapTile t = staleTiles.removeFirst();
t.stale = false;
return t;
} catch(NoSuchElementException e) {
return null;
}
}
}
/* get next MapTile for which the cave map needs to be
* regenerated, or null
* the mapTile is removed from the list of stale cave tiles */
public MapTile popStaleCaveTile()
{
synchronized(lock) {
try {
MapTile t = staleCaveTiles.removeFirst();
t.staleCave = false;
return t;
} catch(NoSuchElementException e) {
return null;
}
}
}
/* put a MapTile that needs to be regenerated on the list of stale tiles */
public boolean pushStaleTile(MapTile m)
{
synchronized(lock) {
boolean ret = false;
if(!m.stale) {
m.stale = true;
staleTiles.addLast(m);
debug(m.toString() + " is now stale");
ret = true;
}
if(!m.staleCave) {
m.staleCave = true;
staleCaveTiles.addLast(m);
debug(m.toString() + " cave is now stale");
ret = true;
}
return ret;
}
}
/* make a MapTile stale by projection position */
public boolean pushStaleTile(int tx, int ty)
{
return pushStaleTile(getTileByPosition(tx, ty));
}
/* get (or create) MapTile by projection position */
private MapTile getTileByPosition(int px, int py)
{
Long key = MapTile.key(px, py);
synchronized(lock) {
MapTile t = tileStore.get(key);
if(t == null) {
/* no maptile exists, need to create one */
t = new MapTile(etc, px, py, ztilex(px), ztiley(py));
tileStore.put(key, t);
return t;
} else {
return t;
}
}
}
/* return number of stale tiles */
public int getStaleCount()
{
synchronized(lock) {
return staleTiles.size() + staleCaveTiles.size();
}
}
/* return number of recently updated tiles */
public int getRecentUpdateCount()
{
synchronized(lock) {
return tileUpdates.size() + caveTileUpdates.size();
}
}
/* regenerate the entire map, starting at position */
public void regenerate(int x, int y, int z)
{
int dx = x - anchorx;
int dy = y - anchory;
int dz = z - anchorz;
int px = dx + dz;
int py = dx - dz - dy;
int tx = tilex(px);
int ty = tiley(py);
MapTile first = getTileByPosition(tx, ty);
Vector<MapTile> open = new Vector<MapTile>();
open.add(first);
Server s = etc.getServer();
World w = etc.getWorld();
while(open.size() > 0) {
MapTile t = open.remove(open.size() - 1);
if(t.stale) continue;
int h = w.getHighestBlockYAt(t.mx, t.mz);
log.info("walking: " + t.mx + ", " + t.mz + ", h = " + h);
if(h < 1)
continue;
pushStaleTile(t);
open.add(getTileByPosition(t.px + tileWidth, t.py));
open.add(getTileByPosition(t.px - tileWidth, t.py));
open.add(getTileByPosition(t.px, t.py + tileHeight));
open.add(getTileByPosition(t.px, t.py - tileHeight));
}
}
/* regenerate all zoom tiles, starting at position */
public void regenerateZoom(int x, int y, int z)
{
int dx = x - anchorx;
int dy = y - anchory;
int dz = z - anchorz;
int px = dx + dz;
int py = dx - dz - dy;
int fzpx = ztilex(tilex(px));
int fzpy = ztiley(tiley(py));
class Pair implements Comparator {
public int x;
public int y;
public Pair(int x, int y)
{
this.x = x;
this.y = y;
}
public int hashCode()
{
return (x << 16) ^ y;
}
public boolean equals(Object o)
{
Pair p = (Pair) o;
return x == p.x && y == p.y;
}
public int compare(Object o1, Object o2)
{
Pair p1 = (Pair) o1;
Pair p2 = (Pair) o2;
if(p1.x < p1.x) return -1;
if(p1.x > p1.x) return 1;
if(p1.y < p1.y) return -1;
if(p1.y > p1.y) return 1;
return 0;
}
}
HashSet<Pair> visited = new HashSet<Pair>();
Vector<Pair> open = new Vector<Pair>();
Pair fp = new Pair(fzpx, fzpy);
open.add(fp);
visited.add(fp);
while(open.size() > 0) {
Pair p = open.remove(open.size() - 1);
int zpx = p.x;
int zpy = p.y;
log.info("Regenerating zoom tile " + zpx + "," + zpy);
int g = regenZoomTile(zpx, zpy);
if(g > 0) {
Pair[] np = new Pair[4];
np[0] = new Pair(zpx-zTileWidth, zpy);
np[1] = new Pair(zpx+zTileWidth, zpy);
np[2] = new Pair(zpx, zpy-zTileHeight);
np[3] = new Pair(zpx, zpy+zTileHeight);
for(int i=0; i<4; i++) {
if(!visited.contains(np[i])) {
visited.add(np[i]);
open.add(np[i]);
}
}
}
}
}
/* regenerate zoom-out tile
* returns number of valid subtiles */
public int regenZoomTile(int zpx, int zpy)
{
int px1 = zpx + tileWidth;
int py1 = zpy;
int px2 = zpx;
int py2 = py1 + tileHeight;
MapTile t1 = getTileByPosition(px1, py1);
MapTile t2 = getTileByPosition(px2, py1);
MapTile t3 = getTileByPosition(px1, py2);
MapTile t4 = getTileByPosition(px2, py2);
BufferedImage im1 = t1.loadTile(this);
BufferedImage im2 = t2.loadTile(this);
BufferedImage im3 = t3.loadTile(this);
BufferedImage im4 = t4.loadTile(this);
BufferedImage zIm = new BufferedImage(MapManager.tileWidth, MapManager.tileHeight, BufferedImage.TYPE_INT_RGB);
WritableRaster zr = zIm.getRaster();
Graphics2D g2 = zIm.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
int scw = tileWidth / 2;
int sch = tileHeight / 2;
int good = 0;
if(im1 != null) {
g2.drawImage(im1, 0, 0, scw, sch, null);
good ++;
}
if(im2 != null) {
g2.drawImage(im2, scw, 0, scw, sch, null);
good ++;
}
if(im3 != null) {
g2.drawImage(im3, 0, sch, scw, sch, null);
good ++;
}
if(im4 != null) {
g2.drawImage(im4, scw, sch, scw, sch, null);
good ++;
}
if(good == 0) {
return 0;
}
String zPath = t1.getZoomPath(this);
/* save zoom-out tile */
try {
File file = new File(zPath);
ImageIO.write(zIm, "png", file);
log.info("regenZoomTile saved zoom-out tile at " + zPath);
} catch(IOException e) {
log.log(Level.SEVERE, "Failed to save zoom-out tile: " + zPath, e);
} catch(java.lang.NullPointerException e) {
log.log(Level.SEVERE, "Failed to save zoom-out tile (NullPointerException): " + zPath, e);
}
return good;
}
/* adds a sign to the map */
/* public boolean addSign(Player player, String name, double px, double py, double pz)
{
if (signs.containsKey(name))
{
player.sendMessage("Map> " + Colors.Red + "Sign \"" + name + "\" already exists.");
return false;
}
Warp sign = new Warp();
sign.Name = name;
sign.Location = new Location(px,py,pz);
signs.put(name, sign);
try
{
saveSigns();
return true;
}
catch(IOException e)
{
log.log(Level.SEVERE, "Failed to save signs.txt", e);
}
return false;
}*/
/* removes a sign from the map */
/* public boolean removeSign(Player player, String name)
{
if (signs.containsKey(name))
{
Warp sign = signs.get(name);
signs.remove(name);
try
{
saveSigns();
return true;
}
catch(IOException e)
{
log.log(Level.SEVERE, "Failed to save signs.txt", e);
}
}
else
{
player.sendMessage("Map> " + Colors.Red + "Sign \"" + name + "\" does not exist.");
}
return false;
}*/
/* teleports a user to a sign */
/* public boolean teleportToSign(Player player, String name)
{
if (signs.containsKey(name))
{
Warp sign = signs.get(name);
player.teleportTo(sign.Location.x, sign.Location.y, sign.Location.z, 0, 0);
}
else
{
player.sendMessage("Map> " + Colors.Red + "Sign \"" + name + "\" does not exist.");
}
return false;
}*/
/* load the map sign file */
/* private void loadSigns()
{
Scanner scanner = null;
try
{
scanner = new Scanner(new FileInputStream(signspath), "UTF-8");
while (scanner.hasNextLine())
{
String line = scanner.nextLine();
String[] values = line.split(":");
String name = "";
Double x = 0.0,y = 0.0,z = 0.0;
// If user has old style of file (CSV)
if (values.length == 1)
{
values = line.split(",");
}
// If user has old style of file (owners)
if (values.length == 5)
{
name = values[0];
x = Double.parseDouble(values[2]);
y = Double.parseDouble(values[3]);
z = Double.parseDouble(values[4]);
}
else if (values.length == 4)
{
name = values[0];
x = Double.parseDouble(values[1]);
y = Double.parseDouble(values[2]);
z = Double.parseDouble(values[3]);
}
else
{
log.log(Level.INFO, "Failed to load sign: " + values[0]);
}
// If a sign was loaded, add it to the hash
if (name.isEmpty() == false && x != 0.0 && y != 0.0 && z != 0.0)
{
Warp sign = new Warp();
sign.Name = name;
sign.Location = new Location(x, y, z);
signs.put(sign.Name, sign);
}
}
}
catch(FileNotFoundException e)
{
// No need to log FileNotFoundException
}
finally
{
if (scanner != null) scanner.close();
}
}*/
/* save the map sign file */
/* private void saveSigns() throws IOException
{
Writer out = null;
try
{
out = new OutputStreamWriter(new FileOutputStream(signspath), "UTF-8");
Collection<Warp> values = signs.values();
Iterator<Warp> it = values.iterator();
while(it.hasNext())
{
Warp sign = it.next();
String line = sign.Name + ":" + sign.Location.x + ":" + sign.Location.y + ":" + sign.Location.z + "\n";
out.write(line);
}
}
catch(UnsupportedEncodingException e)
{
log.log(Level.SEVERE, "Unsupported encoding", e);
}
catch(FileNotFoundException e)
{
log.log(Level.SEVERE, "signs.txt not found", e);
}
finally
{
if (out != null) out.close();
}
}*/
/* TODO: Is there a cleaner way to get warps/homes than using custom DataSource classes to expose the protected properties? */
/* protected List<Warp> loadWarps()
{
List<Warp> warps = null;
if (datasource.equals("flatfile")) {
DMFlatFileSource ds = new DMFlatFileSource();
ds.initialize();
ds.loadWarps();
warps = ds.getAllWarps();
}
else if (datasource.equals("mysql")) {
DMMySQLSource ds = new DMMySQLSource();
ds.initialize();
ds.loadWarps();
warps = ds.getAllWarps();
}
return warps;
}
protected List<Warp> loadHomes()
{
List<Warp> homes = null;
if (datasource.equals("flatfile")) {
DMFlatFileSource ds = new DMFlatFileSource();
ds.initialize();
ds.loadHomes();
homes = ds.getAllHomes();
}
else if (datasource.equals("mysql")) {
DMMySQLSource ds = new DMMySQLSource();
ds.initialize();
ds.loadHomes();
homes = ds.getAllHomes();
}
return homes;
}
private void loadShowOptions()
{
String[] values = showmarkers.split(",");
for (int i = 0; i < values.length; i++)
{
String opt = values[i];
if (opt.equals("all"))
{
showSpawn = true;
showHomes = true;
showWarps = true;
showSigns = true;
showPlayers = true;
}
else if (opt.equals("none"))
{
showSpawn = false;
showHomes = false;
showWarps = false;
showSigns = false;
showPlayers = false;
}
else if (opt.equals("spawn"))
{
showSpawn = true;
}
else if (opt.equals("homes"))
{
showHomes = true;
}
else if (opt.equals("warps"))
{
showWarps = true;
}
else if (opt.equals("signs"))
{
showSigns = true;
}
else if (opt.equals("players"))
{
showPlayers = true;
}
}
}
protected void getPlayerImage(Player player)
{
if (!generatePortraits) return;
String urlString = "http://www.minecraft.net/skin/" + player.getName() + ".png";
String filename = tilepath + player.getName() + ".png";
if (downloadPlayerImage(urlString, filename) == false) {
downloadPlayerImage("http://www.minecraft.net/img/char.png", filename);
}
}
private Boolean downloadPlayerImage(String urlString, String filename)
{
BufferedImage img = null;
Boolean success = false;
File out = null;
try
{
img = ImageIO.read(new URL(urlString));
out = new File(filename);
BufferedImage imgCropped = img.getSubimage(8, 8, 8, 8);
BufferedImage imgResized = new BufferedImage(24, 24, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = imgResized.createGraphics();
g.drawImage(imgCropped, 0, 0, 24, 24, null);
g.dispose();
ImageIO.write(imgResized, "png", out);
success = true;
}
catch(IOException e) {
//log.log(Level.INFO, "Failed to fetch player image " + filename, e);
}
catch(NullPointerException e) {
//log.log(Level.INFO, "Failed to fetch player image " + filename, e);
}
return success;
}*/
}

View file

@ -0,0 +1,529 @@
package org.dynmap;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.awt.*;
import java.awt.image.*;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.bukkit.World;
import org.bukkit.Server;
public class MapTile {
protected static final Logger log = Logger.getLogger("Minecraft");
/* projection position */
public int px, py;
/* projection position of zoom-out tile */
public int zpx, zpy;
/* minecraft space origin */
public int mx, my, mz;
/* whether this tile needs to be updated */
boolean stale = false;
/* whether the cave map of this tile needs to be updated */
boolean staleCave = false;
private map etc;
/* create new MapTile */
public MapTile(map etc, int px, int py, int zpx, int zpy)
{
this.etc = etc;
this.px = px;
this.py = py;
this.zpx = zpx;
this.zpy = zpy;
mx = MapManager.anchorx + px / 2 + py / 2;
my = MapManager.anchory;
mz = MapManager.anchorz + px / 2 - py / 2;
}
/* try to get the server to load the relevant chunks */
public void loadChunks()
{
int x1 = mx - 64;
int x2 = mx + MapManager.tileWidth / 2 + MapManager.tileHeight / 2;
int z1 = mz - MapManager.tileHeight / 2;
int z2 = mz + MapManager.tileWidth / 2 + 64;
int x, z;
Server s = etc.getServer();
World w = etc.getWorld();
for(x=x1; x<x2; x+=16) {
for(z=z1; z<z2; z+=16) {
if(!w.isChunkLoaded(w.getChunkAt(x, z))) {
log.info("chunk not loaded: " + x + ", 0, " + z);
/*
try {
s.loadChunk(x, 0, z);
} catch(Exception e) {
log.log(Level.SEVERE, "Caught exception from loadChunk!", e);
}*/
}
}
}
}
/* check if all relevant chunks are loaded */
public boolean isMapLoaded()
{
int x1 = mx - 64;
int x2 = mx + MapManager.tileWidth / 2 + MapManager.tileHeight / 2;
int z1 = mz - MapManager.tileHeight / 2;
int z2 = mz + MapManager.tileWidth / 2 + 64;
int x, z;
Server s = etc.getServer();
World w = etc.getWorld();
for(x=x1; x<x2; x+=16) {
for(z=z1; z<z2; z+=16) {
if(!w.isChunkLoaded(w.getChunkAt(x, z))) {
// Will try to load chunk.
//log.info("chunk not loaded: " + x + ", " + z + " for tile " + this.toString());
return false;
// Sometimes give very heavy serverload:
/*try {
s.loadChunk(x, 0, z);
} catch(Exception e) {
log.log(Level.SEVERE, "Caught exception from loadChunk!", e);
return false;
}
if(!s.isChunkLoaded(x, 0, z)) {
log.info("Could not load chunk: " + x + ", " + z + " for tile " + this.toString());
return false;
}*/
}
}
}
return true;
}
/* get key by projection position */
public static long key(int px, int py)
{
long lpx = (long) px;
long lpy = (long) py;
return ((lpx & (long) 0xffffffffL) << 32) | (lpy & (long) 0xffffffffL);
}
/* hash value, based on projection position */
public int hashCode()
{
return (px << 16) ^ py;
}
/* equality comparison - based on projection position */
public boolean equals(MapTile o)
{
return o.px == px && o.py == py;
}
/* return a simple string representation... */
public String toString()
{
return px + "_" + py;
}
/* render this tile */
public void render(MapManager mgr)
{
mgr.debug("Rendering tile: " + this.toString());
//loadChunks();
if(!isMapLoaded())
return;
BufferedImage im = new BufferedImage(MapManager.tileWidth, MapManager.tileHeight, BufferedImage.TYPE_INT_RGB);
WritableRaster r = im.getRaster();
int ix = mx;
int iy = my;
int iz = mz;
int jx, jz;
int x, y;
/* draw the map */
for(y=0; y<MapManager.tileHeight;) {
jx = ix;
jz = iz;
for(x=MapManager.tileWidth-1; x>=0; x-=2) {
Color c1 = scan(mgr, jx, iy, jz, 0);
Color c2 = scan(mgr, jx, iy, jz, 2);
r.setPixel(x, y, new int[] { c1.getRed(), c1.getGreen(), c1.getBlue() });
r.setPixel(x-1, y, new int[] { c2.getRed(), c2.getGreen(), c2.getBlue() });
jx++;
jz++;
}
y ++;
jx = ix;
jz = iz - 1;
for(x=MapManager.tileWidth-1; x>=0; x-=2) {
Color c1 = scan(mgr, jx, iy, jz, 2);
jx++;
jz++;
Color c2 = scan(mgr, jx, iy, jz, 0);
r.setPixel(x, y, new int[] { c1.getRed(), c1.getGreen(), c1.getBlue() });
r.setPixel(x-1, y, new int[] { c2.getRed(), c2.getGreen(), c2.getBlue() });
}
y ++;
ix ++;
iz --;
}
/* save the generated tile */
saveTile(getPath(mgr), im, getZoomPath(mgr), mgr);
}
/* render cave map for this tile */
public void renderCave(MapManager mgr)
{
mgr.debug("Rendering cave map: " + this.toString());
//loadChunks();
if(!isMapLoaded())
return;
BufferedImage im = new BufferedImage(MapManager.tileWidth, MapManager.tileHeight, BufferedImage.TYPE_INT_RGB);
WritableRaster r = im.getRaster();
int ix = mx;
int iy = my;
int iz = mz;
int jx, jz;
int x, y;
/* draw the map */
for(y=0; y<MapManager.tileHeight;) {
jx = ix;
jz = iz;
for(x=MapManager.tileWidth-1; x>=0; x-=2) {
Color c1 = caveScan(mgr, jx, iy, jz, 0);
Color c2 = caveScan(mgr, jx, iy, jz, 2);
r.setPixel(x, y, new int[] { c1.getRed(), c1.getGreen(), c1.getBlue() });
r.setPixel(x-1, y, new int[] { c2.getRed(), c2.getGreen(), c2.getBlue() });
jx++;
jz++;
}
y ++;
jx = ix;
jz = iz - 1;
for(x=MapManager.tileWidth-1; x>=0; x-=2) {
Color c1 = caveScan(mgr, jx, iy, jz, 2);
jx++;
jz++;
Color c2 = caveScan(mgr, jx, iy, jz, 0);
r.setPixel(x, y, new int[] { c1.getRed(), c1.getGreen(), c1.getBlue() });
r.setPixel(x-1, y, new int[] { c2.getRed(), c2.getGreen(), c2.getBlue() });
}
y ++;
ix ++;
iz --;
}
/* save the generated tile */
saveTile(getCavePath(mgr), im, getZoomCavePath(mgr), mgr);
}
/* save rendered tile, update zoom-out tile */
public void saveTile(String tilePath, BufferedImage im, String zoomPath, MapManager mgr)
{
/* save image */
try {
File file = new File(tilePath);
ImageIO.write(im, "png", file);
} catch(IOException e) {
log.log(Level.SEVERE, "Failed to save tile: " + tilePath, e);
} catch(java.lang.NullPointerException e) {
log.log(Level.SEVERE, "Failed to save tile (NullPointerException): " + tilePath, e);
}
/* now update zoom-out tile */
BufferedImage zIm = mgr.zoomCache.get(zoomPath);
if(zIm == null) {
/* zoom-out tile doesn't exist - try to load it from disk */
mgr.debug("Trying to load zoom-out tile: " + zoomPath);
try {
File file = new File(zoomPath);
zIm = ImageIO.read(file);
} catch(IOException e) {
}
if(zIm == null) {
mgr.debug("Failed to load zoom-out tile: " + zoomPath);
/* create new one */
/* TODO: we might use existing tiles that we could load
* to fill the zoomed out tile in... */
zIm = new BufferedImage(MapManager.tileWidth, MapManager.tileHeight, BufferedImage.TYPE_INT_RGB);
} else {
mgr.debug("Loaded zoom-out tile from " + zoomPath);
}
} else {
mgr.debug("Using zoom-out tile from cache: " + zoomPath);
}
/* update zoom-out tile */
/* scaled size */
int scw = mgr.tileWidth / 2;
int sch = mgr.tileHeight / 2;
/* origin in zoomed-out tile */
int ox = scw;
int oy = 0;
if(zpx != px) ox = 0;
if(zpy != py) oy = sch;
/* blit scaled rendered tile onto zoom-out tile */
WritableRaster zr = zIm.getRaster();
Graphics2D g2 = zIm.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2.drawImage(im, ox, oy, scw, sch, null);
/* update zoom-out tile cache */
BufferedImage oldIm = mgr.zoomCache.put(zoomPath, zIm);
if(oldIm != null && oldIm != zIm) {
oldIm.flush();
}
/* save zoom-out tile */
try {
File file = new File(zoomPath);
ImageIO.write(zIm, "png", file);
mgr.debug("saved zoom-out tile at " + zoomPath);
//log.info("Saved tile: " + path);
} catch(IOException e) {
log.log(Level.SEVERE, "Failed to save zoom-out tile: " + zoomPath, e);
} catch(java.lang.NullPointerException e) {
log.log(Level.SEVERE, "Failed to save zoom-out tile (NullPointerException): " + zoomPath, e);
}
}
/* generate a path name for this map tile */
public String getPath(MapManager mgr)
{
return mgr.tilepath + "t_" + px + "_" + py + ".png";
}
/* generate a path name for the zoomed-out tile */
public String getZoomPath(MapManager mgr)
{
return mgr.tilepath + "zt_" + zpx + "_" + zpy + ".png";
}
/* generate a path name for this cave map tile */
public String getCavePath(MapManager mgr)
{
return mgr.tilepath + "ct_" + px + "_" + py + ".png";
}
/* generate a path name for the zoomed-out cave tile */
public String getZoomCavePath(MapManager mgr)
{
return mgr.tilepath + "czt_" + zpx + "_" + zpy + ".png";
}
/* try to load already generated image */
public BufferedImage loadTile(MapManager mgr)
{
try {
String path = getPath(mgr);
//log.info("Loading tile from " + path);
File file = new File(path);
BufferedImage im = ImageIO.read(file);
//log.info("OK");
return im;
} catch(IOException e) {
//log.info("failed: " + e.toString());
}
return null;
}
/* cast a ray into the map */
private Color scan(MapManager mgr, int x, int y, int z, int seq)
{
Server s = etc.getServer();
World w = etc.getWorld();
for(;;) {
if(y < 0)
return Color.BLUE;
int id = w.getBlockAt(x, y, z).getTypeID();
switch(seq) {
case 0:
x--;
break;
case 1:
y--;
break;
case 2:
z++;
break;
case 3:
y--;
break;
}
seq = (seq + 1) & 3;
if(id != 0) {
Color[] colors = mgr.colors.get(id);
if(colors != null) {
Color c = colors[seq];
if(c.getAlpha() > 0) {
/* we found something that isn't transparent! */
if(c.getAlpha() == 255) {
/* it's opaque - the ray ends here */
return c;
}
/* this block is transparent, so recurse */
Color bg = scan(mgr, x, y, z, seq);
int cr = c.getRed();
int cg = c.getGreen();
int cb = c.getBlue();
int ca = c.getAlpha();
cr *= ca;
cg *= ca;
cb *= ca;
int na = 255 - ca;
return new Color((bg.getRed() * na + cr) >> 8, (bg.getGreen() * na + cg) >> 8, (bg.getBlue() * na + cb) >> 8);
}
}
}
}
}
/* cast a ray into the caves */
private Color caveScan(MapManager mgr, int x, int y, int z, int seq)
{
Server s = etc.getServer();
World w = etc.getWorld();
boolean air = true;
for(;;) {
if(y < 0)
return Color.BLACK;
int id = w.getBlockAt(x, y, z).getTypeID();
switch(seq) {
case 0:
x--;
break;
case 1:
y--;
break;
case 2:
z++;
break;
case 3:
y--;
break;
}
seq = (seq + 1) & 3;
switch(id) {
case 20:
case 18:
case 17:
case 78:
case 79:
id = 0;
break;
default:
}
if(id != 0) {
air = false;
continue;
}
if(id == 0 && !air) {
int cr, cg, cb;
int mult = 256;
if(y < 64) {
cr = 0;
cg = 64 + y * 3;
cb = 255 - y * 4;
} else {
cr = (y-64) * 4;
cg = 255;
cb = 0;
}
switch(seq) {
case 0:
mult = 224;
break;
case 1:
mult = 256;
break;
case 2:
mult = 192;
break;
case 3:
mult = 160;
break;
}
cr = cr * mult / 256;
cg = cg * mult / 256;
cb = cb * mult / 256;
return new Color(cr, cg, cb);
}
}
}
}

View file

@ -0,0 +1,14 @@
package org.dynmap;
/* this class stores a tile update */
public class TileUpdate {
public long at;
public MapTile tile;
public TileUpdate(long at, MapTile tile)
{
this.at = at;
this.tile = tile;
}
}

View file

@ -0,0 +1,56 @@
package org.dynmap;
import java.io.*;
import java.net.*;
import java.util.*;
import org.bukkit.*;
import java.util.logging.Logger;
public class WebServer extends Thread {
public static final String VERSION = "Huncraft";
protected static final Logger log = Logger.getLogger("Minecraft");
private ServerSocket sock = null;
private boolean running = false;
private MapManager mgr;
public WebServer(int port, MapManager mgr) throws IOException
{
this.mgr = mgr;
sock = new ServerSocket(port, 5, InetAddress.getByName("127.0.0.1"));
running = true;
start();
log.info("map WebServer started on port " + port);
}
public void run()
{
while (running) {
try {
Socket socket = sock.accept();
WebServerRequest requestThread = new WebServerRequest(socket, mgr);
requestThread.start();
}
catch (IOException e) {
log.info("map WebServer.run() stops with IOException");
break;
}
}
log.info("map WebServer run() exiting");
}
public void shutdown()
{
try {
if(sock != null) {
sock.close();
}
} catch(IOException e) {
log.info("map stop() got IOException while closing socket");
}
running = false;
}
}

View file

@ -0,0 +1,151 @@
package org.dynmap;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.*;
public class WebServerRequest extends Thread {
protected static final Logger log = Logger.getLogger("Minecraft");
private Socket sock;
private MapManager mgr;
private map etc;
public WebServerRequest(Socket socket, MapManager mgr)
{
this.etc = mgr.etc;
sock = socket;
this.mgr = mgr;
}
private static void sendHeader(BufferedOutputStream out, int code, String contentType, long contentLength, long lastModified) throws IOException
{
out.write(("HTTP/1.0 " + code + " OK\r\n" +
"Date: " + new Date().toString() + "\r\n" +
"Server: JibbleWebServer/1.0\r\n" +
"Content-Type: " + contentType + "\r\n" +
"Expires: Thu, 01 Dec 1994 16:00:00 GMT\r\n" +
((contentLength != -1) ? "Content-Length: " + contentLength + "\r\n" : "") +
"Last-modified: " + new Date(lastModified).toString() + "\r\n" +
"\r\n").getBytes());
}
private static void sendError(BufferedOutputStream out, int code, String message) throws IOException
{
message = message + "<hr>" + WebServer.VERSION;
sendHeader(out, code, "text/html", message.length(), System.currentTimeMillis());
out.write(message.getBytes());
out.flush();
out.close();
}
public void run()
{
InputStream reader = null;
try {
sock.setSoTimeout(30000);
BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
BufferedOutputStream out = new BufferedOutputStream(sock.getOutputStream());
String request = in.readLine();
if (request == null || !request.startsWith("GET ") || !(request.endsWith(" HTTP/1.0") || request.endsWith("HTTP/1.1"))) {
// Invalid request type (no "GET")
sendError(out, 500, "Invalid Method.");
return;
}
String path = request.substring(4, request.length() - 9);
int current = (int) (System.currentTimeMillis() / 1000);
long cutoff = 0;
if(path.charAt(0) == '/') {
try {
cutoff = ((long) Integer.parseInt(path.substring(1))) * 1000;
} catch(NumberFormatException e) {
}
}
sendHeader(out, 200, "text/plain", -1, System.currentTimeMillis());
StringBuilder sb = new StringBuilder();
//sb.append(current + " " + etc.getServer().getRelativeTime() + "\n");
sb.append(current + " " + 0 +"\n");
if (mgr.showPlayers) {
for(Player player : etc.getServer().getOnlinePlayers()) {
sb.append(player.getName() + " player " + player.getLocation().getX() + " " + player.getLocation().getY() + " " + player.getLocation().getZ() + "\n");
}
}
/*if (mgr.showSigns) {
for(Warp sign : mgr.signs.values())
{
sb.append(sign.Name + " sign " + sign.Location.getX() + " " + sign.Location.getY() + " " + sign.Location.getZ() + "\n");
}
}
if (mgr.showWarps) {
List<Warp> warps = mgr.loadWarps();
if (warps != null) {
for(Warp warp : warps) {
sb.append(warp.Name + " warp " + warp.Location.getX() + " " + warp.Location.getY() + " " + warp.Location.getZ() + "\n");
}
}
}
if (mgr.showHomes) {
List<Warp> homes = mgr.loadHomes();
if (homes != null) {
for(Warp warp : homes) {
sb.append(warp.Name + " home " + warp.Location.x + " " + warp.Location.y + " " + warp.Location.z + "\n");
}
}
}
if (mgr.showSpawn) {
Location spawnLocation = etc.getServer().getSpawnLocation();
sb.append("Spawn spawn " + spawnLocation.x + " " + spawnLocation.y + " " + spawnLocation.z + "\n");
}*/
synchronized(mgr.lock) {
for(TileUpdate tu : mgr.tileUpdates) {
if(tu.at >= cutoff) {
sb.append(tu.tile.px + "_" + tu.tile.py + " " + tu.tile.zpx + "_" + tu.tile.zpy + " t\n");
}
}
for(TileUpdate tu : mgr.caveTileUpdates) {
if(tu.at >= cutoff) {
sb.append(tu.tile.px + "_" + tu.tile.py + " " + tu.tile.zpx + "_" + tu.tile.zpy + " c\n");
}
}
}
out.write(sb.toString().getBytes());
out.flush();
out.close();
}
catch (IOException e) {
if (reader != null) {
try {
reader.close();
}
catch (Exception anye) {
// Do nothing.
}
}
}
}
}

View file

@ -0,0 +1,77 @@
package org.dynmap;
import java.util.logging.Logger;
import java.io.IOException;
import java.io.File;
import org.bukkit.*;
import org.bukkit.event.*;
import org.bukkit.event.Event.Priority;
import org.bukkit.plugin.*;
import org.bukkit.plugin.java.*;
public class map extends JavaPlugin {
protected static final Logger log = Logger.getLogger("Minecraft");
private WebServer server = null;
private MapManager mgr = null;
private MapListener listener = null;
public map(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File plugin, ClassLoader cLoader) {
super(pluginLoader, instance, desc, plugin, cLoader);
}
public World getWorld() {
return getServer().getWorlds()[0];
}
@Override
public void onEnable() {
log.info("Map INIT");
mgr = new MapManager(this);
mgr.startManager();
try {
server = new WebServer(mgr.serverport, mgr);
} catch(IOException e) {
log.info("position failed to start WebServer (IOException)");
}
listener = new MapListener(mgr);
registerEvents();
}
@Override
public void onDisable() {
log.info("Map UNINIT");
mgr.stopManager();
if(server != null) {
server.shutdown();
server = null;
}
}
public void registerEvents() {
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_PLACED, listener, Priority.Normal, this);
//getServer().getPluginManager().registerEvent(Event.Type.BLOCK_DESTROYED, listener, Priority.Normal, this);
/* etc.getLoader().addListener(PluginLoader.Hook.COMMAND, listener, this, PluginListener.Priority.MEDIUM);
etc.getLoader().addListener(PluginLoader.Hook.BLOCK_CREATED, listener, this, PluginListener.Priority.MEDIUM);
etc.getLoader().addListener(PluginLoader.Hook.BLOCK_DESTROYED, listener, this, PluginListener.Priority.MEDIUM);
etc.getLoader().addListener(PluginLoader.Hook.LOGIN, listener, this, PluginListener.Priority.MEDIUM);
etc.getInstance().addCommand("/map_wait", " [wait] - set wait between tile renders (ms)");
etc.getInstance().addCommand("/map_stat", " - query number of tiles in render queue");
etc.getInstance().addCommand("/map_regen", " - regenerate entire map");
etc.getInstance().addCommand("/map_debug", " - send map debugging messages");
etc.getInstance().addCommand("/map_nodebug", " - disable map debugging messages");
etc.getInstance().addCommand("/addsign", " [name] - adds a named sign to the map");
etc.getInstance().addCommand("/removesign", " [name] - removes a named sign to the map");
etc.getInstance().addCommand("/listsigns", " - list all named signs");
etc.getInstance().addCommand("/tpsign", " [name] - teleport to a named sign");*/
}
}