mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-27 20:58:40 +01:00
- Markers are now known as "Signs"
- map-markerpath is now map-signspath (YOU MUST SET THIS TO YOUR CURRENT FILE IF YOU HAVE ONE) - Commands have been renamed to: /addsign, /removesign, /listsigns, /tpsign (Update groups.txt if required) - New map-showmarkers server.property (comma separated list of options spawn,homes,warps,signs,players or you can set it to all or none; yes, can even hide players but still show warps, spawns, etc...) - map-showmarkers directly affects what output via the "up" directory so what you include in your options is included in the data, and ultimately the map - Internally, signs are now Warp based so no longer owner based - index.html updated to add divs around checkboxes - map.js updated to consolidate both players and markers into a single if statement - checkboxes dynamically show/hide from the map based on the number of items on the map (will hide if there are none, especially based on map-showmarkers) - Player list shows/hides based on number of players (or map-showmarkers setting)
This commit is contained in:
parent
70cb6a5a7f
commit
7a2b1598eb
@ -6,8 +6,7 @@ import java.util.logging.Logger;
|
||||
public class MapListener extends PluginListener {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private MapManager mgr;
|
||||
private ArrayList<MapMarker> markers;
|
||||
|
||||
|
||||
public MapListener(MapManager mgr)
|
||||
{
|
||||
this.mgr = mgr;
|
||||
@ -76,58 +75,58 @@ public class MapListener extends PluginListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/addmarker")) {
|
||||
if(split[0].equals("/addsign")) {
|
||||
if(split.length < 2)
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.Red + "Usage: /map_addmarker [name]");
|
||||
player.sendMessage("Map> " + Colors.Red + "Usage: /addsign [name]");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mgr.addMapMarker(player, split[1], player.getX(), player.getY(), player.getZ()))
|
||||
if (mgr.addSign(player, split[1], player.getX(), player.getY(), player.getZ()))
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.White + "Marker \"" + split[1] + "\" added successfully");
|
||||
player.sendMessage("Map> " + Colors.White + "Sign \"" + split[1] + "\" added successfully");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/removemarker")) {
|
||||
if(split[0].equals("/removesign")) {
|
||||
if(split.length < 2)
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.Red + "Usage: /map_removemarker [name]");
|
||||
player.sendMessage("Map> " + Colors.Red + "Usage: /removesign [name]");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mgr.removeMapMarker(player, split[1]))
|
||||
if (mgr.removeSign(player, split[1]))
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.White + "Marker \"" + split[1] + "\" removed successfully");
|
||||
player.sendMessage("Map> " + Colors.White + "Sign \"" + split[1] + "\" removed successfully");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/listmarkers")) {
|
||||
if(split[0].equals("/listsigns")) {
|
||||
String msg = "";
|
||||
Collection<MapMarker> values = mgr.markers.values();
|
||||
Iterator<MapMarker> it = values.iterator();
|
||||
Collection<Warp> values = mgr.signs.values();
|
||||
Iterator<Warp> it = values.iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
MapMarker marker = it.next();
|
||||
String line = " - " + marker.name + " (" + marker.owner + ")\t";
|
||||
Warp sign = it.next();
|
||||
String line = " - " + sign.Name + "\t";
|
||||
msg += line;
|
||||
}
|
||||
player.sendMessage("" + Colors.White + msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(split[0].equals("/tpmarker")) {
|
||||
if(split[0].equals("/tpsign")) {
|
||||
if(split.length < 2)
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.Red + "Usage: /map_tpmarker [name]");
|
||||
player.sendMessage("Map> " + Colors.Red + "Usage: /tpsign [name]");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mgr.teleportToMapMarker(player, split[1]))
|
||||
if (mgr.teleportToSign(player, split[1]))
|
||||
{
|
||||
//player.sendMessage("Map> " + Colors.White + "");
|
||||
}
|
||||
|
280
MapManager.java
280
MapManager.java
@ -1,6 +1,5 @@
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.List;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.WritableRaster;
|
||||
@ -18,6 +17,7 @@ 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;
|
||||
@ -65,8 +65,8 @@ public class MapManager extends Thread {
|
||||
/* path to image tile directory */
|
||||
public String tilepath = "tiles/";
|
||||
|
||||
/* path to markers file */
|
||||
public String markerpath = "markers.txt";
|
||||
/* path to signs file */
|
||||
public String signspath = "signs.txt";
|
||||
|
||||
/* port to run web server on */
|
||||
public int serverport = 8123;
|
||||
@ -83,14 +83,27 @@ public class MapManager extends Thread {
|
||||
/* map debugging mode (send debugging messages to this player) */
|
||||
public String debugPlayer = null;
|
||||
|
||||
/* hashmap of markers */
|
||||
public HashMap<String,MapMarker> markers = 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 void debug(String msg)
|
||||
{
|
||||
@ -110,8 +123,10 @@ public class MapManager extends Thread {
|
||||
try {
|
||||
tilepath = properties.getString("map-tilepath", "tiles/");
|
||||
colorsetpath = properties.getString("map-colorsetpath", "colors.txt");
|
||||
markerpath = properties.getString("map-markerpath", "markers.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");
|
||||
} catch(Exception ex) {
|
||||
log.log(Level.SEVERE, "Exception while reading properties for dynamic map", ex);
|
||||
}
|
||||
@ -121,7 +136,9 @@ public class MapManager extends Thread {
|
||||
tileUpdates = new LinkedList<TileUpdate>();
|
||||
zoomCache = new Cache<String, BufferedImage>(zoomCacheSize);
|
||||
|
||||
markers = new HashMap<String,MapMarker>();
|
||||
signs = new HashMap<String, Warp>();
|
||||
|
||||
loadShowOptions();
|
||||
}
|
||||
|
||||
/* tile X for position x */
|
||||
@ -169,7 +186,7 @@ public class MapManager extends Thread {
|
||||
/* load colorset */
|
||||
File cfile = new File(colorsetpath);
|
||||
|
||||
loadMapMarkers();
|
||||
loadSigns();
|
||||
|
||||
try {
|
||||
Scanner scanner = new Scanner(cfile);
|
||||
@ -566,116 +583,124 @@ public class MapManager extends Thread {
|
||||
return good;
|
||||
}
|
||||
|
||||
/* adds a marker to the map */
|
||||
public boolean addMapMarker(Player player, String name, double px, double py, double pz)
|
||||
/* adds a sign to the map */
|
||||
public boolean addSign(Player player, String name, double px, double py, double pz)
|
||||
{
|
||||
if (markers.containsKey(name))
|
||||
if (signs.containsKey(name))
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.Red + "Marker \"" + name + "\" already exists.");
|
||||
player.sendMessage("Map> " + Colors.Red + "Sign \"" + name + "\" already exists.");
|
||||
return false;
|
||||
}
|
||||
|
||||
MapMarker marker = new MapMarker();
|
||||
marker.name = name;
|
||||
marker.owner = player.getName();
|
||||
marker.px = px;
|
||||
marker.py = py;
|
||||
marker.pz = pz;
|
||||
markers.put(name, marker);
|
||||
Warp sign = new Warp();
|
||||
sign.Name = name;
|
||||
sign.Location = new Location(px,py,pz);
|
||||
signs.put(name, sign);
|
||||
|
||||
try
|
||||
{
|
||||
saveMapMarkers();
|
||||
saveSigns();
|
||||
return true;
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
log.log(Level.SEVERE, "Failed to save markers.txt", e);
|
||||
log.log(Level.SEVERE, "Failed to save signs.txt", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* removes a marker from the map */
|
||||
public boolean removeMapMarker(Player player, String name)
|
||||
/* removes a sign from the map */
|
||||
public boolean removeSign(Player player, String name)
|
||||
{
|
||||
if (markers.containsKey(name))
|
||||
if (signs.containsKey(name))
|
||||
{
|
||||
MapMarker marker = markers.get(name);
|
||||
if (marker.owner.equalsIgnoreCase(player.getName()))
|
||||
{
|
||||
markers.remove(name);
|
||||
|
||||
try
|
||||
{
|
||||
saveMapMarkers();
|
||||
return true;
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
log.log(Level.SEVERE, "Failed to save markers.txt", e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.Red + "Marker \"" + name + "\" does not belong to you.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("Map> " + Colors.Red + "Marker \"" + name + "\" does not exist.");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* teleports a user to a marker */
|
||||
public boolean teleportToMapMarker(Player player, String name)
|
||||
{
|
||||
if (markers.containsKey(name))
|
||||
{
|
||||
MapMarker marker = markers.get(name);
|
||||
Warp sign = signs.get(name);
|
||||
|
||||
player.teleportTo(marker.px, marker.py, marker.pz, 0, 0);
|
||||
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 + "Marker \"" + name + "\" does not exist.");
|
||||
player.sendMessage("Map> " + Colors.Red + "Sign \"" + name + "\" does not exist.");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* load the map marker file */
|
||||
private void loadMapMarkers()
|
||||
/* 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(markerpath), "UTF-8");
|
||||
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 != 5)
|
||||
if (values.length == 1)
|
||||
{
|
||||
values = line.split(",");
|
||||
}
|
||||
|
||||
// If user has old style of file (owners)
|
||||
if (values.length == 5)
|
||||
{
|
||||
MapMarker marker = new MapMarker();
|
||||
marker.name = values[0];
|
||||
marker.owner = values[1];
|
||||
marker.px = Double.parseDouble(values[2]);
|
||||
marker.py = Double.parseDouble(values[3]);
|
||||
marker.pz = Double.parseDouble(values[4]);
|
||||
markers.put(marker.name, marker);
|
||||
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 marker: " + values[0]);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -689,19 +714,19 @@ public class MapManager extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
/* save the map marker file */
|
||||
private void saveMapMarkers() throws IOException
|
||||
/* save the map sign file */
|
||||
private void saveSigns() throws IOException
|
||||
{
|
||||
Writer out = null;
|
||||
try
|
||||
{
|
||||
out = new OutputStreamWriter(new FileOutputStream(markerpath), "UTF-8");
|
||||
Collection<MapMarker> values = markers.values();
|
||||
Iterator<MapMarker> it = values.iterator();
|
||||
out = new OutputStreamWriter(new FileOutputStream(signspath), "UTF-8");
|
||||
Collection<Warp> values = signs.values();
|
||||
Iterator<Warp> it = values.iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
MapMarker marker = it.next();
|
||||
String line = marker.name + ":" + marker.owner + ":" + marker.px + ":" + marker.py + ":" + marker.pz + "\n";
|
||||
Warp sign = it.next();
|
||||
String line = sign.Name + ":" + sign.Location.x + ":" + sign.Location.y + ":" + sign.Location.z + "\n";
|
||||
out.write(line);
|
||||
}
|
||||
}
|
||||
@ -711,7 +736,7 @@ public class MapManager extends Thread {
|
||||
}
|
||||
catch(FileNotFoundException e)
|
||||
{
|
||||
log.log(Level.SEVERE, "markers.txt not found", e);
|
||||
log.log(Level.SEVERE, "signs.txt not found", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -723,23 +748,19 @@ public class MapManager extends Thread {
|
||||
|
||||
protected List<Warp> loadWarps()
|
||||
{
|
||||
PropertiesFile props = new PropertiesFile("server.properties");
|
||||
|
||||
List<Warp> warps = null;
|
||||
|
||||
if (props.getString("data-source").equals("flatfile")) {
|
||||
DMFlatFileSource dataSource = new DMFlatFileSource();
|
||||
dataSource.initialize();
|
||||
dataSource.loadWarps();
|
||||
dataSource.loadHomes();
|
||||
warps = dataSource.getAllWarps();
|
||||
if (datasource.equals("flatfile")) {
|
||||
DMFlatFileSource ds = new DMFlatFileSource();
|
||||
ds.initialize();
|
||||
ds.loadWarps();
|
||||
warps = ds.getAllWarps();
|
||||
}
|
||||
else if (props.getString("data-source").equals("mysql")) {
|
||||
DMMySQLSource dataSource = new DMMySQLSource();
|
||||
dataSource.initialize();
|
||||
dataSource.loadWarps();
|
||||
dataSource.loadHomes();
|
||||
warps = dataSource.getAllWarps();
|
||||
else if (datasource.equals("mysql")) {
|
||||
DMMySQLSource ds = new DMMySQLSource();
|
||||
ds.initialize();
|
||||
ds.loadWarps();
|
||||
warps = ds.getAllWarps();
|
||||
}
|
||||
|
||||
return warps;
|
||||
@ -747,25 +768,68 @@ public class MapManager extends Thread {
|
||||
|
||||
protected List<Warp> loadHomes()
|
||||
{
|
||||
PropertiesFile props = new PropertiesFile("server.properties");
|
||||
|
||||
List<Warp> homes = null;
|
||||
|
||||
if (props.getString("data-source").equals("flatfile")) {
|
||||
DMFlatFileSource dataSource = new DMFlatFileSource();
|
||||
dataSource.initialize();
|
||||
dataSource.loadWarps();
|
||||
dataSource.loadHomes();
|
||||
homes = dataSource.getAllHomes();
|
||||
if (datasource.equals("flatfile")) {
|
||||
DMFlatFileSource ds = new DMFlatFileSource();
|
||||
ds.initialize();
|
||||
ds.loadHomes();
|
||||
homes = ds.getAllHomes();
|
||||
}
|
||||
else if (props.getString("data-source").equals("mysql")) {
|
||||
DMMySQLSource dataSource = new DMMySQLSource();
|
||||
dataSource.initialize();
|
||||
dataSource.loadWarps();
|
||||
dataSource.loadHomes();
|
||||
homes = dataSource.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
public class MapMarker {
|
||||
public double px, py, pz;
|
||||
public String name, owner;
|
||||
}
|
@ -72,33 +72,44 @@ public class WebServerRequest extends Thread {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(current + "\n");
|
||||
|
||||
for(Player player : etc.getServer().getPlayerList()) {
|
||||
sb.append(player.getName() + " " + player.getX() + " " + player.getY() + " " + player.getZ() + "\n");
|
||||
if (mgr.showPlayers) {
|
||||
for(Player player : etc.getServer().getPlayerList()) {
|
||||
sb.append(player.getName() + " player " + player.getX() + " " + player.getY() + " " + player.getZ() + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
for(MapMarker marker : mgr.markers.values())
|
||||
{
|
||||
sb.append(marker.name + " marker " + marker.owner + " " + marker.px + " " + marker.py + " " + marker.pz + "\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");
|
||||
}
|
||||
}
|
||||
|
||||
List<Warp> warps = mgr.loadWarps();
|
||||
List<Warp> homes = mgr.loadHomes();
|
||||
|
||||
Location spawnLocation = etc.getServer().getSpawnLocation();
|
||||
|
||||
if (warps != null) {
|
||||
for(Warp warp : warps) {
|
||||
sb.append(warp.Name + " warp unknown " + warp.Location.x + " " + warp.Location.y + " " + warp.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 (homes != null) {
|
||||
for(Warp warp : homes) {
|
||||
sb.append(warp.Name + " home " + warp.Name + " " + 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sb.append("Spawn spawn none " + spawnLocation.x + " " + spawnLocation.y + " " + spawnLocation.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) {
|
||||
|
BIN
dist/DynamicMap.rar
vendored
BIN
dist/DynamicMap.rar
vendored
Binary file not shown.
8
map.java
8
map.java
@ -48,9 +48,9 @@ public class map extends Plugin {
|
||||
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("/addmarker", " [name] - adds a named marker to the map");
|
||||
etc.getInstance().addCommand("/removemarker", " [name] - removes a named marker to the map");
|
||||
etc.getInstance().addCommand("/listmarkers", " - list all named markers");
|
||||
etc.getInstance().addCommand("/tpmarker", " [name] - teleport to a named marker");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
13
readme.txt
13
readme.txt
@ -7,14 +7,15 @@ Commands
|
||||
/map_nodebug - disable map debugging messages
|
||||
/map_regenzoom - regenerates zoom-out tiles
|
||||
|
||||
/addmarker [name] - adds a named marker to the map
|
||||
/removemarker [name] - removes a named marker to the map
|
||||
/listmarkers - list all named markers
|
||||
/tpmarker [name] - teleport to a named marker
|
||||
/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-markerpath - point to markers.csv file (do not need to create the file, one will be created when you create a marker)
|
||||
map-serverport - the port the web server runs on (default is 8123)
|
||||
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)
|
@ -20,15 +20,23 @@
|
||||
<div id="lst">[Connecting]</div>
|
||||
</div>
|
||||
<div id="controls">
|
||||
<form action="#" method="get">
|
||||
<img src="warp.png" alt="Warps" title="Warps" />
|
||||
<input type="checkbox" checked="checked" id="showWarps" /><br />
|
||||
<img src="marker.png" alt="Markers" title="Markers" />
|
||||
<input type="checkbox" checked="checked" id="showMarkers" /><br />
|
||||
<img src="home.png" alt="Homes" title="Homes" />
|
||||
<input type="checkbox" checked="checked" id="showHomes" /><br />
|
||||
<img src="spawn.png" alt="Spawn" title="Spawn" />
|
||||
<input type="checkbox" checked="checked" id="showSpawn" /><br />
|
||||
<form action="#" method="get">
|
||||
<div id="warpsDiv">
|
||||
<img src="warp.png" alt="Warps" title="Warps" />
|
||||
<input type="checkbox" checked="checked" id="showWarps" />
|
||||
</div>
|
||||
<div id="signsDiv">
|
||||
<img src="sign.png" alt="Signs" title="Signs" />
|
||||
<input type="checkbox" checked="checked" id="showSigns" /><br />
|
||||
</div>
|
||||
<div id="homesDiv">
|
||||
<img src="home.png" alt="Homes" title="Homes" />
|
||||
<input type="checkbox" checked="checked" id="showHomes" /><br />
|
||||
</div>
|
||||
<div id="spawnsDiv">
|
||||
<img src="spawn.png" alt="Spawn" title="Spawn" />
|
||||
<input type="checkbox" checked="checked" id="showSpawn" /><br />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div id="link"></div>
|
||||
|
69
web/map.js
69
web/map.js
@ -565,7 +565,7 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||
var rows = res.split('\n');
|
||||
var loggedin = new Array();
|
||||
var showWarps = document.getElementById('showWarps').checked;
|
||||
var showMarkers = document.getElementById('showMarkers').checked;
|
||||
var showSigns = document.getElementById('showSigns').checked;
|
||||
var showHomes = document.getElementById('showHomes').checked;
|
||||
var showSpawn = document.getElementById('showSpawn').checked;
|
||||
|
||||
@ -573,55 +573,49 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||
delete rows[0];
|
||||
|
||||
var playerlst = ''
|
||||
var numwarps = 0;
|
||||
var numsigns = 0;
|
||||
var numhomes = 0;
|
||||
var numspawns = 0;
|
||||
var numplayers = 0;
|
||||
|
||||
for(var line in rows) {
|
||||
var p = rows[line].split(' ');
|
||||
|
||||
// Hack to keep duplicate markers/warps/players from conflicting with eachother
|
||||
if(p.length == 6) {
|
||||
if(p[0] == '') continue;
|
||||
|
||||
// Hack to keep duplicate markers from conflicting with eachother
|
||||
if (p[1] != 'player') {
|
||||
p[0] = p[0] + '<span style="display:none;">' + p[1] + '</span>';
|
||||
}
|
||||
|
||||
loggedin[p[0]] = 1;
|
||||
if(p[0] == '') continue;
|
||||
|
||||
if(p.length == 4) {
|
||||
|
||||
if (p[1] == 'player') {
|
||||
if(playerlst != '') playerlst += '<br />';
|
||||
playerlst += '<img id="icon_' + p[0] + '" class="plicon" src="' + (p[0] == followPlayer ? 'follow_on.png' : 'follow_off.png') + '" onclick="plfollow(' + "'" + p[0] + "'" + ')" alt="" /> <a href="#" onclick="plclick(' + "'" + p[0] + "'" + ')">' + p[0] + '</a>';
|
||||
}
|
||||
|
||||
if(p[0] == followPlayer) {
|
||||
map.setCenter(fromWorldToLatLng(p[1], p[2], p[3]));
|
||||
}
|
||||
|
||||
if(p[0] in markers) {
|
||||
var m = markers[p[0]];
|
||||
var converted = fromWorldToLatLng(p[1], p[2], p[3]);
|
||||
m.setPosition(converted);
|
||||
} else {
|
||||
var converted = fromWorldToLatLng(p[1], p[2], p[3]);
|
||||
var marker = new MarkerWithLabel({
|
||||
position: converted,
|
||||
map: map,
|
||||
labelContent: p[0],
|
||||
labelAnchor: new google.maps.Point(-14, 10),
|
||||
labelClass: "labels",
|
||||
clickable: false,
|
||||
flat: true,
|
||||
icon: new google.maps.MarkerImage('player.png', new google.maps.Size(28, 28), new google.maps.Point(0, 0), new google.maps.Point(14, 14))
|
||||
});
|
||||
|
||||
markers[p[0]] = marker;
|
||||
}
|
||||
} else if(p.length == 6) {
|
||||
if(p.length == 5) {
|
||||
var image = p[1] + '.png';
|
||||
|
||||
if (p[1] == 'warp') numwarps++;
|
||||
if (p[1] == 'sign') numsigns++;
|
||||
if (p[1] == 'home') numhomes++;
|
||||
if (p[1] == 'spawn') numspawns++;
|
||||
if (p[1] == 'player') numplayers++;
|
||||
|
||||
var hideMarker = (
|
||||
(p[1] == 'warp' && showWarps == false) ||
|
||||
(p[1] == 'marker' && showMarkers == false) ||
|
||||
(p[1] == 'sign' && showSigns == false) ||
|
||||
(p[1] == 'home' && showHomes == false) ||
|
||||
(p[1] == 'spawn' && showSpawn == false)
|
||||
);
|
||||
|
||||
if(p[0] == followPlayer) {
|
||||
map.panTo(fromWorldToLatLng(p[2], p[3], p[4]));
|
||||
}
|
||||
|
||||
if(p[0] in markers) {
|
||||
var m = markers[p[0]];
|
||||
|
||||
@ -633,14 +627,14 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||
m.setMap(map);
|
||||
}
|
||||
|
||||
var converted = fromWorldToLatLng(p[3], p[4], p[5]);
|
||||
var converted = fromWorldToLatLng(p[2], p[3], p[4]);
|
||||
m.setPosition(converted);
|
||||
} else {
|
||||
if (hideMarker) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var converted = fromWorldToLatLng(p[3], p[4], p[5]);
|
||||
var converted = fromWorldToLatLng(p[2], p[3], p[4]);
|
||||
var marker = new MarkerWithLabel({
|
||||
position: converted,
|
||||
map: map,
|
||||
@ -674,6 +668,15 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||
delete markers[m];
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('warpsDiv').style.display = (numwarps == 0)?'none':'';
|
||||
document.getElementById('signsDiv').style.display = (numsigns == 0)?'none':'';
|
||||
document.getElementById('homesDiv').style.display = (numhomes == 0)?'none':'';
|
||||
document.getElementById('spawnsDiv').style.display = (numspawns == 0)?'none':'';
|
||||
|
||||
document.getElementById('plist').style.display = (numplayers == 0)?'none':'';
|
||||
|
||||
document.getElementById('controls').style.display = ((numwarps + numsigns + numhomes + numspawns) == 0)?'none':'';
|
||||
|
||||
setTimeout(mapUpdate, config.updateRate);
|
||||
}, 'text', function() { alert('failed to get update data'); } );
|
||||
|
Before Width: | Height: | Size: 681 B After Width: | Height: | Size: 681 B |
Loading…
Reference in New Issue
Block a user