Compare commits

...

92 Commits

Author SHA1 Message Date
FrozenCow 553eb7952d Added ability to disable commands in configuration. 2011-02-07 17:25:16 +01:00
FrozenCow 421b91058a Merge https://github.com/kosiini/dynmap 2011-02-07 17:01:39 +01:00
Janne Sinisalo 100a03274c Compile fix for multiworld
Updated getWorlds()[0] to getWorlds().get(0)
2011-02-07 17:42:11 +02:00
FrozenCow d2b7169884 Workaround for IE's retardness (not yet tested). 2011-02-06 15:09:15 +01:00
FrozenCow 3e398e9124 Made updates in JSON format. Combined chat and tile queues into one UpdateQueue. Fixed UpdateQueue. 2011-02-06 03:00:51 +01:00
FrozenCow 7c257af454 Fixed Json stringify. 2011-02-06 02:00:27 +01:00
FrozenCow a937d13086 Added reflection-support for stringifyJson. 2011-02-05 21:09:49 +01:00
FrozenCow d651d58d63 Moved stringifyJson to Json class. 2011-02-05 21:02:39 +01:00
FrozenCow 9a655676ab Moved FileHandler to handlers package. 2011-02-05 20:54:28 +01:00
FrozenCow debf5bcc57 Renamed WebServer to HttpServer and WebServerRequest to HttpServerConnection. 2011-02-05 20:53:42 +01:00
FrozenCow 2a79aea7bb Moved handlers to their own (independent) classes. 2011-02-05 20:51:20 +01:00
FrozenCow 883eba6890 Removed debugging + small fix. 2011-02-05 19:57:32 +01:00
FrozenCow 226cc5f86c More work on HttpServer. 2011-02-05 19:51:48 +01:00
FrozenCow bf0edea7e2 Initial http-server work. 2011-02-05 19:51:48 +01:00
FrozenCow 711341ec47 Oops, forgot comma. 2011-02-05 19:51:06 +01:00
FrozenCow 14a3d32205 Used colors.txt from lechd. 2011-02-05 17:49:11 +01:00
FrozenCow 9f555bd4bb Added 'loadChunks' to configuration. 2011-02-05 03:03:52 +01:00
FrozenCow 902cc87458 Added 'focuschatballoons' to config influenced by Incendia's suggestion. 2011-02-05 02:59:03 +01:00
FrozenCow 9951baf8b5 Made tiles use nearest-neighbor filtering in Firefox and IE as suggested by lechd. 2011-02-05 02:54:06 +01:00
FrozenCow 335109d8c7 Added pumpkin colors as suggested by lechd. 2011-02-05 02:53:22 +01:00
FrozenCow 3940b91d0e Applied Eclipse formatting. 2011-02-05 02:25:18 +01:00
FrozenCow 4f138a56da Removed comments. 2011-02-05 02:11:49 +01:00
FrozenCow c8cf39a440 Added unstable fullmap rendering. Also... messed up formatting by pressing ctrl+shift+f in eclipse, sigh 2011-02-05 02:01:04 +01:00
FrozenCow 138aed8c33 Added chunk loading to rendering. 2011-02-04 23:12:55 +01:00
FrozenCow fde56275fe Changed day/night time as suggested by lologarithm. 2011-02-02 11:58:14 +01:00
FrozenCow 13e829cda0 Updated Server.getTime to World.getTime (to reflect Bukkit's changes) 2011-02-02 11:40:49 +01:00
FrozenCow 455b5d3b3e Added showchatballoons, showplayerfacesonmap and showplayerfacesinmenu to configuration. 2011-02-01 15:16:54 +01:00
FrozenCow 8abf596ba6 Organized imports. 2011-02-01 14:23:13 +01:00
FrozenCow 1beb4fa466 Added server-to-client configuration and maptype-configuration: enables serverside configuration of maps and updaterate. 2011-02-01 14:17:08 +01:00
FrozenCow e47b4dc49f Small fixes to chat-balloons. 2011-01-26 01:05:00 +01:00
FrozenCow 3ff0b85ef7 Merge branch 'master' of https://github.com/NathanWolf/dynmap 2011-01-26 00:39:48 +01:00
FrozenCow 99ae8a8f3b Moved Web* to webpackage and added server-to-client configuration (server-side). 2011-01-26 00:38:36 +01:00
Nathan Wolf 18b36f96fe Finish the client-side chat bubble interface:
- Bubbles disappear automatically after some time
 - Each bubble shows the last 5 messages for each player
 - Some formatting to the bubble done, could be better (add high-res
player pic?)
2011-01-25 15:10:42 -08:00
FrozenCow 36d1a7676e Merge branch 'master' of https://github.com/NathanWolf/dynmap 2011-01-25 23:06:48 +01:00
Nathan Wolf f14e097c54 Adding chat message pop-ups! 2011-01-25 14:03:27 -08:00
FrozenCow 4de18ac700 Changed startup message (shows webserver-info, hides debug) 2011-01-25 22:59:22 +01:00
FrozenCow 98f03c588e Added ignores. 2011-01-25 22:56:35 +01:00
FrozenCow 5ee5fee232 Added getters/setters. 2011-01-25 18:43:11 +01:00
FrozenCow c2047fe7c4 Fixed webpath and tilepath accepting absolute paths. 2011-01-23 19:56:59 +01:00
FrozenCow 34093874bc Changed /map to /dynmap. 2011-01-23 12:07:23 +01:00
FrozenCow 676f6c5a3e Made it possible to change background color in style.css 2011-01-23 12:00:15 +01:00
FrozenCow 9ea9e347ea Changed proxy-url to /up/ as ktr suggested. 2011-01-22 14:55:50 -08:00
FrozenCow 75efba1425 Fixed comment in config.js. 2011-01-20 23:29:38 +01:00
FrozenCow 6419469be3 Added ability to hide players (/map hide, /map hide playername(s) and /map show). 2011-01-20 22:56:39 +01:00
FrozenCow 68412ae27d Changed '/map_render' to '/map render'. 2011-01-20 20:50:18 +01:00
FrozenCow bcb25468db Added aspx for proxying on IIS. 2011-01-20 20:48:00 +01:00
FrozenCow 78b243371d Fixed red and yellow colors for flowers. 2011-01-19 19:29:37 +01:00
FrozenCow 867f069822 Added new minecraft-blocks to colors. 2011-01-18 20:54:47 +01:00
FrozenCow 7dec76aadc Removed web from jar. 2011-01-18 20:54:32 +01:00
FrozenCow b27fcdbd4b Changed configuration to key/value instead of full YAML. 2011-01-18 20:08:05 +01:00
FrozenCow 9b8a90bf9f Added some of the configuration options. (not all yet) 2011-01-16 21:44:03 +01:00
FrozenCow 3aa48f2215 Added configuration and renamed Map to MapType. 2011-01-16 18:09:58 +01:00
FrozenCow ce60452a35 Fix to be compatible with latest Bukkit. 2011-01-16 11:51:56 +01:00
Arthur Mayer 08ba9de51c changed dependencie from java version 1.5 to 1.6 in maven project file 2011-01-16 00:35:38 +01:00
flames 9f1c8f548a reverted pom.xml back to its old version 2011-01-16 00:35:19 +01:00
FrozenCow 18a1f484d8 Fixed to be compatible with latest Dynmap. 2011-01-15 23:18:16 +01:00
FrozenCow 53e7ab73a0 Fix to reflect Bukkit's changes. Also fixes the threading-problems. 2011-01-15 21:44:27 +01:00
FrozenCow 6205aee3b6 Updated maven buildfile, removed depricated readmes. 2011-01-15 12:13:54 +01:00
FrozenCow 32567b8569 Removed hardcoded path, sigh. 2011-01-15 03:33:30 +01:00
FrozenCow b501f1d8cb More exception handling and messages. 2011-01-15 02:57:11 +01:00
FrozenCow b22a48d5cb Fixed small browser incompatibilities 2011-01-15 02:11:31 +01:00
FrozenCow b5deec79be Enabled hack for faster rendering when zoomed in, which also fixed a bug that was annoying to fix. 2011-01-15 00:02:03 +01:00
FrozenCow d594df93ee Fixed little bug. 2011-01-15 00:01:44 +01:00
FrozenCow 686b09bc9d Tiles will now also generate when destroying blocks. 2011-01-14 23:41:13 +01:00
FrozenCow dfc051743d Better way of handling inheriting in javascript. 2011-01-14 23:38:50 +01:00
FrozenCow dfe33efdc3 Made dynmap's javascript self-contained, which allows for multiple maps on a single page. 2011-01-14 20:08:23 +01:00
FrozenCow 77b0bc1664 More debug messages. 2011-01-14 20:05:12 +01:00
FrozenCow 2e1a9d0a0e Changed Color to ChatColor to reflect Bukkits changes. 2011-01-14 14:51:29 +01:00
FrozenCow ff5f96aa78 Small fix for loadColorSet. 2011-01-13 15:33:30 +01:00
FrozenCow 342a72f39f Made colors load from jar when not found in filesystem. 2011-01-13 11:18:54 +01:00
FrozenCow 4f0e89b1d8 Set tilePath to 'tiles/'. 2011-01-13 01:57:19 +01:00
FrozenCow c4cce7182a More cleanup. 2011-01-12 02:03:31 +01:00
FrozenCow d634aede92 Minor cleaups. 2011-01-12 01:45:56 +01:00
FrozenCow 27fb8a20f1 Abstracted clock and tile-updating a bit. 2011-01-12 01:28:45 +01:00
FrozenCow 8263918b8d Abstracted from cave+normal to kzedmaps. Can now have any configurable type of map. 2011-01-10 23:58:39 +01:00
FrozenCow 4b5e6e6f80 Cleaned up client-side tile logic. 2011-01-10 01:28:50 +01:00
FrozenCow c8a08b5af7 Commented debug-tile-grid. 2011-01-10 00:43:23 +01:00
FrozenCow ce7bfdb46e Small cleanup. 2011-01-10 00:38:18 +01:00
FrozenCow a08edc3fa9 Fixed zoomed tile/player not fitting unzoomed. 2011-01-10 00:31:44 +01:00
FrozenCow 2b2891bd0a Readded zoom-tiles. Still needs some work. 2011-01-09 01:12:35 +01:00
FrozenCow e1a3ac60e2 Cleanup/Refactoring. 2011-01-08 18:56:08 +01:00
FrozenCow 8860eb8c04 Splitted up MapManager. 2011-01-08 03:20:51 +01:00
FrozenCow 90afd9ef82 Restructured MapManager. 2011-01-07 15:36:50 +01:00
FrozenCow 6a7559f3ad Expanded internal webserver to also handle web and tiles, where web-files can be retrieved from filesystem or jar. Also some debugging changes. 2011-01-07 04:50:43 +01:00
flames b4fca31cd5 added configvariable bindaddress (thanks FrozenCow) 2011-01-07 02:52:59 +01:00
FrozenCow 8162817041 Reenabled time again by using Bukkit's getTime. 2011-01-06 16:37:54 +01:00
FrozenCow c5d5a85a17 Separated rendering from MapTile, removed separate cave logic (integrated in rendering) and temporarily removed/disabled zoom-rendering. 2011-01-06 03:30:50 +01:00
flames 225d28e177 Added maven build file 2011-01-06 01:50:45 +01:00
FrozenCow 4261f30dcd Made code better fit for Bukkit. 2011-01-05 21:19:11 +01:00
FrozenCow eafc8a858c Added seperate file for ant build parameters. 2011-01-05 21:17:27 +01:00
FrozenCow f0ec375834 Put classes in package to be more compatible with Bukkit. 2011-01-05 19:41:21 +01:00
FrozenCow 80f9435a1a Initial bukket work, now compileable 2011-01-03 23:15:58 +01:00
64 changed files with 3398 additions and 2625 deletions
+25
View File
@@ -0,0 +1,25 @@
# Eclipse stuff
/.classpath
/.project
/.settings
# netbeans
/nbproject
# we use maven!
/build.xml
# maven
/target
# vim
.*.sw[a-p]
# various other potential build files
/build
/bin
/dist
/manifest.mf
# Mac filesystem dust
/.DS_Store
+15 -20
View File
@@ -1,46 +1,41 @@
<project name="dynmap" default="dist" basedir=".">
<!-- Change the following two properties to the correct jar files -->
<property name="minecraftserver.jar" location="../../minecraft_server.jar"/>
<property name="hmod.jar" location="../../Minecraft_Mod.jar"/>
<property name="bukkit.jar" location="C:\Users\Bob\Desktop\minecraft_server\bukkit-0.0.1-SNAPSHOT.jar"/>
<property name="minecraft" location="C:\Users\Bob\Desktop\minecraft_server"/>
<property name="plugins" location="${minecraft}/plugins/"/>
<property name="http_root" location="/srv/http/dynmap/"/>
<property name="pluginname" value="dynmap"/>
<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="bin" location="bin"/>
<property name="dist" location="dist"/>
<property name="web" location="web"/>
<target name="init">
<mkdir dir="${bin}"/>
</target>
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${bin}" includeantruntime="false">
<classpath>
<pathelement location="${hmod.jar}"/>
<pathelement location="${minecraftserver.jar}"/>
</classpath>
</javac>
<javac srcdir="${src}/main/java" destdir="${bin}" classpath="${bukkit.jar}" debug="on" includeantruntime="false" />
</target>
<target name="dist" depends="compile">
<mkdir dir="${dist}"/>
<jar jarfile="${dist}/map.jar" basedir="${bin}"/>
<jar jarfile="${dist}/${pluginname}.jar">
<fileset dir="${bin}"/>
<fileset file="${src}/main/resources/plugin.yml"/>
<zipfileset file="${src}/main/resources/colors.txt"/>
</jar>
</target>
<target name="deploy" depends="dist">
<copy file="${dist}/map.jar" todir="${plugins}"/>
<copy file="colors.txt" todir="${minecraft}"/>
<copy file="${dist}/${pluginname}.jar" todir="${plugins}"/>
<copy todir="${http_root}">
<fileset dir="web"/>
</copy>
</target>
<target name="release" depends="dist">
<delete file="dynmap.zip"/>
<zip destfile="dynmap.zip">
<delete file="${pluginname}.zip"/>
<zip destfile="${pluginname}.zip">
<zipfileset dir="." includes="README.md" fullpath="readme.txt"/>
<zipfileset dir="." includes="build.xml"/>
<zipfileset dir="${dist}" includes="*.jar"/>
@@ -53,4 +48,4 @@
<delete dir="${bin}"/>
<delete dir="${dist}"/>
</target>
</project>
</project>
+6
View File
@@ -0,0 +1,6 @@
<project name="dynmap_parameters" basedir=".">
<property name="bukkit.jar" location="../../bukkit.jar"/>
<property name="minecraft" location="../../"/>
<property name="plugins" location="${minecraft}/plugins/"/>
<property name="http_root" location="/srv/http/dynmap/"/>
</project>
+54
View File
@@ -0,0 +1,54 @@
# All paths in this configuration file are relative to Dynmap's data-folder: minecraft_server/plugins/dynmap/
# How often a tile gets rendered (in seconds).
renderinterval: 1
# When enabled Dynmap will preload chunks before rendering a tile. This will avoid Dynmap rendering unloaded (=partially blue) tiles.
# This WILL impact memory and diskio.
loadChunks: false
# The path where the tile-files are placed.
tilepath: web/tiles
# The path where the web-files are located.
webpath: web
# The network-interface the webserver will bind to (0.0.0.0 for all interfaces, 127.0.0.1 for only local access).
webserver-bindaddress: 0.0.0.0
# The TCP-port the webserver will listen on.
webserver-port: 8123
disabledcommands:
- fullrender
- fullrenderasync
# The maptypes Dynmap will use to render.
maps:
- class: org.dynmap.kzedmap.KzedMap
renderers:
- class: org.dynmap.kzedmap.DefaultTileRenderer
prefix: t
- class: org.dynmap.kzedmap.CaveTileRenderer
prefix: ct
web:
# Interval the browser should poll for updates.
updaterate: 2000
showchatballoons: true
showplayerfacesonmap: true
showplayerfacesinmenu: true
focuschatballoons: false
# The name of the map shown when opening Dynmap's page (must be in menu).
defaultmap: defaultmap
# The maps shown in the menu.
shownmaps:
- type: KzedMapType
name: defaultmap
prefix: t
- type: KzedMapType
name: cavemap
prefix: ct
+30
View File
@@ -0,0 +1,30 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.bukkit</groupId>
<artifactId>dynamic-map</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>DynamicMap</name>
<url>http://www.bukkit.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
-22
View File
@@ -1,22 +0,0 @@
Commands
--------------------------------------------------
/map_wait [wait] - set wait between tile renders (ms)
/map_stat - query number of tiles in render queue
/map_regen - regenerate entire map (currently buggy)
/map_debug - send map debugging messages
/map_nodebug - disable map debugging messages
/map_regenzoom - regenerates zoom-out tiles
/addsign [name] - adds a named sign to the map
/removesign [name] - removes a named sign to the map
/listsigns - list all named signs
/tpsign [name] - teleport to a named sign
server.properties
--------------------------------------------------
map-colorsetpath - point to colors.txt
map-tilepath - point to web/tiles folder
map-signspath - point to signs.txt file (do not need to create the file, one will be created when you create a sign)
map-serverport - the port the web server runs on (default is 8123)
map-showmarkers - a list of which markers to show on the map, comma separated if multiple (spawn, homes, warps, signs, players, all, none)
map-generateportraits - whether player-portraits are generated by the server (0, 1, default: 0)
-114
View File
@@ -1,114 +0,0 @@
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;
}
}
}
-13
View File
@@ -1,13 +0,0 @@
/* FlatFileSource class wrapper to expose protected properties */
import java.util.List;
public class DMFlatFileSource extends FlatFileSource {
public List<Warp> getAllWarps() {
return this.warps;
}
public List<Warp> getAllHomes() {
return this.homes;
}
}
-13
View File
@@ -1,13 +0,0 @@
/* MySQLSource class wrapper to expose protected properties */
import java.util.List;
public class DMMySQLSource extends MySQLSource {
public List<Warp> getAllWarps() {
return this.warps;
}
public List<Warp> getAllHomes() {
return this.homes;
}
}
-151
View File
@@ -1,151 +0,0 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.logging.Logger;
public class MapListener extends PluginListener {
private static final Logger log = Logger.getLogger("Minecraft");
private MapManager mgr;
public MapListener(MapManager mgr)
{
this.mgr = mgr;
}
@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;
}
}
-944
View File
File diff suppressed because it is too large Load Diff
-519
View File
File diff suppressed because it is too large Load Diff
-12
View File
@@ -1,12 +0,0 @@
/* 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;
}
}
-53
View File
@@ -1,53 +0,0 @@
import java.io.*;
import java.net.*;
import java.util.*;
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;
}
}
-145
View File
@@ -1,145 +0,0 @@
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;
public class WebServerRequest extends Thread {
protected static final Logger log = Logger.getLogger("Minecraft");
private Socket sock;
private MapManager mgr;
public WebServerRequest(Socket socket, MapManager mgr)
{
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");
if (mgr.showPlayers) {
for(Player player : etc.getServer().getPlayerList()) {
sb.append(player.getName() + " player " + player.getX() + " " + player.getY() + " " + player.getZ() + "\n");
}
}
if (mgr.showSigns) {
for(Warp sign : mgr.signs.values())
{
sb.append(sign.Name + " sign " + sign.Location.x + " " + sign.Location.y + " " + sign.Location.z + "\n");
}
}
if (mgr.showWarps) {
List<Warp> warps = mgr.loadWarps();
if (warps != null) {
for(Warp warp : warps) {
sb.append(warp.Name + " warp " + warp.Location.x + " " + warp.Location.y + " " + warp.Location.z + "\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.
}
}
}
}
}
+111
View File
@@ -0,0 +1,111 @@
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;
}
}
}
+43
View File
@@ -0,0 +1,43 @@
package org.dynmap;
public class Client {
public static class Update {
public long timestamp;
public long servertime;
public Player[] players;
public Object[] updates;
}
public static class Player {
public String type = "player";
public String name;
public double x, y, z;
public Player(String name, double x, double y, double z) {
this.name = name;
this.x = x;
this.y = y;
this.z = z;
}
}
public static class ChatMessage {
public String type = "chat";
public String playerName;
public String message;
public ChatMessage(String playerName, String message) {
this.playerName = playerName;
this.message = message;
}
}
public static class Tile {
public String type = "tile";
public String name;
public Tile(String name) {
this.name = name;
}
}
}
@@ -0,0 +1,28 @@
package org.dynmap;
import org.bukkit.block.Block;
import org.bukkit.block.BlockDamageLevel;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;
public class DynmapBlockListener extends BlockListener {
private MapManager mgr;
public DynmapBlockListener(MapManager mgr) {
this.mgr = mgr;
}
@Override
public void onBlockPlace(BlockPlaceEvent event) {
Block blockPlaced = event.getBlockPlaced();
mgr.touch(blockPlaced.getX(), blockPlaced.getY(), blockPlaced.getZ());
}
public void onBlockDamage(BlockDamageEvent event) {
if (event.getDamageLevel() == BlockDamageLevel.BROKEN) {
Block blockBroken = event.getBlock();
mgr.touch(blockBroken.getX(), blockBroken.getY(), blockBroken.getZ());
}
}
}
+10
View File
@@ -0,0 +1,10 @@
package org.dynmap;
public class DynmapChunk {
public int x, y;
public DynmapChunk(int x, int y) {
this.x = x;
this.y = y;
}
}
@@ -0,0 +1,72 @@
package org.dynmap;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.util.config.ConfigurationNode;
public class DynmapPlayerListener extends PlayerListener {
private MapManager mgr;
private PlayerList playerList;
private ConfigurationNode configuration;
public DynmapPlayerListener(MapManager mgr, PlayerList playerList, ConfigurationNode configuration) {
this.mgr = mgr;
this.playerList = playerList;
this.configuration = configuration;
}
@Override
public void onPlayerCommand(PlayerChatEvent event) {
String[] split = event.getMessage().split(" ");
if (split[0].equalsIgnoreCase("/dynmap")) {
if (split.length > 1) {
for(String s : (Iterable<String>)configuration.getProperty("disabledcommands")) {
if (split[1].equals(s)) {
return;
}
}
if (split[1].equals("render")) {
Player player = event.getPlayer();
mgr.touch(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ());
event.setCancelled(true);
} else if (split[1].equals("hide")) {
if (split.length == 2) {
playerList.hide(event.getPlayer().getName());
} else {
for (int i = 2; i < split.length; i++) {
playerList.hide(split[i]);
}
}
event.setCancelled(true);
} else if (split[1].equals("show")) {
if (split.length == 2) {
playerList.show(event.getPlayer().getName());
} else {
for (int i = 2; i < split.length; i++) {
playerList.show(split[i]);
}
}
event.setCancelled(true);
} else if (split[1].equals("fullrender")) {
Player player = event.getPlayer();
mgr.renderFullWorld(player.getLocation());
} else if (split[1].equals("fullrenderasync")) {
Player player = event.getPlayer();
mgr.renderFullWorldAsync(player.getLocation());
}
}
}
}
/**
* Called when a player sends a chat message
*
* @param event
* Relevant event details
*/
public void onPlayerChat(PlayerChatEvent event) {
mgr.updateQueue.pushUpdate(new Client.ChatMessage(event.getPlayer().getName(), event.getMessage()));
}
}

Some files were not shown because too many files have changed in this diff Show More