-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
63 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
.../modern/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/modern/ModernSkull.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.willfp.eco.internal.spigot.proxy.common.modern | ||
|
||
import com.mojang.authlib.GameProfile | ||
import com.mojang.authlib.properties.Property | ||
import net.minecraft.world.item.component.ResolvableProfile | ||
import org.bukkit.inventory.meta.SkullMeta | ||
import java.lang.reflect.Field | ||
import java.lang.reflect.Method | ||
import java.util.UUID | ||
|
||
private lateinit var setProfile: Method | ||
private lateinit var profile: Field | ||
private lateinit var value: Field | ||
|
||
var SkullMeta.texture: String? | ||
get() { | ||
if (!::value.isInitialized) { | ||
// Doing it this way because Property was changed to be a record and this is | ||
// a quick hack to get around that | ||
value = Property::class.java.getDeclaredField("value") | ||
value.isAccessible = true | ||
} | ||
|
||
if (!::profile.isInitialized) { | ||
// Assumes instance of CraftMetaSkull; package-private class so can't do manual type check | ||
profile = this.javaClass.getDeclaredField("profile") | ||
profile.isAccessible = true | ||
} | ||
|
||
val profile = profile[this] as ResolvableProfile? ?: return null | ||
val properties = profile.properties ?: return null | ||
val props = properties["textures"] ?: return null | ||
val prop = props.toMutableList().firstOrNull() ?: return null | ||
return value[prop] as String? | ||
} | ||
set(base64) { | ||
if (!::setProfile.isInitialized) { | ||
// Same here; that's why I can't delegate to a lazy initializer | ||
setProfile = this.javaClass.getDeclaredMethod("setProfile", ResolvableProfile::class.java) | ||
setProfile.isAccessible = true | ||
} | ||
|
||
if (base64 == null || base64.length < 20) { | ||
setProfile.invoke(this, null) | ||
} else { | ||
val uuid = UUID( | ||
base64.substring(base64.length - 20).hashCode().toLong(), | ||
base64.substring(base64.length - 10).hashCode().toLong() | ||
) | ||
val profile = GameProfile(uuid, "eco") | ||
profile.properties.put("textures", Property("textures", base64)) | ||
val resolvable = ResolvableProfile(profile) | ||
setProfile.invoke(this, resolvable) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
eco-core/core-nms/v1_21/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_21/Skull.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
version = 6.74.1 | ||
version = 6.74.2 | ||
kotlin.incremental.useClasspathSnapshot=false |