more cleanup

This commit is contained in:
Lee 2024-04-08 05:29:05 +01:00
parent 3f7f1864a6
commit 1f45d26f53
11 changed files with 34 additions and 31 deletions

@ -1,9 +1,9 @@
package cc.fascinated.controller; package cc.fascinated.controller;
import cc.fascinated.service.player.PlayerService; import cc.fascinated.service.PlayerService;
import cc.fascinated.service.player.impl.Player; import cc.fascinated.model.player.Player;
import cc.fascinated.service.player.impl.Skin; import cc.fascinated.model.player.Skin;
import cc.fascinated.service.player.impl.SkinPart; import cc.fascinated.model.player.SkinPart;
import lombok.NonNull; import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.CacheControl; import org.springframework.http.CacheControl;
@ -49,7 +49,7 @@ public class PlayerController {
@RequestParam(required = false, defaultValue = "250") int size) { @RequestParam(required = false, defaultValue = "250") int size) {
Player player = playerManagerService.getPlayer(id); Player player = playerManagerService.getPlayer(id);
byte[] headBytes = new byte[0]; byte[] headBytes = new byte[0];
if (player != null) { if (player != null) { // The player exists
Skin skin = player.getSkin(); Skin skin = player.getSkin();
SkinPart skinPart = skin.getPart(part); SkinPart skinPart = skin.getPart(part);
if (skinPart != null) { if (skinPart != null) {
@ -57,7 +57,7 @@ public class PlayerController {
} }
} }
if (headBytes == null) { if (headBytes == null) { // Fallback to the default head
headBytes = defaultHead.getPartData(size); headBytes = defaultHead.getPartData(size);
} }

@ -1,6 +1,6 @@
package cc.fascinated.exception; package cc.fascinated.exception;
import cc.fascinated.model.ErrorResponse; import cc.fascinated.model.response.ErrorResponse;
import io.micrometer.common.lang.NonNull; import io.micrometer.common.lang.NonNull;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;

@ -1,4 +1,4 @@
package cc.fascinated.service.player.impl; package cc.fascinated.model.player;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;

@ -1,10 +1,11 @@
package cc.fascinated.service.player.impl; package cc.fascinated.model.player;
import cc.fascinated.service.mojang.types.MojangProfile; import cc.fascinated.service.mojang.model.MojangProfile;
import cc.fascinated.util.Tuple; import cc.fascinated.util.Tuple;
import cc.fascinated.util.UUIDUtils; import cc.fascinated.util.UUIDUtils;
import lombok.Getter; import lombok.Getter;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Getter @Getter
@ -21,24 +22,26 @@ public class Player {
private final String name; private final String name;
/** /**
* The skin of the player * The skin of the player, null if the
* <p> * player does not have a skin
* This will be null if the player does not have a skin.
* </p>
*/ */
private Skin skin; private Skin skin;
/** /**
* The cape of the player * The cape of the player, null if the
* <p> * player does not have a cape
* This will be null if the player does not have a cape.
* </p>
*/ */
private Cape cape; private Cape cape;
/**
* The raw properties of the player
*/
private final List<MojangProfile.ProfileProperty> rawProperties;
public Player(MojangProfile profile) { public Player(MojangProfile profile) {
this.uuid = UUID.fromString(UUIDUtils.addUUIDDashes(profile.getId())); this.uuid = UUID.fromString(UUIDUtils.addUUIDDashes(profile.getId()));
this.name = profile.getName(); this.name = profile.getName();
this.rawProperties = profile.getProperties();
// Get the skin and cape // Get the skin and cape
Tuple<Skin, Cape> skinAndCape = profile.getSkinAndCape(); Tuple<Skin, Cape> skinAndCape = profile.getSkinAndCape();

@ -1,4 +1,4 @@
package cc.fascinated.service.player.impl; package cc.fascinated.model.player;
import cc.fascinated.Main; import cc.fascinated.Main;
import cc.fascinated.config.Config; import cc.fascinated.config.Config;

@ -1,4 +1,4 @@
package cc.fascinated.service.player.impl; package cc.fascinated.model.player;
import lombok.Getter; import lombok.Getter;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;

@ -1,4 +1,4 @@
package cc.fascinated.model; package cc.fascinated.model.response;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.micrometer.common.lang.NonNull; import io.micrometer.common.lang.NonNull;

@ -1,9 +1,9 @@
package cc.fascinated.service.player; package cc.fascinated.service;
import cc.fascinated.service.mojang.MojangAPIService; import cc.fascinated.service.mojang.MojangAPIService;
import cc.fascinated.service.mojang.types.MojangProfile; import cc.fascinated.service.mojang.model.MojangProfile;
import cc.fascinated.service.mojang.types.MojangUsernameToUuid; import cc.fascinated.service.mojang.model.MojangUsernameToUuid;
import cc.fascinated.service.player.impl.Player; import cc.fascinated.model.player.Player;
import cc.fascinated.util.UUIDUtils; import cc.fascinated.util.UUIDUtils;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import net.jodah.expiringmap.ExpirationPolicy; import net.jodah.expiringmap.ExpirationPolicy;

@ -1,7 +1,7 @@
package cc.fascinated.service.mojang; package cc.fascinated.service.mojang;
import cc.fascinated.service.mojang.types.MojangProfile; import cc.fascinated.service.mojang.model.MojangProfile;
import cc.fascinated.service.mojang.types.MojangUsernameToUuid; import cc.fascinated.service.mojang.model.MojangUsernameToUuid;
import cc.fascinated.util.WebRequest; import cc.fascinated.util.WebRequest;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;

@ -1,8 +1,8 @@
package cc.fascinated.service.mojang.types; package cc.fascinated.service.mojang.model;
import cc.fascinated.Main; import cc.fascinated.Main;
import cc.fascinated.service.player.impl.Cape; import cc.fascinated.model.player.Cape;
import cc.fascinated.service.player.impl.Skin; import cc.fascinated.model.player.Skin;
import cc.fascinated.util.Tuple; import cc.fascinated.util.Tuple;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;

@ -1,4 +1,4 @@
package cc.fascinated.service.mojang.types; package cc.fascinated.service.mojang.model;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;