diff options
author | nea <nea@nea.moe> | 2023-09-09 15:10:34 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-09-09 15:10:34 +0200 |
commit | e1eac7232420d34bf7c347a9e3d49e75a7399cae (patch) | |
tree | b6219d10386955dbb2b26ebdb011dd081115d431 /src/main | |
parent | c82c051704424763c20742b616228cfe636b9f65 (diff) | |
download | firmament-e1eac7232420d34bf7c347a9e3d49e75a7399cae.tar.gz firmament-e1eac7232420d34bf7c347a9e3d49e75a7399cae.tar.bz2 firmament-e1eac7232420d34bf7c347a9e3d49e75a7399cae.zip |
Fix some skulls not being properly reskinned
[no changelog]
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/util/item/SkullItemData.kt | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/item/SkullItemData.kt b/src/main/kotlin/moe/nea/firmament/util/item/SkullItemData.kt index 4d4d386..39088ec 100644 --- a/src/main/kotlin/moe/nea/firmament/util/item/SkullItemData.kt +++ b/src/main/kotlin/moe/nea/firmament/util/item/SkullItemData.kt @@ -47,14 +47,18 @@ fun GameProfile.setTextures(textures: MinecraftTexturesPayloadKt) { fun decodeProfileTextureProperty(property: Property): MinecraftTexturesPayloadKt? { assertTrueOr(property.name == PlayerSkinProvider.TEXTURES) { return null } - try { - val json = java.util.Base64.getDecoder().decode(property.value).decodeToString() - return Firmament.json.decodeFromString<MinecraftTexturesPayloadKt>(json) + return try { + var encodedF: String = property.value + while (encodedF.length % 4 != 0 && encodedF.last() == '=') { + encodedF = encodedF.substring(0, encodedF.length - 1) + } + val json = java.util.Base64.getDecoder().decode(encodedF).decodeToString() + Firmament.json.decodeFromString<MinecraftTexturesPayloadKt>(json) } catch (e: Exception) { // Malformed profile data if (Firmament.DEBUG) e.printStackTrace() - return null + null } } |