Skull.kt now uses lateinit var
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user