mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-25 10:07:37 +01:00
Merge branch 'master' of git://github.com/FrozenCow/dynmap
This commit is contained in:
commit
d4bc0863b8
9
configuration.txt
Executable file → Normal file
9
configuration.txt
Executable file → Normal file
@ -67,13 +67,16 @@ web:
|
||||
# Interval the browser should poll for updates.
|
||||
updaterate: 2000
|
||||
|
||||
# showchat: modal/balloons
|
||||
showchat: modal
|
||||
showchatballoons: false
|
||||
focuschatballoons: false
|
||||
|
||||
showchatwindow: true
|
||||
allowwebchat: true
|
||||
messagettl: 15000
|
||||
|
||||
showplayerfacesonmap: true
|
||||
showplayerfacesinmenu: true
|
||||
focuschatballoons: false
|
||||
|
||||
joinmessage: "%playername% joined"
|
||||
quitmessage: "%playername% quit"
|
||||
|
||||
|
@ -4,10 +4,10 @@ import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
|
||||
public class DynmapPlayerListener extends PlayerListener {
|
||||
public class DynmapPlayerChatListener extends PlayerListener {
|
||||
DynmapPlugin plugin;
|
||||
|
||||
public DynmapPlayerListener(DynmapPlugin plugin) {
|
||||
public DynmapPlayerChatListener(DynmapPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -16,14 +16,12 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockDamageLevel;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
@ -75,12 +73,12 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
|
||||
public void onEnable() {
|
||||
dataDirectory = this.getDataFolder();
|
||||
|
||||
|
||||
configuration = new Configuration(new File(this.getDataFolder(), "configuration.txt"));
|
||||
configuration.load();
|
||||
|
||||
loadDebuggers();
|
||||
|
||||
|
||||
tilesDirectory = getFile(configuration.getString("tilespath", "web/tiles"));
|
||||
if (!tilesDirectory.isDirectory() && !tilesDirectory.mkdirs()) {
|
||||
log.warning("Could not create directory for tiles ('" + tilesDirectory + "').");
|
||||
@ -131,16 +129,18 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
webServer.handlers.put("/up/", new ClientUpdateHandler(mapManager, playerList, getServer()));
|
||||
webServer.handlers.put("/up/configuration", new ClientConfigurationHandler((Map<?, ?>) configuration.getProperty("web")));
|
||||
|
||||
SendMessageHandler messageHandler = new SendMessageHandler();
|
||||
messageHandler.onMessageReceived.addListener(new Listener<SendMessageHandler.Message>() {
|
||||
@Override
|
||||
public void triggered(Message t) {
|
||||
mapManager.pushUpdate(new Client.WebChatMessage(t.name, t.message));
|
||||
log.info("[WEB]" + t.name + ": " + t.message);
|
||||
getServer().broadcastMessage("[WEB]" + t.name + ": " + t.message);
|
||||
}
|
||||
});
|
||||
webServer.handlers.put("/up/sendmessage", messageHandler);
|
||||
if (configuration.getNode("web").getBoolean("allowwebchat", false)) {
|
||||
SendMessageHandler messageHandler = new SendMessageHandler();
|
||||
messageHandler.onMessageReceived.addListener(new Listener<SendMessageHandler.Message>() {
|
||||
@Override
|
||||
public void triggered(Message t) {
|
||||
mapManager.pushUpdate(new Client.WebChatMessage(t.name, t.message));
|
||||
log.info("[WEB]" + t.name + ": " + t.message);
|
||||
getServer().broadcastMessage("[WEB]" + t.name + ": " + t.message);
|
||||
}
|
||||
});
|
||||
webServer.handlers.put("/up/sendmessage", messageHandler);
|
||||
}
|
||||
|
||||
try {
|
||||
webServer.startServer();
|
||||
@ -167,11 +167,11 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
public boolean isTrigger(String s) {
|
||||
return enabledTriggers.contains(s);
|
||||
}
|
||||
|
||||
|
||||
public void registerEvents() {
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
final MapManager mm = mapManager;
|
||||
|
||||
|
||||
// To trigger rendering.
|
||||
{
|
||||
BlockListener renderTrigger = new BlockListener() {
|
||||
@ -185,8 +185,10 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
mm.touch(event.getBlock().getLocation());
|
||||
}
|
||||
};
|
||||
if (isTrigger("blockplaced")) pm.registerEvent(Event.Type.BLOCK_PLACED, renderTrigger, Priority.Monitor, this);
|
||||
if (isTrigger("blockbreak")) pm.registerEvent(Event.Type.BLOCK_BREAK, renderTrigger, Priority.Monitor, this);
|
||||
if (isTrigger("blockplaced"))
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACED, renderTrigger, Priority.Monitor, this);
|
||||
if (isTrigger("blockbreak"))
|
||||
pm.registerEvent(Event.Type.BLOCK_BREAK, renderTrigger, Priority.Monitor, this);
|
||||
}
|
||||
{
|
||||
PlayerListener renderTrigger = new PlayerListener() {
|
||||
@ -194,13 +196,16 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
public void onPlayerJoin(PlayerEvent event) {
|
||||
mm.touch(event.getPlayer().getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
mm.touch(event.getPlayer().getLocation());
|
||||
}
|
||||
};
|
||||
if (isTrigger("playerjoin")) pm.registerEvent(Event.Type.PLAYER_JOIN, renderTrigger, Priority.Monitor, this);
|
||||
if (isTrigger("playermove")) pm.registerEvent(Event.Type.PLAYER_MOVE, renderTrigger, Priority.Monitor, this);
|
||||
if (isTrigger("playerjoin"))
|
||||
pm.registerEvent(Event.Type.PLAYER_JOIN, renderTrigger, Priority.Monitor, this);
|
||||
if (isTrigger("playermove"))
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, renderTrigger, Priority.Monitor, this);
|
||||
}
|
||||
{
|
||||
WorldListener renderTrigger = new WorldListener() {
|
||||
@ -210,18 +215,30 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
int z = event.getChunk().getZ() * 16 + 8;
|
||||
mm.touch(new Location(event.getWorld(), x, 127, z));
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void onChunkGenerated(ChunkLoadEvent event) {
|
||||
int x = event.getChunk().getX() * 16 + 8;
|
||||
int z = event.getChunk().getZ() * 16 + 8;
|
||||
mm.touch(new Location(event.getWorld(), x, 127, z));
|
||||
}*/
|
||||
|
||||
/*
|
||||
* @Override public void onChunkGenerated(ChunkLoadEvent event)
|
||||
* { int x = event.getChunk().getX() * 16 + 8; int z =
|
||||
* event.getChunk().getZ() * 16 + 8; mm.touch(new
|
||||
* Location(event.getWorld(), x, 127, z)); }
|
||||
*/
|
||||
};
|
||||
if (isTrigger("chunkloaded")) pm.registerEvent(Event.Type.CHUNK_LOADED, renderTrigger, Priority.Monitor, this);
|
||||
if (isTrigger("chunkloaded"))
|
||||
pm.registerEvent(Event.Type.CHUNK_LOADED, renderTrigger, Priority.Monitor, this);
|
||||
//if (isTrigger("chunkgenerated")) pm.registerEvent(Event.Type.CHUNK_GENERATED, renderTrigger, Priority.Monitor, this);
|
||||
}
|
||||
|
||||
|
||||
// To announce when players have joined/quit/chatted.
|
||||
if (configuration.getNode("web").getBoolean("showchatballoons", false) || configuration.getNode("web").getBoolean("showchatwindow", false)) {
|
||||
// To handle webchat.
|
||||
PlayerListener playerListener = new DynmapPlayerChatListener(this);
|
||||
//getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Monitor, this);
|
||||
}
|
||||
|
||||
// To link configuration to real loaded worlds.
|
||||
WorldListener worldListener = new WorldListener() {
|
||||
@Override
|
||||
@ -230,15 +247,6 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
}
|
||||
};
|
||||
pm.registerEvent(Event.Type.WORLD_LOADED, worldListener, Priority.Monitor, this);
|
||||
|
||||
// To handle webchat.
|
||||
PlayerListener playerListener = new DynmapPlayerListener(this);
|
||||
//getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Monitor, this);
|
||||
|
||||
}
|
||||
|
||||
private static File combinePaths(File parent, String path) {
|
||||
@ -315,7 +323,7 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
}
|
||||
} else if (args[0].equals("fullrender")) {
|
||||
if (player == null || player.isOp()) {
|
||||
if (args.length > 2) {
|
||||
if (args.length > 1) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
World w = getServer().getWorld(args[i]);
|
||||
mapManager.renderFullWorld(new Location(w, 0, 0, 0));
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.dynmap.flat;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.io.File;
|
||||
@ -69,7 +70,10 @@ public class FlatMap extends MapType {
|
||||
|
||||
boolean rendered = false;
|
||||
BufferedImage im = new BufferedImage(t.size, t.size, BufferedImage.TYPE_INT_RGB);
|
||||
WritableRaster r = im.getRaster();
|
||||
WritableRaster raster = im.getRaster();
|
||||
|
||||
float[] hsb = new float[4];
|
||||
int[] pixel = new int[4];
|
||||
|
||||
for (int x = 0; x < t.size; x++)
|
||||
for (int y = 0; y < t.size; y++) {
|
||||
@ -83,10 +87,26 @@ public class FlatMap extends MapType {
|
||||
Color c = colors[0];
|
||||
if (c == null)
|
||||
continue;
|
||||
r.setPixel(x, y, new int[] {
|
||||
c.getRed(),
|
||||
c.getGreen(),
|
||||
c.getBlue() });
|
||||
|
||||
|
||||
Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsb);
|
||||
|
||||
float normalheight = 64;
|
||||
float below = Math.min(my, normalheight) / normalheight;
|
||||
float above = 1.0f - Math.max(0, my - normalheight) / (128 - normalheight);
|
||||
|
||||
// Saturation will be changed when going higher.
|
||||
hsb[1] *= above;
|
||||
|
||||
// Brightness will change when going lower
|
||||
hsb[2] *= below;
|
||||
|
||||
int rgb = Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]);
|
||||
pixel[0] = (rgb&0xff0000) >> 16;
|
||||
pixel[1] = (rgb&0x00ff00) >> 8;
|
||||
pixel[2] = (rgb&0x0000ff)/* >> 0*/;
|
||||
|
||||
raster.setPixel(x, y, pixel);
|
||||
rendered = true;
|
||||
}
|
||||
|
||||
|
@ -2,23 +2,6 @@
|
||||
* Page setup
|
||||
*/
|
||||
|
||||
html {
|
||||
height: 100%
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
|
||||
font-family: sans-serif;
|
||||
font-size: 11px;
|
||||
|
||||
color: #fff;
|
||||
background: #000;
|
||||
|
||||
margin: 0px;
|
||||
padding: 0px ;
|
||||
}
|
||||
|
||||
.dynmap .map .tile img, img {
|
||||
image-rendering: -moz-crisp-edges;
|
||||
-ms-interpolation-mode: nearest-neighbor;
|
||||
@ -45,8 +28,8 @@ body {
|
||||
*/
|
||||
|
||||
#mcmap {
|
||||
width: 100%;
|
||||
height: 100%
|
||||
/*width: 100%;
|
||||
height: 100%*/
|
||||
}
|
||||
|
||||
.dynmap {
|
||||
@ -539,8 +522,4 @@ body {
|
||||
position: relative;
|
||||
top: -3px;
|
||||
left: 0px;
|
||||
}
|
||||
|
||||
/* Chat Balloons */
|
||||
|
||||
#content { color: #000; }
|
||||
}
|
15
web/embedded_example.css
Normal file
15
web/embedded_example.css
Normal file
@ -0,0 +1,15 @@
|
||||
/* Embedded into website */
|
||||
|
||||
#mcmap {
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
.dynmap .sidebar {
|
||||
width: 140px; /* original width 200px */
|
||||
margin-right: -143px; /* original margin 203px, sidebar width +2xborder 1px +1px to hide */
|
||||
}
|
||||
|
||||
.dynmap .hitbar {
|
||||
right: 140px; /* width of sidebar */
|
||||
}
|
@ -10,6 +10,8 @@
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||||
<link rel="icon" href="images/dynmap.ico" type="image/ico" />
|
||||
|
||||
<!--<link rel="stylesheet" type="text/css" href="/map/embedded.css" media="screen" />-->
|
||||
<link rel="stylesheet" type="text/css" href="standalone.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="dynmap_style.css" media="screen" />
|
||||
<!-- <link rel="stylesheet" type="text/css" href="override.css" media="screen" /> -->
|
||||
|
||||
|
92
web/map.js
92
web/map.js
@ -195,28 +195,30 @@ DynMap.prototype = {
|
||||
.appendTo(container);
|
||||
|
||||
// The chat
|
||||
if (me.options.showchat === 'modal') {
|
||||
if (me.options.showchatwindow) {
|
||||
var chat = me.chat = $('<div/>')
|
||||
.addClass('chat')
|
||||
.appendTo(container);
|
||||
var messagelist = me.messagelist = $('<div/>')
|
||||
.addClass('messagelist')
|
||||
.appendTo(chat);
|
||||
var chatinput = me.chatinput = $('<input/>')
|
||||
.addClass('chatinput')
|
||||
.attr({
|
||||
id: 'chatinput',
|
||||
type: 'text',
|
||||
value: ''
|
||||
})
|
||||
.keydown(function(event) {
|
||||
if (event.keyCode == '13') {
|
||||
event.preventDefault();
|
||||
sendChat(chatinput.val());
|
||||
chatinput.val('');
|
||||
}
|
||||
})
|
||||
.appendTo(chat);
|
||||
if (me.options.allowwebchat) {
|
||||
var chatinput = me.chatinput = $('<input/>')
|
||||
.addClass('chatinput')
|
||||
.attr({
|
||||
id: 'chatinput',
|
||||
type: 'text',
|
||||
value: ''
|
||||
})
|
||||
.keydown(function(event) {
|
||||
if (event.keyCode == '13') {
|
||||
event.preventDefault();
|
||||
sendChat(chatinput.val());
|
||||
chatinput.val('');
|
||||
}
|
||||
})
|
||||
.appendTo(chat);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Enable hash-links.
|
||||
@ -306,30 +308,22 @@ DynMap.prototype = {
|
||||
}
|
||||
|
||||
$.each(update.updates, function(index, update) {
|
||||
swtch(update.type, {
|
||||
tile: function() {
|
||||
|
||||
if(me.lasttimestamp <= update.timestamp || !me.options.jsonfile)
|
||||
// Only handle updates that are actually new.
|
||||
if(!me.options.jsonfile || me.lasttimestamp <= update.timestamp) {
|
||||
swtch(update.type, {
|
||||
tile: function() {
|
||||
me.onTileUpdated(update.name);
|
||||
},
|
||||
chat: function() {
|
||||
if (!me.options.showchat) {
|
||||
return;
|
||||
}
|
||||
if(me.lasttimestamp <= update.timestamp || !me.options.jsonfile)
|
||||
},
|
||||
chat: function() {
|
||||
me.onPlayerChat(update.playerName, update.message);
|
||||
},
|
||||
webchat: function() {
|
||||
if (!me.options.showchat) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(me.lasttimestamp <= update.timestamp || !me.options.jsonfile)
|
||||
},
|
||||
webchat: function() {
|
||||
me.onPlayerChat('[WEB]' + update.playerName, update.message);
|
||||
}
|
||||
}, function(type) {
|
||||
console.log('Unknown type ', type, '!');
|
||||
});
|
||||
}
|
||||
}, function(type) {
|
||||
console.log('Unknown type ', type, '!');
|
||||
});
|
||||
}
|
||||
/* remove older messages from chat*/
|
||||
//var timestamp = event.timeStamp;
|
||||
//var divs = $('div[rel]');
|
||||
@ -369,11 +363,9 @@ DynMap.prototype = {
|
||||
var d = new Date();
|
||||
var now = d.getTime();
|
||||
var popupIndex;
|
||||
for (popupIndex in this.chatPopups)
|
||||
{
|
||||
for (popupIndex in this.chatPopups) {
|
||||
var popup = this.chatPopups[popupIndex];
|
||||
if (now - popup.popupTime > POPUP_LIFE)
|
||||
{
|
||||
if (now - popup.popupTime > POPUP_LIFE) {
|
||||
popup.infoWindow.close();
|
||||
popup.infoWindow = null;
|
||||
delete this.chatPopups[popupIndex];
|
||||
@ -386,9 +378,8 @@ DynMap.prototype = {
|
||||
var map = me.map;
|
||||
var player = me.players[playerName];
|
||||
var playerMarker = player && player.marker;
|
||||
if (me.options.showchat === 'balloons') {
|
||||
if (playerMarker)
|
||||
{
|
||||
if (me.options.showchatballoons) {
|
||||
if (playerMarker) {
|
||||
var popup = chatPopups[playerName];
|
||||
if (!popup) {
|
||||
popup = { lines: [ message ] };
|
||||
@ -397,14 +388,12 @@ DynMap.prototype = {
|
||||
}
|
||||
|
||||
var MAX_LINES = 5;
|
||||
if (popup.lines.length > MAX_LINES)
|
||||
{
|
||||
if (popup.lines.length > MAX_LINES) {
|
||||
popup.lines = popup.lines.slice(1);
|
||||
}
|
||||
var htmlMessage = '<div id="content"><b>' + playerName + "</b><br/><br/>";
|
||||
var line;
|
||||
for (line in popup.lines)
|
||||
{
|
||||
for (line in popup.lines) {
|
||||
htmlMessage = htmlMessage + popup.lines[line] + "<br/>";
|
||||
}
|
||||
htmlMessage = htmlMessage + "</div>";
|
||||
@ -421,7 +410,8 @@ DynMap.prototype = {
|
||||
popup.infoWindow.open(map, playerMarker);
|
||||
this.chatPopups[playerName] = popup;
|
||||
}
|
||||
} else if (me.options.showchat === 'modal') {
|
||||
}
|
||||
if (me.options.showchatwindow) {
|
||||
var messagelist = me.messagelist;
|
||||
|
||||
var messageRow = $('<div/>')
|
||||
@ -527,7 +517,9 @@ DynMap.prototype = {
|
||||
.text(player.name)
|
||||
)
|
||||
.click(function(e) {
|
||||
me.followPlayer(null);
|
||||
if (me.followingPlayer !== player) {
|
||||
me.followPlayer(null);
|
||||
}
|
||||
me.panTo(player.location);
|
||||
})
|
||||
.appendTo(me.playerlist);
|
||||
|
37
web/standalone.css
Normal file
37
web/standalone.css
Normal file
@ -0,0 +1,37 @@
|
||||
/* Standalone Document */
|
||||
|
||||
html {
|
||||
width: 100%;
|
||||
height: 100%
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
|
||||
font-family: sans-serif;
|
||||
font-size: 11px;
|
||||
|
||||
color: #fff;
|
||||
background: #000;
|
||||
|
||||
margin: 0px;
|
||||
padding: 0px ;
|
||||
}
|
||||
|
||||
/* Chat Balloons */
|
||||
|
||||
#content { color: #000; }
|
||||
|
||||
#mcmap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.dynmap .sidebar {
|
||||
width: 200px; /* original width 200px */
|
||||
margin-right: -203px; /* original margin 203px, sidebar width +2xborder 1px +1px to hide */
|
||||
}
|
||||
|
||||
.dynmap .hitbar {
|
||||
right: 200px; /* width of sidebar */
|
||||
}
|
Loading…
Reference in New Issue
Block a user