Change image response to 204 and always save an empty players.json

This commit is contained in:
Lukas Rieger (Blue) 2023-03-02 16:30:28 +01:00
parent 701f6cb2dc
commit c2499df3a7
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
3 changed files with 25 additions and 3 deletions

View File

@ -131,9 +131,18 @@ public class MapStorageRequestHandler implements HttpRequestHandler {
return new HttpResponse(HttpStatusCode.INTERNAL_SERVER_ERROR);
}
HttpResponse response = new HttpResponse(HttpStatusCode.OK);
response.setData("{}");
return response;
if (path.endsWith(".png")) {
return new HttpResponse(HttpStatusCode.NO_CONTENT);
}
if (path.endsWith(".json")) {
HttpResponse response = new HttpResponse(HttpStatusCode.OK);
response.addHeader("Content-Type", "application/json");
response.setData("{}");
return response;
}
return new HttpResponse(HttpStatusCode.NOT_FOUND);
}
private String calculateETag(String path, TileInfo tileInfo) {

View File

@ -30,6 +30,7 @@ public enum HttpStatusCode {
PROCESSING (102, "Processing"),
OK (200, "OK"),
NO_CONTENT (204, "No Content"),
MOVED_PERMANENTLY (301, "Moved Permanently"),
FOUND (302, "Found"),

View File

@ -39,6 +39,7 @@ import de.bluecolored.bluemap.core.world.Grid;
import de.bluecolored.bluemap.core.world.World;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@ -134,6 +135,7 @@ public class BmMap {
lowresTileManager.save();
saveRenderState();
saveMarkerState();
savePlayerState();
saveMapSettings();
// only save texture gallery if not present in storage
@ -215,6 +217,16 @@ public class BmMap {
}
}
public synchronized void savePlayerState() {
try (
OutputStream out = storage.writeMeta(id, META_FILE_PLAYERS);
) {
out.write("{}".getBytes(StandardCharsets.UTF_8));
} catch (Exception ex) {
Logger.global.logError("Failed to save markers for map '" + getId() + "'!", ex);
}
}
public String getId() {
return id;
}