Skip to content

Commit

Permalink
fix: 頭のテクスチャが正しく表示されないのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Dec 22, 2023
1 parent 354122e commit bdef677
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.unchama.itemstackbuilder

import com.mojang.authlib.GameProfile
import com.mojang.authlib.properties.Property
import org.apache.commons.codec.binary.Base64
import org.bukkit.inventory.meta.SkullMeta
import org.bukkit.{Bukkit, Material}

Expand Down Expand Up @@ -32,16 +33,34 @@ class SkullItemStackBuilder(private val owner: SkullOwnerReference)
meta.setOwningPlayer(Bukkit.getOfflinePlayer(uuid))
val gameProfile = new GameProfile(uuid, name)

val textureUrl =
s"http://textures.minecraft.net/texture/${uuid.toString.replaceAll("-", "")}"

val encodedData = Base64.encodeBase64(
String.format("{textures:{SKIN:{url:\"%s\"}}}", textureUrl).getBytes
)

gameProfile
.getProperties
.put("textures", new Property("textures", new String(encodedData)))

val profileField = meta.getClass.getDeclaredField("profile")
profileField.setAccessible(true)
profileField.set(meta, gameProfile)
case SkullOwnerUuid(uuid) =>
meta.setOwningPlayer(Bukkit.getOfflinePlayer(uuid))
val gameProfile = new GameProfile(uuid, null)

val profileField = meta.getClass.getDeclaredField("profile")
profileField.setAccessible(true)
profileField.set(meta, gameProfile)
val textureUrl =
s"http://textures.minecraft.net/texture/${uuid.toString.replaceAll("-", "")}"

val encodedData = Base64.encodeBase64(
String.format("{textures:{SKIN:{url:\"%s\"}}}", textureUrl).getBytes
)

gameProfile
.getProperties
.put("textures", new Property("textures", new String(encodedData)))

/**
* @see
Expand Down

0 comments on commit bdef677

Please sign in to comment.