Throw an error if a skin is classic AND modern

This commit is contained in:
Jordan Eldredge 2022-03-20 20:00:00 -07:00
parent 8ae08dce40
commit 69da26fb7c

View File

@ -123,10 +123,15 @@ async function addClassicSkinFromBuffer(
}
export async function getSkinType(zip: JSZip): Promise<SkinType> {
if (zip.file(/main\.bmp$/i).length > 0) {
const classic = (zip.file(/main\.bmp$/i).length > 0)
const modern = (zip.file(/skin\.xml$/i).length > 0);
if (classic && modern) {
throw new Error("Skin is both modern and classic.");
}
if (classic) {
return "CLASSIC";
}
if (zip.file(/skin\.xml$/i).length > 0) {
if (modern) {
return "MODERN";
}
throw new Error("Not a skin");