add skin overlays to all images if it's enabled
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m35s

This commit is contained in:
Lee
2024-04-12 19:50:36 +01:00
parent 4e08955ab9
commit 55c1ca4139
8 changed files with 40 additions and 43 deletions

View File

@ -59,12 +59,14 @@ public interface ISkinPart {
@Getter
enum Vanilla implements ISkinPart {
// Overlays
HEAD_OVERLAY_TOP(true, new Coordinates(40, 0), 8, 8),
HEAD_OVERLAY_FACE(true, new Coordinates(40, 8), 8, 8),
HEAD_OVERLAY_LEFT(true, new Coordinates(48, 8), 8, 8),
// Head
HEAD_TOP(true, new Coordinates(8, 0), 8, 8),
HEAD_TOP(true, new Coordinates(8, 0), 8, 8, HEAD_OVERLAY_TOP),
FACE(false, new Coordinates(8, 8), 8, 8, HEAD_OVERLAY_FACE),
HEAD_LEFT(true, new Coordinates(0, 8), 8, 8),
HEAD_LEFT(true, new Coordinates(0, 8), 8, 8, HEAD_OVERLAY_LEFT),
HEAD_RIGHT(true, new Coordinates(16, 8), 8, 8),
HEAD_BOTTOM(true, new Coordinates(16, 0), 8, 8),
HEAD_BACK(true, new Coordinates(24, 8), 8, 8),

View File

@ -1,5 +1,6 @@
package cc.fascinated.model.skin;
import cc.fascinated.common.EnumUtils;
import cc.fascinated.common.PlayerUtils;
import cc.fascinated.config.Config;
import com.fasterxml.jackson.annotation.JsonIgnore;
@ -77,9 +78,10 @@ public class Skin {
}
String url = json.get("url").getAsString();
JsonObject metadata = json.getAsJsonObject("metadata");
Model model = Model.fromName(metadata == null ? "default" : // Fall back to slim if the model is not found
metadata.get("model").getAsString());
return new Skin(url, model);
return new Skin(
url,
EnumUtils.getEnumConstant(Model.class, metadata != null ? metadata.get("model").getAsString() : "DEFAULT")
);
}
/**
@ -106,21 +108,6 @@ public class Skin {
*/
public enum Model {
DEFAULT,
SLIM;
/**
* Gets the model from its name.
*
* @param name the name of the model
* @return the model
*/
public static Model fromName(String name) {
for (Model model : values()) {
if (model.name().equalsIgnoreCase(name)) {
return model;
}
}
return null;
}
SLIM
}
}