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