cache control of 1 hr
All checks were successful
deploy / deploy (push) Successful in 42s

This commit is contained in:
Lee 2024-04-06 18:42:52 +01:00
parent c52f9332a2
commit 1542cff64e
3 changed files with 10 additions and 1 deletions

@ -5,10 +5,16 @@ import cc.fascinated.player.impl.Player;
import cc.fascinated.player.impl.Skin; import cc.fascinated.player.impl.Skin;
import cc.fascinated.player.impl.SkinPart; import cc.fascinated.player.impl.SkinPart;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.CacheControl;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@RestController @RestController
@RequestMapping(value = "/") @RequestMapping(value = "/")
public class PlayerController { public class PlayerController {
@ -35,9 +41,11 @@ public class PlayerController {
if (player == null) { if (player == null) {
return null; return null;
} }
Skin skin = player.getSkin(); Skin skin = player.getSkin();
SkinPart head = skin.getHead(); SkinPart head = skin.getHead();
return ResponseEntity.ok() return ResponseEntity.ok()
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic())
.contentType(MediaType.IMAGE_PNG) .contentType(MediaType.IMAGE_PNG)
.body(head.getPartData()); .body(head.getPartData());
} }

@ -71,6 +71,7 @@ public class SkinPart {
if (image == null) { if (image == null) {
return null; return null;
} }
// Get the part of the image (e.g. the head)
BufferedImage partImage = image.getSubimage(this.x, this.y, this.width, this.height); BufferedImage partImage = image.getSubimage(this.x, this.y, this.width, this.height);
// Scale the image // Scale the image

@ -5,7 +5,7 @@ server:
whitelabel: whitelabel:
enabled: false enabled: false
public-url: http://localhost public-url: http://localhost:80
mojang: mojang:
session-server: https://sessionserver.mojang.com session-server: https://sessionserver.mojang.com