File tree Expand file tree Collapse file tree
plugin/src/main/kotlin/trplugins/menu/util/bukkit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,7 +126,17 @@ object Heads {
126126 meta.owningPlayer?.name?.let { return it }
127127 }
128128
129- meta.getProperty<GameProfile >(" profile" )?.properties?.values()?.forEach {
129+ val profileValue = meta.getProperty<Any >(" profile" ) ? : return null
130+
131+ val gameProfile: GameProfile ? = if (profileValue is GameProfile ) {
132+ profileValue
133+ } else {
134+ // Minecraft 1.21+ 将 profile 字段改为 ResolvableProfile
135+ val optional = runCatching { profileValue.invokeMethod<Any >(" gameProfile" ) }.getOrNull()
136+ runCatching { optional?.invokeMethod<GameProfile >(" orElse" , null ) }.getOrNull()
137+ }
138+
139+ gameProfile?.properties?.values()?.forEach {
130140 if (it.getProperty<String >(NAME ) == " textures" ) return it.getProperty<String >(VALUE )
131141 }
132142 return null
You can’t perform that action at this time.
0 commit comments