mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-25 03:35:18 +01:00
Merge pull request #174 from mikeprimm/master
Add night-and-day option support in web interface - automatically synced to world time
This commit is contained in:
commit
bdccd5daf0
@ -67,4 +67,14 @@ public class Client {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class DayNight extends Update {
|
||||||
|
public String type = "daynight";
|
||||||
|
public boolean isday;
|
||||||
|
|
||||||
|
public DayNight(boolean isday) {
|
||||||
|
this.isday = isday;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,5 @@ public class DynmapWorld {
|
|||||||
public UpdateQueue updates = new UpdateQueue();
|
public UpdateQueue updates = new UpdateQueue();
|
||||||
public ConfigurationNode configuration;
|
public ConfigurationNode configuration;
|
||||||
public List<Location> seedloc;
|
public List<Location> seedloc;
|
||||||
|
public int servertime;
|
||||||
}
|
}
|
||||||
|
@ -162,6 +162,21 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class CheckWorldTimes implements Runnable {
|
||||||
|
public void run() {
|
||||||
|
for(DynmapWorld w : worlds) {
|
||||||
|
int new_servertime = (int)(w.world.getTime() % 24000);
|
||||||
|
/* Check if we went from night to day */
|
||||||
|
boolean wasday = w.servertime >= 0 && w.servertime < 13700;
|
||||||
|
boolean isday = new_servertime >= 0 && new_servertime < 13700;
|
||||||
|
w.servertime = new_servertime;
|
||||||
|
if(wasday != isday) {
|
||||||
|
MapManager.mapman.pushUpdate(w.world, new Client.DayNight(isday));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public MapManager(DynmapPlugin plugin, ConfigurationNode configuration) {
|
public MapManager(DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||||
plug_in = plugin;
|
plug_in = plugin;
|
||||||
mapman = this;
|
mapman = this;
|
||||||
@ -183,6 +198,9 @@ public class MapManager {
|
|||||||
for (World world : plug_in.getServer().getWorlds()) {
|
for (World world : plug_in.getServer().getWorlds()) {
|
||||||
activateWorld(world);
|
activateWorld(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scheduler.scheduleSyncRepeatingTask(plugin, new CheckWorldTimes(), 5*20, 5*20); /* Check very 5 seconds */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderFullWorld(Location l) {
|
void renderFullWorld(Location l) {
|
||||||
@ -234,6 +252,7 @@ public class MapManager {
|
|||||||
|
|
||||||
List<ConfigurationNode> loclist = worldConfiguration.getNodes("fullrenderlocations");
|
List<ConfigurationNode> loclist = worldConfiguration.getNodes("fullrenderlocations");
|
||||||
dynmapWorld.seedloc = new ArrayList<Location>();
|
dynmapWorld.seedloc = new ArrayList<Location>();
|
||||||
|
dynmapWorld.servertime = (int)(w.getTime() % 24000);
|
||||||
if(loclist != null) {
|
if(loclist != null) {
|
||||||
for(ConfigurationNode loc : loclist) {
|
for(ConfigurationNode loc : loclist) {
|
||||||
Location lx = new Location(w, loc.getDouble("x", 0), loc.getDouble("y", 64), loc.getDouble("z", 0));
|
Location lx = new Location(w, loc.getDouble("x", 0), loc.getDouble("y", 64), loc.getDouble("z", 0));
|
||||||
|
@ -292,6 +292,7 @@ public class FlatMap extends MapType {
|
|||||||
s(o, "title", c.getString("title"));
|
s(o, "title", c.getString("title"));
|
||||||
s(o, "icon", c.getString("icon"));
|
s(o, "icon", c.getString("icon"));
|
||||||
s(o, "prefix", c.getString("prefix"));
|
s(o, "prefix", c.getString("prefix"));
|
||||||
|
s(o, "nightandday", c.getBoolean("night-and-day",false));
|
||||||
a(worldObject, "maps", o);
|
a(worldObject, "maps", o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,6 +360,8 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||||||
int lightlevel = 15;
|
int lightlevel = 15;
|
||||||
int lightlevel_day = 15;
|
int lightlevel_day = 15;
|
||||||
result.setTransparent();
|
result.setTransparent();
|
||||||
|
if(result_day != null)
|
||||||
|
result_day.setTransparent();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (mapiter.y < 0) {
|
if (mapiter.y < 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -25,8 +25,11 @@ FlatMapType.prototype = $.extend(new DynMapType(), {
|
|||||||
var imgSize;
|
var imgSize;
|
||||||
var tileName;
|
var tileName;
|
||||||
|
|
||||||
tileName = this.prefix + '_128_' + coord.x + '_' + coord.y + '.png';
|
var dnprefix = '';
|
||||||
|
if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].nightandday && this.dynmap.serverday)
|
||||||
|
dnprefix = '_day';
|
||||||
|
|
||||||
|
tileName = this.prefix + dnprefix + '_128_' + coord.x + '_' + coord.y + '.png';
|
||||||
imgSize = Math.pow(2, 7+zoom);
|
imgSize = Math.pow(2, 7+zoom);
|
||||||
var tile = $('<div/>')
|
var tile = $('<div/>')
|
||||||
.addClass('tile')
|
.addClass('tile')
|
||||||
|
@ -43,17 +43,21 @@ KzedMapType.prototype = $.extend(new DynMapType(), {
|
|||||||
var debugred;
|
var debugred;
|
||||||
var debugblue;
|
var debugblue;
|
||||||
|
|
||||||
|
var dnprefix = '';
|
||||||
|
if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].nightandday && this.dynmap.serverday)
|
||||||
|
dnprefix = '_day';
|
||||||
|
|
||||||
if (zoom == 0) {
|
if (zoom == 0) {
|
||||||
// Most zoomed out tiles.
|
// Most zoomed out tiles.
|
||||||
tileSize = 128;
|
tileSize = 128;
|
||||||
imgSize = tileSize;
|
imgSize = tileSize;
|
||||||
tileName = 'z' + this.prefix + '_' + (-coord.x * tileSize*2) + '_' + (coord.y * tileSize*2) + '.png';
|
tileName = 'z' + this.prefix + dnprefix + '_' + (-coord.x * tileSize*2) + '_' + (coord.y * tileSize*2) + '.png';
|
||||||
} else {
|
} else {
|
||||||
// Other zoom levels.
|
// Other zoom levels.
|
||||||
tileSize = 128;
|
tileSize = 128;
|
||||||
|
|
||||||
imgSize = Math.pow(2, 6+zoom);
|
imgSize = Math.pow(2, 6+zoom);
|
||||||
tileName = this.prefix + '_' + (-coord.x*tileSize) + '_' + (coord.y*tileSize) + '.png';
|
tileName = this.prefix + dnprefix + '_' + (-coord.x*tileSize) + '_' + (coord.y*tileSize) + '.png';
|
||||||
}
|
}
|
||||||
var img;
|
var img;
|
||||||
var tile = $('<div/>')
|
var tile = $('<div/>')
|
||||||
|
@ -91,6 +91,8 @@ DynMap.prototype = {
|
|||||||
registeredTiles: [],
|
registeredTiles: [],
|
||||||
players: {},
|
players: {},
|
||||||
lasttimestamp: '0',
|
lasttimestamp: '0',
|
||||||
|
servertime: 0,
|
||||||
|
serverday: false,
|
||||||
followingPlayer: '',
|
followingPlayer: '',
|
||||||
formatUrl: function(name, options) {
|
formatUrl: function(name, options) {
|
||||||
var url = this.options.url[name];
|
var url = this.options.url[name];
|
||||||
@ -370,6 +372,22 @@ DynMap.prototype = {
|
|||||||
me.lasttimestamp = update.timestamp;
|
me.lasttimestamp = update.timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
me.servertime = update.servertime;
|
||||||
|
var oldday = me.serverday;
|
||||||
|
if(me.servertime > 23100 || me.servertime < 12900)
|
||||||
|
me.serverday = true;
|
||||||
|
else
|
||||||
|
me.serverday = false;
|
||||||
|
if(me.serverday != oldday) {
|
||||||
|
var mtid = me.map.mapTypeId;
|
||||||
|
if(me.map.mapTypes[mtid].nightandday) {
|
||||||
|
me.map.setMapTypeId('none');
|
||||||
|
window.setTimeout(function() {
|
||||||
|
me.map.setMapTypeId(mtid);
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var newplayers = {};
|
var newplayers = {};
|
||||||
$.each(update.players, function(index, playerUpdate) {
|
$.each(update.players, function(index, playerUpdate) {
|
||||||
var name = playerUpdate.name;
|
var name = playerUpdate.name;
|
||||||
|
Loading…
Reference in New Issue
Block a user