remove unnecessary skin fallback
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m50s

This commit is contained in:
Lee 2024-04-13 16:09:01 +01:00
parent b708191267
commit 4d4e8557d8
4 changed files with 28 additions and 13 deletions

@ -20,16 +20,6 @@ import java.util.Map;
@AllArgsConstructor @NoArgsConstructor @AllArgsConstructor @NoArgsConstructor
@Getter @Log4j2 @Getter @Log4j2
public class Skin { public class Skin {
/**
* The default skins, usually used when the skin is not found.
*/
public static final Map<Model, Skin> DEFAULT_SKINS = new HashMap<>();
static {
DEFAULT_SKINS.put(Model.DEFAULT, new Skin(Config.INSTANCE.getWebPublicUrl() + "/assets/steve.png", Model.DEFAULT));
DEFAULT_SKINS.put(Model.SLIM, new Skin(Config.INSTANCE.getWebPublicUrl() + "/assets/alex.png", Model.SLIM));
}
/** /**
* The URL for the skin * The URL for the skin
*/ */
@ -62,9 +52,6 @@ public class Skin {
this.model = model; this.model = model;
this.skinImage = PlayerUtils.getSkinImage(url); this.skinImage = PlayerUtils.getSkinImage(url);
if (skinImage == null) { // Use the default skin if the skin is not found
this.skinImage = PlayerUtils.getSkinImage(DEFAULT_SKINS.get(model).getUrl());
}
if (this.skinImage != null) { if (this.skinImage != null) {
try { try {
BufferedImage image = ImageIO.read(new ByteArrayInputStream(this.skinImage)); BufferedImage image = ImageIO.read(new ByteArrayInputStream(this.skinImage));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

@ -0,0 +1,28 @@
package cc.fascinated.tests;
import cc.fascinated.config.TestRedisConfig;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@AutoConfigureMockMvc
@SpringBootTest(classes = TestRedisConfig.class)
class MojangControllerTests {
@Autowired
private MockMvc mockMvc;
@Test
public void ensureEndpointStatusLookupSuccess() throws Exception {
mockMvc.perform(get("/mojang/status")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
}