Class PlayerProfiles

java.lang.Object
com.cryptomorin.xseries.profiles.PlayerProfiles

@Internal public final class PlayerProfiles extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.authlib.GameProfile
     
    static final String
    The value after this URL is probably an SHA-252 value that Mojang uses to unique identify player skins.
    static final String
    Some people use this without quotes surrounding the keys, not sure if that'd work.
    static final String
    In v1.20.2 there were some changes to the Mojang API.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile
    createGameProfile(UUID uuid, String username)
     
    static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile
    createGameProfile(UUID uuid, String username, com.mojang.authlib.properties.PropertyMap properties)
     
    static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile
     
    static @Nullable String
    Tries to decode the string as a Base64 value.
    static String
    Encodes the provided string into Base64 format.
    static @Nullable com.mojang.authlib.GameProfile
    fromResolvableProfile(@Nullable Object profile)
    Tries to unwrap a GameProfile from a ResolvableProfile.
    static @Nullable String
    getOriginalValue(@Nullable com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
     
    static @NotNull String
    getPropertyValue(@NotNull com.mojang.authlib.properties.Property property)
    Retrieves the value of a Property, handling differences between versions.
    static Optional<com.mojang.authlib.properties.Property>
    getTextureProperty(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
     
    static @Nullable String
    getTextureValue(@NotNull com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
    Retrieves the skin value from the given GameProfile.
    static boolean
    hasTextures(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
    Checks if the provided GameProfile has a texture property.
    static @NotNull com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile
    Constructs a GameProfile using the provided texture hash and base64 string.
    static void
    removeTimestamp(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
     
    static com.mojang.authlib.GameProfile
    sanitizeProfile(com.mojang.authlib.GameProfile gameProfile)
    Uses the online/offline UUID depending on Bukkit.getOnlineMode().
    static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile
    setTexturesProperty(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile, String texture)
     
    static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile
    signXSeries(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
    All GameProfile created/modified by this library should have a special signature for debugging purposes, specially since we're directly messing with the server's internal cache it should be there in case something goes wrong.
    static @Nullable Object
    toResolvableProfile(@Nullable com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • XSERIES_SIG

      public static final String XSERIES_SIG
      In v1.20.2 there were some changes to the Mojang API. Before that version, both UUID and name fields couldn't be null, only one of them. It gave the error: Name and ID cannot both be blank Here, "blank" is null for UUID, and Character.isWhitespace for the name field.
      See Also:
    • NIL

      public static final com.mojang.authlib.GameProfile NIL
    • TEXTURES_NBT_PROPERTY_PREFIX

      public static final String TEXTURES_NBT_PROPERTY_PREFIX
      Some people use this without quotes surrounding the keys, not sure if that'd work.
      See Also:
    • TEXTURES_BASE_URL

      public static final String TEXTURES_BASE_URL
      The value after this URL is probably an SHA-252 value that Mojang uses to unique identify player skins.
      This wiki documents how to get base64 information from player's UUID.

      Older clients such as v1.8.9 (only tested for v1.8.9) cannot correctly load HTTPS textures. Not sure if plugins like ViaVersion handle this properly. Also, the MojangAPI UUID_TO_PROFILE returns HTTP for texture URL when the Base64 is decoded, so we can keep it consistent when it's not explicitly defined by the user.

      See Also:
  • Constructor Details

    • PlayerProfiles

      public PlayerProfiles()
  • Method Details

    • getTextureProperty

      public static Optional<com.mojang.authlib.properties.Property> getTextureProperty(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
    • getTextureValue

      @Nullable public static @Nullable String getTextureValue(@NotNull @NotNull com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
      Retrieves the skin value from the given GameProfile.
      Parameters:
      profile - The GameProfile to retrieve the skin value from.
      Returns:
      The skin value as a String, or null if not found.
      Throws:
      NullPointerException - if profile is null.
      See Also:
    • getOriginalValue

      @Nullable public static @Nullable String getOriginalValue(@Nullable @Nullable com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
    • getPropertyValue

      @NotNull public static @NotNull String getPropertyValue(@NotNull @NotNull com.mojang.authlib.properties.Property property)
      Retrieves the value of a Property, handling differences between versions.
      Since:
      4.0.1
    • hasTextures

      public static boolean hasTextures(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
      Checks if the provided GameProfile has a texture property.
      Parameters:
      profile - The GameProfile to check.
      Returns:
      true if the profile has a texture property, false otherwise.
      See Also:
    • profileFromHashAndBase64

      @NotNull public static @NotNull com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profileFromHashAndBase64(String hash, String base64)
      Constructs a GameProfile using the provided texture hash and base64 string.
      Parameters:
      hash - The texture hash used to construct the profile's textures.
      base64 - The base64 string representing the profile's textures.
      Returns:
      The constructed GameProfile.
    • removeTimestamp

      public static void removeTimestamp(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
    • fromResolvableProfile

      @Nullable public static @Nullable com.mojang.authlib.GameProfile fromResolvableProfile(@Nullable @Nullable Object profile) throws Throwable
      Tries to unwrap a GameProfile from a ResolvableProfile.
      Throws:
      Throwable
    • toResolvableProfile

      @Nullable public static @Nullable Object toResolvableProfile(@Nullable @Nullable com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile) throws Throwable
      Throws:
      Throwable
    • sanitizeProfile

      public static com.mojang.authlib.GameProfile sanitizeProfile(com.mojang.authlib.GameProfile gameProfile)
      Uses the online/offline UUID depending on Bukkit.getOnlineMode().
      Parameters:
      gameProfile - must have complete name and UUID
      Returns:
      may return the same or a new profile.
    • setTexturesProperty

      @Contract(pure=true) public static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile setTexturesProperty(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile, String texture)
    • encodeBase64

      @Contract(pure=true) public static String encodeBase64(String str)
      Encodes the provided string into Base64 format.
      Parameters:
      str - The string to encode.
      Returns:
      The Base64 encoded string.
    • decodeBase64

      @Nullable @Contract(pure=true) public static @Nullable String decodeBase64(String base64)
      Tries to decode the string as a Base64 value.
      Parameters:
      base64 - The Base64 string to decode.
      Returns:
      the decoded Base64 string if it is a valid Base64 string, or null if not.
    • createGameProfile

      @Contract(pure=true) public static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile createGameProfile(UUID uuid, String username)
    • createGameProfile

      @Contract(pure=true) public static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile createGameProfile(UUID uuid, String username, com.mojang.authlib.properties.PropertyMap properties)
    • signXSeries

      @Contract(pure=true) public static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile signXSeries(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile)
      All GameProfile created/modified by this library should have a special signature for debugging purposes, specially since we're directly messing with the server's internal cache it should be there in case something goes wrong.
    • createNamelessGameProfile

      @Contract(pure=true) public static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile createNamelessGameProfile(UUID id)