Initial bukket work, now compileable

This commit is contained in:
FrozenCow 2011-01-03 23:15:58 +01:00
parent 3c7f164823
commit 80f9435a1a
11 changed files with 314 additions and 272 deletions

View File

@ -1,16 +1,11 @@
<project name="dynmap" default="dist" basedir="."> <project name="dynmap" default="dist" basedir=".">
<!-- Change the following two properties to the correct jar files --> <property name="pluginname" value="dynmap"/>
<property name="minecraftserver.jar" location="../../minecraft_server.jar"/> <property name="bukkit.jar" location="../../bukkit.jar"/>
<property name="hmod.jar" location="../../Minecraft_Mod.jar"/> <property name="plugins" location="../../plugins/"/>
<property name="minecraft" location="../../"/>
<property name="plugins" location="${minecraft}/plugins/"/>
<property name="http_root" location="/srv/http/dynmap/"/>
<property name="src" location="src"/> <property name="src" location="src"/>
<property name="bin" location="bin"/> <property name="bin" location="bin"/>
<property name="dist" location="dist"/> <property name="dist" location="dist"/>
<property name="web" location="web"/>
<target name="init"> <target name="init">
<mkdir dir="${bin}"/> <mkdir dir="${bin}"/>
@ -19,38 +14,25 @@
<target name="compile" depends="init"> <target name="compile" depends="init">
<javac srcdir="${src}" destdir="${bin}" includeantruntime="false"> <javac srcdir="${src}" destdir="${bin}" includeantruntime="false">
<classpath> <classpath>
<pathelement location="${hmod.jar}"/> <pathelement location="${bukkit.jar}"/>
<pathelement location="${minecraftserver.jar}"/>
</classpath> </classpath>
</javac> </javac>
</target> </target>
<target name="dist" depends="compile"> <target name="dist" depends="compile">
<mkdir dir="${dist}"/> <mkdir dir="${dist}"/>
<jar jarfile="${dist}/map.jar" basedir="${bin}"/> <jar jarfile="${dist}/${pluginname}.jar">
<fileset dir="${bin}"/>
<fileset file="${src}/plugin.yml"/>
</jar>
</target> </target>
<target name="deploy" depends="dist"> <target name="deploy" depends="dist">
<copy file="${dist}/map.jar" todir="${plugins}"/> <copy file="${dist}/${pluginname}.jar" todir="${plugins}"/>
<copy file="colors.txt" todir="${minecraft}"/>
<copy todir="${http_root}">
<fileset dir="web"/>
</copy>
</target>
<target name="release" depends="dist">
<delete file="dynmap.zip"/>
<zip destfile="dynmap.zip">
<zipfileset dir="." includes="README.md" fullpath="readme.txt"/>
<zipfileset dir="." includes="build.xml"/>
<zipfileset dir="${dist}" includes="*.jar"/>
<zipfileset dir="${src}" includes="*.java" prefix="src/"/>
<zipfileset dir="${web}" includes="**" prefix="web/"/>
</zip>
</target> </target>
<target name="clean"> <target name="clean">
<delete dir="${bin}"/> <delete dir="${bin}"/>
<delete dir="${dist}"/> <delete dir="${dist}"/>
</target> </target>
</project> </project>

View File

@ -2,12 +2,12 @@
import java.util.List; import java.util.List;
public class DMFlatFileSource extends FlatFileSource { public class DMFlatFileSource{/* extends FlatFileSource {
public List<Warp> getAllWarps() { public List<Warp> getAllWarps() {
return this.warps; return this.warps;
} }
public List<Warp> getAllHomes() { public List<Warp> getAllHomes() {
return this.homes; return this.homes;
} }*/
} }

View File

@ -2,12 +2,12 @@
import java.util.List; import java.util.List;
public class DMMySQLSource extends MySQLSource { public class DMMySQLSource{/* extends MySQLSource {
public List<Warp> getAllWarps() { public List<Warp> getAllWarps() {
return this.warps; return this.warps;
} }
public List<Warp> getAllHomes() { public List<Warp> getAllHomes() {
return this.homes; return this.homes;
} }*/
} }

View File

@ -2,8 +2,10 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.*;
import org.bukkit.event.block.*;
public class MapListener extends PluginListener { public class MapListener extends BlockListener {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private MapManager mgr; private MapManager mgr;
@ -12,6 +14,14 @@ public class MapListener extends PluginListener {
this.mgr = 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 @Override
public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicked, int itemInHand) public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicked, int itemInHand)
{ {
@ -147,5 +157,5 @@ public class MapListener extends PluginListener {
} }
return false; return false;
} }*/
} }

