diff --git a/eco-core/core-nms/v1_16_R3/src/main/kotlin/Skull.kt b/eco-core/core-nms/v1_16_R3/src/main/kotlin/Skull.kt index 0725b22f..7f284413 100644 --- a/eco-core/core-nms/v1_16_R3/src/main/kotlin/Skull.kt +++ b/eco-core/core-nms/v1_16_R3/src/main/kotlin/Skull.kt @@ -1,22 +1,22 @@ import com.mojang.authlib.GameProfile import com.mojang.authlib.properties.Property -import proxy.SkullProxy import org.bukkit.inventory.meta.SkullMeta +import proxy.SkullProxy import java.lang.reflect.Method import java.util.* class Skull : SkullProxy { - private var setProfile: Method? = null + private lateinit var setProfile: Method override fun setSkullTexture( meta: SkullMeta, base64: String ) { try { - if (setProfile == null) { + if (!this::setProfile.isInitialized) { setProfile = meta.javaClass.getDeclaredMethod("setProfile", GameProfile::class.java) - setProfile!!.isAccessible = true + setProfile.isAccessible = true } val uuid = UUID( base64.substring(base64.length - 20).hashCode().toLong(), @@ -24,7 +24,7 @@ class Skull : SkullProxy { ) val profile = GameProfile(uuid, "eco") profile.properties.put("textures", Property("textures", base64)) - setProfile!!.invoke(meta, profile) + setProfile.invoke(meta, profile) } catch (e: ReflectiveOperationException) { e.printStackTrace() } diff --git a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/proxy/v1_17_R1/Skull.kt b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/proxy/v1_17_R1/Skull.kt index 1dac6c11..47c2585c 100644 --- a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/proxy/v1_17_R1/Skull.kt +++ b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/proxy/v1_17_R1/Skull.kt @@ -8,16 +8,16 @@ import java.lang.reflect.Method import java.util.* class Skull : SkullProxy { - private var setProfile: Method? = null + private lateinit var setProfile: Method override fun setSkullTexture( meta: SkullMeta, base64: String ) { try { - if (setProfile == null) { + if (!this::setProfile.isInitialized) { setProfile = meta.javaClass.getDeclaredMethod("setProfile", GameProfile::class.java) - setProfile!!.isAccessible = true + setProfile.isAccessible = true } val uuid = UUID( base64.substring(base64.length - 20).hashCode().toLong(), @@ -25,7 +25,7 @@ class Skull : SkullProxy { ) val profile = GameProfile(uuid, "eco") profile.properties.put("textures", Property("textures", base64)) - setProfile!!.invoke(meta, profile) + setProfile.invoke(meta, profile) } catch (e: ReflectiveOperationException) { e.printStackTrace() }