Skull.kt now uses lateinit var

This commit is contained in:
Auxilor
2021-08-07 13:24:36 +01:00
parent 09d444da58
commit 1e712dcae6
2 changed files with 9 additions and 9 deletions

View File

@@ -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()
}

View File

@@ -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()
}