mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-02 23:23:41 +01:00
Nicer invalid update-url handling (for invalid world-names or non-existing worlds).
This commit is contained in:
parent
5778611227
commit
1e04d10b35
@ -10,6 +10,10 @@ public class HttpErrorHandler {
|
|||||||
response.getBody();
|
response.getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void handleForbidden(HttpResponse response) throws IOException {
|
||||||
|
handle(response, 403, "Forbidden");
|
||||||
|
}
|
||||||
|
|
||||||
public static void handleNotFound(HttpResponse response) throws IOException {
|
public static void handleNotFound(HttpResponse response) throws IOException {
|
||||||
handle(response, 404, "Not found");
|
handle(response, 404, "Not found");
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.dynmap.Client;
|
import org.dynmap.Client;
|
||||||
import org.dynmap.MapManager;
|
import org.dynmap.MapManager;
|
||||||
import org.dynmap.PlayerList;
|
import org.dynmap.PlayerList;
|
||||||
|
import org.dynmap.web.HttpErrorHandler;
|
||||||
import org.dynmap.web.HttpHandler;
|
import org.dynmap.web.HttpHandler;
|
||||||
import org.dynmap.web.HttpRequest;
|
import org.dynmap.web.HttpRequest;
|
||||||
import org.dynmap.web.HttpResponse;
|
import org.dynmap.web.HttpResponse;
|
||||||
@ -34,15 +35,19 @@ public class ClientUpdateHandler implements HttpHandler {
|
|||||||
|
|
||||||
Matcher match = updatePathPattern.matcher(path);
|
Matcher match = updatePathPattern.matcher(path);
|
||||||
|
|
||||||
if (!match.matches())
|
if (!match.matches()) {
|
||||||
|
HttpErrorHandler.handleForbidden(response);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String worldName = match.group(1);
|
String worldName = match.group(1);
|
||||||
String timeKey = match.group(2);
|
String timeKey = match.group(2);
|
||||||
|
|
||||||
World world = server.getWorld(worldName);
|
World world = server.getWorld(worldName);
|
||||||
if (world == null)
|
if (world == null) {
|
||||||
|
HttpErrorHandler.handleNotFound(response);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
long current = System.currentTimeMillis();
|
long current = System.currentTimeMillis();
|
||||||
long since = 0;
|
long since = 0;
|
||||||
|
@ -44,6 +44,8 @@ function DynMap(options) {
|
|||||||
$.getJSON(me.options.updateUrl + 'configuration', function(configuration) {
|
$.getJSON(me.options.updateUrl + 'configuration', function(configuration) {
|
||||||
me.configure(configuration);
|
me.configure(configuration);
|
||||||
me.initialize();
|
me.initialize();
|
||||||
|
}, function(status, statusMessage) {
|
||||||
|
alert('Could not retrieve configuration: ' + statusMessage);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
DynMap.prototype = {
|
DynMap.prototype = {
|
||||||
@ -333,9 +335,9 @@ DynMap.prototype = {
|
|||||||
//divs.filter(function(i){return parseInt(divs[i].attr('rel')) > timestamp+me.options.messagettl;}).remove();
|
//divs.filter(function(i){return parseInt(divs[i].attr('rel')) > timestamp+me.options.messagettl;}).remove();
|
||||||
});
|
});
|
||||||
setTimeout(function() { me.update(); }, me.options.updaterate);
|
setTimeout(function() { me.update(); }, me.options.updaterate);
|
||||||
}, function(request, statusText, ex) {
|
}, function(status, statusText, ex) {
|
||||||
me.alertbox
|
me.alertbox
|
||||||
.text('Could not update map')
|
.text('Could not update map: ' + statusText)
|
||||||
.show();
|
.show();
|
||||||
setTimeout(function() { me.update(); }, me.options.updaterate);
|
setTimeout(function() { me.update(); }, me.options.updaterate);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user