- Map listens for player login and downloads, crops and resizes the players skin (face only)
- If the map fails to download a skin for the user, it downloads, crops and resizes the default skin (http://www.minecraft.net/img/char.png) - Images are saved to the tile directory so users aren't forced to map another directory, setup permissions, etc... - Added one more zoom level (thanks godsyn) - Added a map link so you can link people/friends to specific parts of the map (thanks godsyn)
This commit is contained in:
parent
1e11a47534
commit
084c1a4925
6 changed files with 102 additions and 32 deletions
|
|
@ -35,6 +35,12 @@ public class MapListener extends PluginListener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLogin(Player player)
|
||||||
|
{
|
||||||
|
mgr.getPlayerImage(player);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(Player player, String[] split)
|
public boolean onCommand(Player player, String[] split)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.Insets;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.WritableRaster;
|
import java.awt.image.WritableRaster;
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
@ -11,6 +14,8 @@ import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -832,4 +837,45 @@ public class MapManager extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void getPlayerImage(Player player)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
dist/DynamicMap.rar
vendored
BIN
dist/DynamicMap.rar
vendored
Binary file not shown.
1
map.java
1
map.java
|
|
@ -42,6 +42,7 @@ public class map extends Plugin {
|
||||||
etc.getLoader().addListener(PluginLoader.Hook.COMMAND, listener, this, PluginListener.Priority.MEDIUM);
|
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.getInstance().addCommand("/map_wait", " [wait] - set wait between tile renders (ms)");
|
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_stat", " - query number of tiles in render queue");
|
||||||
|
|
|
||||||
63
web/map.js
63
web/map.js
|
|
@ -1,9 +1,9 @@
|
||||||
var setup = {
|
var setup = {
|
||||||
tileUrl: 'http://www.yourdomain.com/minecraft/tiles/',
|
tileUrl: 'http://www.yourdomain.com/minecraft/tiles/',
|
||||||
updateUrl: 'http://www.yourdomain.com/minecraft/up/', // Or if using ASP.NET: http://www.yourdomain.com/minecraft/up/default.aspx?lasttimestamp=
|
updateUrl: 'http://www.yourdomain.com/minecraft/up/', // Or if using ASP.NET: http://www.yourdomain.com/minecraft/up/default.aspx?lasttimestamp=
|
||||||
updateRate: 2000 //Seconds the map should poll for updates. (Seconds) * 1000. The default is 2000 (every 2 seconds).
|
updateRate: 2000 //Seconds the map should poll for updates. (Seconds) * 1000. The default is 2000 (every 2 seconds).
|
||||||
};
|
};
|
||||||
|
|
||||||
/* THERE SHOULD BE NO NEED FOR MANUAL CONFIGURATION BEYOND THIS POINT */
|
/* THERE SHOULD BE NO NEED FOR MANUAL CONFIGURATION BEYOND THIS POINT */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -388,8 +388,6 @@ MarkerWithLabel.prototype.setMap = function (theMap) {
|
||||||
this.label.setMap(theMap);
|
this.label.setMap(theMap);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* generic function for making an XMLHttpRequest
|
/* generic function for making an XMLHttpRequest
|
||||||
* url: request URL
|
* url: request URL
|
||||||
* func: callback function for success
|
* func: callback function for success
|
||||||
|
|
@ -451,7 +449,7 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||||
tileWidth: 128,
|
tileWidth: 128,
|
||||||
tileHeight: 128,
|
tileHeight: 128,
|
||||||
updateRate: setup.updateRate,
|
updateRate: setup.updateRate,
|
||||||
zoomSize: [ 128, 128, 256 ]
|
zoomSize: [ 128, 128, 256, 512 ]
|
||||||
};
|
};
|
||||||
|
|
||||||
function MCMapProjection() {
|
function MCMapProjection() {
|
||||||
|
|
@ -525,7 +523,7 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||||
|
|
||||||
mcMapType.prototype.tileSize = new google.maps.Size(config.tileWidth, config.tileHeight);
|
mcMapType.prototype.tileSize = new google.maps.Size(config.tileWidth, config.tileHeight);
|
||||||
mcMapType.prototype.minZoom = 0;
|
mcMapType.prototype.minZoom = 0;
|
||||||
mcMapType.prototype.maxZoom = 2;
|
mcMapType.prototype.maxZoom = 3;
|
||||||
mcMapType.prototype.getTile = function(coord, zoom, doc) {
|
mcMapType.prototype.getTile = function(coord, zoom, doc) {
|
||||||
var img = doc.createElement('IMG');
|
var img = doc.createElement('IMG');
|
||||||
|
|
||||||
|
|
@ -558,7 +556,7 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||||
var plistbtn;
|
var plistbtn;
|
||||||
var lstopen = true;
|
var lstopen = true;
|
||||||
var oldplayerlst = '[Connecting]';
|
var oldplayerlst = '[Connecting]';
|
||||||
|
|
||||||
function mapUpdate()
|
function mapUpdate()
|
||||||
{
|
{
|
||||||
makeRequest(config.updateUrl + lasttimestamp, function(res) {
|
makeRequest(config.updateUrl + lasttimestamp, function(res) {
|
||||||
|
|
@ -568,11 +566,9 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||||
var showSigns = document.getElementById('showSigns').checked;
|
var showSigns = document.getElementById('showSigns').checked;
|
||||||
var showHomes = document.getElementById('showHomes').checked;
|
var showHomes = document.getElementById('showHomes').checked;
|
||||||
var showSpawn = document.getElementById('showSpawn').checked;
|
var showSpawn = document.getElementById('showSpawn').checked;
|
||||||
|
lasttimestamp = rows[0];
|
||||||
lasttimestamp = rows[0];
|
|
||||||
delete rows[0];
|
delete rows[0];
|
||||||
|
var playerlst = ''
|
||||||
var playerlst = ''
|
|
||||||
var numwarps = 0;
|
var numwarps = 0;
|
||||||
var numsigns = 0;
|
var numsigns = 0;
|
||||||
var numhomes = 0;
|
var numhomes = 0;
|
||||||
|
|
@ -587,18 +583,18 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||||
// Hack to keep duplicate markers from conflicting with eachother
|
// Hack to keep duplicate markers from conflicting with eachother
|
||||||
if (p[1] != 'player' && p.length == 5) {
|
if (p[1] != 'player' && p.length == 5) {
|
||||||
p[0] = p[0] + '<span style="display:none;">' + p[1] + '</span>';
|
p[0] = p[0] + '<span style="display:none;">' + p[1] + '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
loggedin[p[0]] = 1;
|
loggedin[p[0]] = 1;
|
||||||
|
|
||||||
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.length == 5) {
|
if(p.length == 5) {
|
||||||
var image = p[1] + '.png';
|
var image = p[1] + '.png';
|
||||||
|
|
||||||
|
if (p[1] == 'player') {
|
||||||
|
if(playerlst != '') playerlst += '<br />';
|
||||||
|
playerlst += '<img id="icon_' + p[0] + '" title="Follow" class="plicon" src="' + (p[0] == followPlayer ? 'follow_on.png' : 'follow_off.png') + '" onclick="plfollow(' + "'" + p[0] + "'" + ')" alt="" /><a href="#" onclick="plclick(' + "'" + p[0] + "'" + ')"><img class="plisthead" src="' + setup.tileUrl + p[0] + '.png" />' + p[0] + '</a>';
|
||||||
|
image = setup.tileUrl + p[0] + '.png';
|
||||||
|
}
|
||||||
|
|
||||||
if (p[1] == 'warp') numwarps++;
|
if (p[1] == 'warp') numwarps++;
|
||||||
if (p[1] == 'sign') numsigns++;
|
if (p[1] == 'sign') numsigns++;
|
||||||
if (p[1] == 'home') numhomes++;
|
if (p[1] == 'home') numhomes++;
|
||||||
|
|
@ -651,7 +647,6 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||||
} else if(p.length == 2) {
|
} else if(p.length == 2) {
|
||||||
lastSeen['t_' + p[0]] = lasttimestamp;
|
lastSeen['t_' + p[0]] = lasttimestamp;
|
||||||
lastSeen['zt_' + p[1]] = lasttimestamp;
|
lastSeen['zt_' + p[1]] = lasttimestamp;
|
||||||
|
|
||||||
imgSubst('t_' + p[0]);
|
imgSubst('t_' + p[0]);
|
||||||
imgSubst('zt_' + p[1]);
|
imgSubst('zt_' + p[1]);
|
||||||
}
|
}
|
||||||
|
|
@ -661,24 +656,20 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||||
oldplayerlst = playerlst;
|
oldplayerlst = playerlst;
|
||||||
lst.innerHTML = playerlst;
|
lst.innerHTML = playerlst;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var m in markers) {
|
for(var m in markers) {
|
||||||
if(!(m in loggedin)) {
|
if(!(m in loggedin)) {
|
||||||
markers[m].setMap(null);
|
markers[m].setMap(null);
|
||||||
delete markers[m];
|
delete markers[m];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setTimeout(mapUpdate, config.updateRate);
|
||||||
document.getElementById('warpsDiv').style.display = (numwarps == 0)?'none':'';
|
document.getElementById('warpsDiv').style.display = (numwarps == 0)?'none':'';
|
||||||
document.getElementById('signsDiv').style.display = (numsigns == 0)?'none':'';
|
document.getElementById('signsDiv').style.display = (numsigns == 0)?'none':'';
|
||||||
document.getElementById('homesDiv').style.display = (numhomes == 0)?'none':'';
|
document.getElementById('homesDiv').style.display = (numhomes == 0)?'none':'';
|
||||||
document.getElementById('spawnsDiv').style.display = (numspawns == 0)?'none':'';
|
document.getElementById('spawnsDiv').style.display = (numspawns == 0)?'none':'';
|
||||||
|
|
||||||
document.getElementById('plist').style.display = (numplayers == 0)?'none':'';
|
document.getElementById('plist').style.display = (numplayers == 0)?'none':'';
|
||||||
|
|
||||||
document.getElementById('controls').style.display = ((numwarps + numsigns + numhomes + numspawns) == 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'); } );
|
}, 'text', function() { alert('failed to get update data'); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -690,7 +681,7 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||||
center: new google.maps.LatLng(0, 1),
|
center: new google.maps.LatLng(0, 1),
|
||||||
navigationControl: true,
|
navigationControl: true,
|
||||||
navigationControlOptions: {
|
navigationControlOptions: {
|
||||||
style: google.maps.NavigationControlStyle.SMALL
|
style: google.maps.NavigationControlStyle.DEFAULT
|
||||||
},
|
},
|
||||||
scaleControl: false,
|
scaleControl: false,
|
||||||
mapTypeControl: false,
|
mapTypeControl: false,
|
||||||
|
|
@ -708,6 +699,12 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||||
google.maps.event.addListener(map, 'dragstart', function(mEvent) {
|
google.maps.event.addListener(map, 'dragstart', function(mEvent) {
|
||||||
plfollow('');
|
plfollow('');
|
||||||
});
|
});
|
||||||
|
google.maps.event.addListener(map, 'zoom_changed', function() {
|
||||||
|
makeLink();
|
||||||
|
});
|
||||||
|
google.maps.event.addListener(map, 'center_changed', function() {
|
||||||
|
makeLink();
|
||||||
|
});
|
||||||
|
|
||||||
map.dragstart = plfollow('');
|
map.dragstart = plfollow('');
|
||||||
map.mapTypes.set('mcmap', mapType);
|
map.mapTypes.set('mcmap', mapType);
|
||||||
|
|
@ -732,7 +729,7 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||||
function plclick(name) {
|
function plclick(name) {
|
||||||
if(name in markers) {
|
if(name in markers) {
|
||||||
if(name != followPlayer) plfollow('');
|
if(name != followPlayer) plfollow('');
|
||||||
map.setCenter(markers[name].getPosition());
|
map.panTo(markers[name].getPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -759,10 +756,18 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||||
followPlayer = name;
|
followPlayer = name;
|
||||||
|
|
||||||
if(name in markers) {
|
if(name in markers) {
|
||||||
map.setCenter(markers[name].getPosition());
|
map.panTo(markers[name].getPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeLink() {
|
||||||
|
var a=location.href.substring(0,location.href.lastIndexOf("/")+1)
|
||||||
|
+ "?lat=" + map.getCenter().lat().toFixed(6)
|
||||||
|
+ "&lng=" + map.getCenter().lng().toFixed(6)
|
||||||
|
+ "&zoom=" + map.getZoom();
|
||||||
|
document.getElementById("link").innerHTML = a;
|
||||||
|
}
|
||||||
|
|
||||||
//remove item (string or number) from an array
|
//remove item (string or number) from an array
|
||||||
function removeItem(originalArray, itemToRemove) {
|
function removeItem(originalArray, itemToRemove) {
|
||||||
var j = 0;
|
var j = 0;
|
||||||
|
|
@ -774,4 +779,4 @@ function makeRequest(url, func, type, fail, post, contenttype)
|
||||||
}
|
}
|
||||||
// assert('hi');
|
// assert('hi');
|
||||||
return originalArray;
|
return originalArray;
|
||||||
}
|
}
|
||||||
|
|
@ -18,6 +18,7 @@ body { height: 100%; margin: 0px; padding: 0px ; background-color: #000; }
|
||||||
}
|
}
|
||||||
#plistbtn {
|
#plistbtn {
|
||||||
float:right;
|
float:right;
|
||||||
|
cursor:pointer;
|
||||||
}
|
}
|
||||||
#link {
|
#link {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
@ -32,8 +33,8 @@ body { height: 100%; margin: 0px; padding: 0px ; background-color: #000; }
|
||||||
}
|
}
|
||||||
#controls {
|
#controls {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 4px;
|
top: 12px;
|
||||||
left: 30px;
|
left: 45px;
|
||||||
border: 1px solid #808080;
|
border: 1px solid #808080;
|
||||||
background: #000;
|
background: #000;
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
|
|
@ -56,4 +57,15 @@ a, a:visited {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
color: white;
|
color: white;
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
.gmnoprint{
|
||||||
|
margin-top:-75px;
|
||||||
|
margin-left:-20px
|
||||||
|
}
|
||||||
|
.plisthead{
|
||||||
|
margin-left:3px;
|
||||||
|
margin-right:3px;
|
||||||
|
display:inline-block;
|
||||||
|
height:14px;width:14px;
|
||||||
|
background-color:#000;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue