2929import com .mojang .authlib .properties .Property ;
3030import com .mojang .authlib .properties .PropertyMap ;
3131import java .lang .reflect .Constructor ;
32+ import java .lang .reflect .Field ;
3233import java .lang .reflect .Method ;
3334import java .util .HashMap ;
3435import java .util .Map ;
@@ -51,6 +52,8 @@ public final class SpigotVersionSpecificMethods {
5152 private static final Constructor <GameProfile > RECORD_GAME_PROFILE_CONSTRUCTOR ;
5253 private static final Constructor <PropertyMap > IMMUTABLE_PROPERTY_MAP_CONSTRUCTOR ;
5354 private static final Method MULTIMAP_FROM_MAP ;
55+ private static final Field PROFILE_NAME_FIELD ;
56+ private static final Field PROFILE_UUID_FIELD ;
5457
5558 static {
5659 GET_SPIGOT = ReflectionUtils .getMethod (Player .class , "spigot" );
@@ -69,6 +72,8 @@ public final class SpigotVersionSpecificMethods {
6972 GameProfile .class , true , UUID .class , String .class , PropertyMap .class );
7073 IMMUTABLE_PROPERTY_MAP_CONSTRUCTOR = (Constructor <PropertyMap >)
7174 PropertyMap .class .getConstructors ()[0 ];
75+ PROFILE_NAME_FIELD = ReflectionUtils .getField (GameProfile .class , "name" );
76+ PROFILE_UUID_FIELD = ReflectionUtils .getField (GameProfile .class , "id" );
7277 // Avoid relocation for this class.
7378 Class <?> multimaps = ReflectionUtils .getClass (String .join ("." , "com" ,
7479 "google" , "common" , "collect" , "Multimaps" ));
@@ -81,6 +86,12 @@ public SpigotVersionSpecificMethods(SpigotPlugin plugin) {
8186 this .plugin = plugin ;
8287 }
8388
89+ public GameProfile createGameProfile (GameProfile oldProfile , Property textureProperty ) {
90+ String name = (String ) ReflectionUtils .getValue (oldProfile , PROFILE_NAME_FIELD );
91+ UUID uuid = (UUID ) ReflectionUtils .getValue (oldProfile , PROFILE_UUID_FIELD );
92+ return createGameProfile (uuid , name , textureProperty );
93+ }
94+
8495 public GameProfile createGameProfile (UUID uuid , String name , Property texturesProperty ) {
8596 if (RECORD_GAME_PROFILE_CONSTRUCTOR != null && IMMUTABLE_PROPERTY_MAP_CONSTRUCTOR != null ) {
8697 if (texturesProperty != null ) {
0 commit comments