From ad51d4d3574521e36fc2eb32af64b3bbcd9b6dfd Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Tue, 9 Apr 2024 01:31:48 -0400 Subject: [PATCH] Fix server icon route producing the wrong file name --- src/main/java/me/braydon/mc/controller/PlayerController.java | 2 +- src/main/java/me/braydon/mc/controller/ServerController.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/braydon/mc/controller/PlayerController.java b/src/main/java/me/braydon/mc/controller/PlayerController.java index 3d7020f..9f5a4ad 100644 --- a/src/main/java/me/braydon/mc/controller/PlayerController.java +++ b/src/main/java/me/braydon/mc/controller/PlayerController.java @@ -88,7 +88,7 @@ public final class PlayerController { * @return the skin part texture * @throws BadRequestException if the extension is invalid */ - @GetMapping("/{partName}/{query}.{extension}") + @GetMapping(value = "/{partName}/{query}.{extension}", produces = { MediaType.IMAGE_PNG_VALUE, MediaType.IMAGE_JPEG_VALUE }) @ResponseBody public ResponseEntity getPartTexture(@PathVariable @NonNull String partName, @PathVariable @NonNull String query, @PathVariable @NonNull String extension, @RequestParam(required = false) String size diff --git a/src/main/java/me/braydon/mc/controller/ServerController.java b/src/main/java/me/braydon/mc/controller/ServerController.java index 1da34c8..7fd47bf 100644 --- a/src/main/java/me/braydon/mc/controller/ServerController.java +++ b/src/main/java/me/braydon/mc/controller/ServerController.java @@ -32,6 +32,7 @@ import me.braydon.mc.model.MinecraftServer; import me.braydon.mc.model.cache.CachedMinecraftServer; import me.braydon.mc.service.MojangService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -98,11 +99,12 @@ public final class ServerController { * @param hostname the hostname of the server * @return the server icon */ - @GetMapping("/icon/{hostname}") + @GetMapping(value = "/icon/{hostname}", produces = MediaType.IMAGE_PNG_VALUE) @ResponseBody public ResponseEntity getServerFavicon(@PathVariable @NonNull String hostname) { return ResponseEntity.ok() .contentType(MediaType.IMAGE_PNG) + .header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=%s.png".formatted(hostname)) .body(mojangService.getServerFavicon(hostname)); } } \ No newline at end of file