-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdynmap.patch
150 lines (141 loc) · 5.37 KB
/
dynmap.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
diff --git a/DynmapCore/src/main/resources/extracted/web/js/chat.js b/DynmapCore/src/main/resources/extracted/web/js/chat.js
index e71f03ef..60fc95e2 100644
--- a/DynmapCore/src/main/resources/extracted/web/js/chat.js
+++ b/DynmapCore/src/main/resources/extracted/web/js/chat.js
@@ -4,13 +4,17 @@ componentconstructors['chat'] = function(dynmap, configuration) {
if(dynmap.getBoolParameterByName("hidechat"))
return;
+
+ const seen = new Set();
// Provides 'chat'-events by monitoring the world-updates.
$(dynmap).bind('worldupdate', function(event, update) {
swtch(update.type, {
chat: function() {
- $(dynmap).trigger('chat', [{source: update.source, name: update.playerName, text: update.message, account: update.account,
- channel: update.channel}]);
+ const event = {source: update.source, name: update.playerName, text: update.message, account: update.account, channel: update.channel};
+ const json = JSON.stringify(event);
+ if (!seen.has(json)) $(dynmap).trigger("chat", [event]);
+ seen.add(json);
}
});
});
@@ -26,7 +30,7 @@ componentconstructors['chat'] = function(dynmap, configuration) {
var data = '{"name":'+JSON.stringify(pname?pname:"")+',"message":'+JSON.stringify(message)+'}';
$.ajax({
type: 'POST',
- contentType: "application/json; charset=utf-8",
+ contentType: "application/json; charset=utf-8",
url: config.url.sendmessage,
data: data,
dataType: 'json',
diff --git a/DynmapCore/src/main/resources/extracted/web/js/dynmaputils.js b/DynmapCore/src/main/resources/extracted/web/js/dynmaputils.js
index 936664aa..6af90c12 100644
--- a/DynmapCore/src/main/resources/extracted/web/js/dynmaputils.js
+++ b/DynmapCore/src/main/resources/extracted/web/js/dynmaputils.js
@@ -207,13 +207,18 @@ var DynmapTileLayer = L.TileLayer.extend({
},
_tickLoadQueue: function() {
- if (this._loadingTiles.length > 4) {
+ if (this._loadingTiles.length > 12) {
return;
}
+ if (this._loadingTiles.length !== 0) {
+ $(dynmap).trigger("load-from-center");
+ }
+
var next = this._loadQueue.shift();
if (!next) {
+ $(dynmap).trigger("tile-queue-loaded");
return;
}
diff --git a/DynmapCore/src/main/resources/extracted/web/js/map.js b/DynmapCore/src/main/resources/extracted/web/js/map.js
index a0ec24b6..e76a94b1 100644
--- a/DynmapCore/src/main/resources/extracted/web/js/map.js
+++ b/DynmapCore/src/main/resources/extracted/web/js/map.js
@@ -1,5 +1,8 @@
"use strict";
//if (!console) console = { log: function() {} };
+if (window.dynUpdate == null) window.dynUpdate = function (url, cb) {
+ $.getJSON(url, cb);
+}
var componentconstructors = {};
var maptypes = {};
@@ -99,33 +102,23 @@ DynMap.prototype = {
});
me.defaultworld = me.defaultworld || world;
});
- var urlarg = me.getParameterByName('worldname');
- if(urlarg == "")
- urlarg = me.options.defaultworld || "";
- if(urlarg != "") {
- me.defaultworld = me.worlds[urlarg] || me.defaultworld;
- }
- urlarg = me.getParameterByName('mapname');
- if(urlarg != "") {
- me.defaultworld.defaultmap = me.defaultworld.maps[urlarg] || me.defaultworld.defaultmap;
- }
- urlarg = me.getIntParameterByName('x');
- if(urlarg != null)
- me.defaultworld.center.x = urlarg;
- urlarg = me.getIntParameterByName('y');
- if(urlarg != null)
- me.defaultworld.center.y = urlarg;
- urlarg = me.getIntParameterByName('z');
- if(urlarg != null)
- me.defaultworld.center.z = urlarg;
- urlarg = me.getParameterByName('nogui');
- if(urlarg != "") {
- me.nogui = (urlarg == 'true');
- }
- urlarg = me.getParameterByName('nocompass');
- if(urlarg != "") {
- me.nocompass = (urlarg == 'true');
- }
+
+ const parts = location.hash.slice(2).split(",");
+ const zoom = parseFloat(parts[0]);
+ const x = parseFloat(parts[1]);
+ const z = parseFloat(parts[2]);
+
+ if (isNaN(zoom) || isNaN(x) || isNaN(z)) return;
+
+ var world = parts[3];
+
+ if (world !== "world_nether" && world !== "world_the_end") world = "world";
+
+ me.defaultworld.defaultmap = me.defaultworld.maps[world] || me.defaultworld.defaultmap
+ me.defaultworld.center.x = x;
+ me.defaultworld.center.z = z;
+
+ me.options.defaultzoom = zoom;
},
initialize: function() {
var me = this;
@@ -620,7 +613,8 @@ DynMap.prototype = {
}
$(me).trigger('worldupdating');
- $.getJSON(me.formatUrl('update', { world: me.world.name, timestamp: me.lasttimestamp, reqid: me.reqid }), function(update) {
+
+ window.dynUpdate(me.formatUrl('update', { world: me.world.name, timestamp: me.lasttimestamp, reqid: me.reqid }), function(update) {
me.reqid++; // Bump request ID always
if (!update) {
setTimeout(function() { me.update(); }, me.options.updaterate);
@@ -647,7 +641,6 @@ DynMap.prototype = {
me.lasttimestamp = update.timestamp;
}
if(me.options.confighash != update.confighash) {
- window.location = me.getLink();
return;
}
me.playerfield.text(me.options['msg-players'] + " [" + update.currentcount + "/" + me.options.maxcount + "]");
@@ -695,7 +688,9 @@ DynMap.prototype = {
swtch(update.type, {
tile: function() {
- me.maptype.updateNamedTile(update.name, update.timestamp);
+ setTimeout(() => {
+ me.maptype.updateNamedTile(update.name, update.timestamp);
+ }, 1000);
},
playerjoin: function() {
$(me).trigger('playerjoin', [ update.playerName ]);