View File

@ -30,11 +30,15 @@ import java.util.Vector;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.*;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
public class MapManager extends Thread { public class MapManager extends Thread {
protected static final Logger log = Logger.getLogger("Minecraft"); protected static final Logger log = Logger.getLogger("Minecraft");
public map etc;
/* dimensions of a map tile */ /* dimensions of a map tile */
public static final int tileWidth = 128; public static final int tileWidth = 128;
public static final int tileHeight = 128; public static final int tileHeight = 128;
@ -93,7 +97,7 @@ public class MapManager extends Thread {
public String debugPlayer = null; public String debugPlayer = null;
/* hashmap of signs */ /* hashmap of signs */
public HashMap<String, Warp> signs = null; //public HashMap<String, Warp> signs = null;
/* cache this many zoomed-out tiles */ /* cache this many zoomed-out tiles */
public static final int zoomCacheSize = 64; public static final int zoomCacheSize = 64;
@ -121,13 +125,14 @@ public class MapManager extends Thread {
Server s = etc.getServer(); Server s = etc.getServer();
Player p = s.getPlayer(debugPlayer); Player p = s.getPlayer(debugPlayer);
if(p == null) return; if(p == null) return;
p.sendMessage("Map> " + Colors.Red + msg); p.sendMessage("Map> " + Color.RED + msg);
} }
public MapManager() public MapManager(map plugin)
{ {
etc = plugin;
/* load configuration */ /* load configuration */
PropertiesFile properties; /*PropertiesFile properties;
properties = new PropertiesFile("server.properties"); properties = new PropertiesFile("server.properties");
try { try {
@ -140,7 +145,21 @@ public class MapManager extends Thread {
generatePortraits = !properties.getString("map-generateportraits", "0").equals("0"); generatePortraits = !properties.getString("map-generateportraits", "0").equals("0");
} catch(Exception ex) { } catch(Exception ex) {
log.log(Level.SEVERE, "Exception while reading properties for dynamic map", 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>(); tileStore = new HashMap<Long, MapTile>();
staleTiles = new LinkedList<MapTile>(); staleTiles = new LinkedList<MapTile>();
@ -149,9 +168,9 @@ public class MapManager extends Thread {
caveTileUpdates = new LinkedList<TileUpdate>(); caveTileUpdates = new LinkedList<TileUpdate>();
zoomCache = new Cache<String, BufferedImage>(zoomCacheSize); zoomCache = new Cache<String, BufferedImage>(zoomCacheSize);
signs = new HashMap<String, Warp>(); // signs = new HashMap<String, Warp>();
loadShowOptions(); // loadShowOptions();
} }
/* tile X for position x */ /* tile X for position x */
@ -199,7 +218,7 @@ public class MapManager extends Thread {
/* load colorset */ /* load colorset */
File cfile = new File(colorsetpath); File cfile = new File(colorsetpath);
loadSigns(); //loadSigns();
try { try {
Scanner scanner = new Scanner(cfile); Scanner scanner = new Scanner(cfile);
@ -442,7 +461,7 @@ public class MapManager extends Thread {
if(t == null) { if(t == null) {
/* no maptile exists, need to create one */ /* no maptile exists, need to create one */
t = new MapTile(px, py, ztilex(px), ztiley(py)); t = new MapTile(etc, px, py, ztilex(px), ztiley(py));
tileStore.put(key, t); tileStore.put(key, t);
return t; return t;
} else { } else {
@ -485,11 +504,12 @@ public class MapManager extends Thread {
open.add(first); open.add(first);
Server s = etc.getServer(); Server s = etc.getServer();
World w = etc.getWorld();
while(open.size() > 0) { while(open.size() > 0) {
MapTile t = open.remove(open.size() - 1); MapTile t = open.remove(open.size() - 1);
if(t.stale) continue; if(t.stale) continue;
int h = s.getHighestBlockY(t.mx, t.mz); int h = w.getHighestBlockYAt(t.mx, t.mz);
log.info("walking: " + t.mx + ", " + t.mz + ", h = " + h); log.info("walking: " + t.mx + ", " + t.mz + ", h = " + h);
if(h < 1) if(h < 1)
@ -651,7 +671,7 @@ public class MapManager extends Thread {
} }
/* adds a sign to the map */ /* adds a sign to the map */
public boolean addSign(Player player, String name, double px, double py, double pz) /* public boolean addSign(Player player, String name, double px, double py, double pz)
{ {
if (signs.containsKey(name)) if (signs.containsKey(name))
{ {
@ -675,10 +695,10 @@ public class MapManager extends Thread {
} }
return false; return false;
} }*/
/* removes a sign from the map */ /* removes a sign from the map */
public boolean removeSign(Player player, String name) /* public boolean removeSign(Player player, String name)
{ {
if (signs.containsKey(name)) if (signs.containsKey(name))
{ {
@ -702,10 +722,10 @@ public class MapManager extends Thread {
} }
return false; return false;
} }*/
/* teleports a user to a sign */ /* teleports a user to a sign */
public boolean teleportToSign(Player player, String name) /* public boolean teleportToSign(Player player, String name)
{ {
if (signs.containsKey(name)) if (signs.containsKey(name))
{ {
@ -719,10 +739,10 @@ public class MapManager extends Thread {
} }
return false; return false;
} }*/
/* load the map sign file */ /* load the map sign file */
private void loadSigns() /* private void loadSigns()
{ {
Scanner scanner = null; Scanner scanner = null;
try try
@ -779,10 +799,10 @@ public class MapManager extends Thread {
{ {
if (scanner != null) scanner.close(); if (scanner != null) scanner.close();
} }
} }*/
/* save the map sign file */ /* save the map sign file */
private void saveSigns() throws IOException /* private void saveSigns() throws IOException
{ {
Writer out = null; Writer out = null;
try try
@ -809,11 +829,11 @@ public class MapManager extends Thread {
{ {
if (out != null) out.close(); 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? */ /* TODO: Is there a cleaner way to get warps/homes than using custom DataSource classes to expose the protected properties? */
protected List<Warp> loadWarps() /* protected List<Warp> loadWarps()
{ {
List<Warp> warps = null; List<Warp> warps = null;
@ -940,5 +960,5 @@ public class MapManager extends Thread {
} }
return success; return success;
} }*/
} }

View File

@ -8,6 +8,8 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.bukkit.World;
import org.bukkit.Server;
public class MapTile { public class MapTile {
protected static final Logger log = Logger.getLogger("Minecraft"); protected static final Logger log = Logger.getLogger("Minecraft");
@ -27,9 +29,11 @@ public class MapTile {
/* whether the cave map of this tile needs to be updated */ /* whether the cave map of this tile needs to be updated */
boolean staleCave = false; boolean staleCave = false;
private map etc;
/* create new MapTile */ /* create new MapTile */
public MapTile(int px, int py, int zpx, int zpy) public MapTile(map etc, int px, int py, int zpx, int zpy)
{ {
this.etc = etc;
this.px = px; this.px = px;
this.py = py; this.py = py;
this.zpx = zpx; this.zpx = zpx;
@ -51,17 +55,19 @@ public class MapTile {
int x, z; int x, z;
Server s = etc.getServer(); Server s = etc.getServer();
World w = etc.getWorld();
for(x=x1; x<x2; x+=16) { for(x=x1; x<x2; x+=16) {
for(z=z1; z<z2; z+=16) { for(z=z1; z<z2; z+=16) {
if(!s.isChunkLoaded(x, 0, z)) { if(!w.isChunkLoaded(w.getChunkAt(x, z))) {
log.info("map render loading chunk: " + x + ", 0, " + z); log.info("chunk not loaded: " + x + ", 0, " + z);
/*
try { try {
s.loadChunk(x, 0, z); s.loadChunk(x, 0, z);
} catch(Exception e) { } catch(Exception e) {
log.log(Level.SEVERE, "Caught exception from loadChunk!", e); log.log(Level.SEVERE, "Caught exception from loadChunk!", e);
} }*/
} }
} }
} }
@ -78,10 +84,11 @@ public class MapTile {
int x, z; int x, z;
Server s = etc.getServer(); Server s = etc.getServer();
World w = etc.getWorld();
for(x=x1; x<x2; x+=16) { for(x=x1; x<x2; x+=16) {
for(z=z1; z<z2; z+=16) { for(z=z1; z<z2; z+=16) {
if(!s.isChunkLoaded(x, 0, z)) { if(!w.isChunkLoaded(w.getChunkAt(x, z))) {
// Will try to load chunk. // Will try to load chunk.
//log.info("chunk not loaded: " + x + ", " + z + " for tile " + this.toString()); //log.info("chunk not loaded: " + x + ", " + z + " for tile " + this.toString());
@ -380,12 +387,12 @@ public class MapTile {
private Color scan(MapManager mgr, int x, int y, int z, int seq) private Color scan(MapManager mgr, int x, int y, int z, int seq)
{ {
Server s = etc.getServer(); Server s = etc.getServer();
World w = etc.getWorld();
for(;;) { for(;;) {
if(y < 0) if(y < 0)
return Color.BLUE; return Color.BLUE;
int id = s.getBlockIdAt(x, y, z); int id = w.getBlockAt(x, y, z).getTypeID();
switch(seq) { switch(seq) {
case 0: case 0:
@ -438,13 +445,14 @@ public class MapTile {
private Color caveScan(MapManager mgr, int x, int y, int z, int seq) private Color caveScan(MapManager mgr, int x, int y, int z, int seq)
{ {
Server s = etc.getServer(); Server s = etc.getServer();
World w = etc.getWorld();
boolean air = true; boolean air = true;
for(;;) { for(;;) {
if(y < 0) if(y < 0)
return Color.BLACK; return Color.BLACK;
int id = s.getBlockIdAt(x, y, z); int id = w.getBlockAt(x, y, z).getTypeID();
switch(seq) { switch(seq) {
case 0: case 0:

View File

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

View File

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

View File

@ -1,7 +1,14 @@
import java.util.logging.Logger; import java.util.logging.Logger;
import java.io.IOException; import java.io.IOException;
public class map extends Plugin { 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"); protected static final Logger log = Logger.getLogger("Minecraft");
@ -9,11 +16,20 @@ public class map extends Plugin {
private MapManager mgr = null; private MapManager mgr = null;
private MapListener listener = null; private MapListener listener = null;
public map(PluginLoader pluginLoader, Server instance, PluginDescriptionFile desc, File plugin, ClassLoader cLoader) {
super(pluginLoader, instance, desc, plugin, cLoader);
registerEvents();
}
public World getWorld() {
return getServer().getWorlds()[0];
}
@Override @Override
public void enable() { public void onEnable() {
log.info("Map INIT"); log.info("Map INIT");
mgr = new MapManager(); mgr = new MapManager(this);
mgr.startManager(); mgr.startManager();
try { try {
@ -26,7 +42,7 @@ public class map extends Plugin {
} }
@Override @Override
public void disable() { public void onDisable() {
log.info("Map UNINIT"); log.info("Map UNINIT");
mgr.stopManager(); mgr.stopManager();
@ -37,9 +53,10 @@ public class map extends Plugin {
} }
} }
@Override public void registerEvents() {
public void initialize() { getServer().getPluginManager().registerEvent(Event.Type.BLOCK_PLACED, listener, Priority.Normal, this);
etc.getLoader().addListener(PluginLoader.Hook.COMMAND, listener, this, PluginListener.Priority.MEDIUM); //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_CREATED, listener, this, PluginListener.Priority.MEDIUM);
etc.getLoader().addListener(PluginLoader.Hook.BLOCK_DESTROYED, 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.getLoader().addListener(PluginLoader.Hook.LOGIN, listener, this, PluginListener.Priority.MEDIUM);
@ -52,6 +69,6 @@ public class map extends Plugin {
etc.getInstance().addCommand("/addsign", " [name] - adds a named sign to the map"); 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("/removesign", " [name] - removes a named sign to the map");
etc.getInstance().addCommand("/listsigns", " - list all named signs"); etc.getInstance().addCommand("/listsigns", " - list all named signs");
etc.getInstance().addCommand("/tpsign", " [name] - teleport to a named sign"); etc.getInstance().addCommand("/tpsign", " [name] - teleport to a named sign");*/
} }
} }

View File

@ -1,3 +1,3 @@
Set map.js tileUrl to this folder Set map.js tileUrl to this folder
Also set map-tilepath in server.properties to point to this folder. Also set map-tilepath in server.properties to point to this folder.
New tile images will be generated here by the plugin New tile images will be generated here by the plugin

View File

@ -1,2 +1,2 @@
default.aspx is not required for all installations. default.aspx is not required for all installations.
If you are running a windows server with IIS, it may help in your setup. If you are running a windows server with IIS, it may help in your setup.