wow! avatars!!

This commit is contained in:
Lee
2024-04-06 05:45:50 +01:00
parent 50265b6228
commit 0819b228ba
10 changed files with 206 additions and 9 deletions

View File

@ -1,9 +1,16 @@
package cc.fascinated.player.impl;
import lombok.AllArgsConstructor;
import lombok.Getter;
import cc.fascinated.Main;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
@Getter @AllArgsConstructor
import java.net.URI;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
@Getter
public class Skin {
/**
@ -15,4 +22,40 @@ public class Skin {
* The model of the skin
*/
private final SkinType model;
/**
* The bytes of the skin
*/
@JsonIgnore
private final byte[] skinBytes;
/**
* The head of the skin
*/
@JsonIgnore
private final SkinPart head;
public Skin(String url, SkinType model) {
this.url = url;
this.model = model;
this.skinBytes = this.getSkinData();
// The skin parts
this.head = new SkinPart(this.skinBytes, 8, 8, 8, 8, 20);
}
/**
* Gets the skin data from the URL.
*
* @return the skin data
*/
@SneakyThrows @JsonIgnore
public byte[] getSkinData() {
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI(this.url))
.GET()
.build();
return Main.getCLIENT().send(request, HttpResponse.BodyHandlers.ofByteArray()).body();
}
}