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.mojang.authlib.GameProfile
    clone(com.mojang.authlib.GameProfile gameProfile)
     
    static com.mojang.authlib.GameProfile
    createGameProfile(UUID uuid, String username)
     
    static com.mojang.authlib.GameProfile
     
    static @Nullable String
    Tries to decode the string as a Base64 value.
    static String
    Encodes the provided string into Base64 format.
    static @Nullable String
    getOriginalValue(@Nullable com.mojang.authlib.GameProfile 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.mojang.authlib.GameProfile profile)
     
    static @Nullable String
    getTextureValue(@NotNull com.mojang.authlib.GameProfile profile)
    Retrieves the skin value from the given GameProfile.
    static boolean
    hasTextures(com.mojang.authlib.GameProfile profile)
    Checks if the provided GameProfile has a texture property.
    static @NotNull com.mojang.authlib.GameProfile
    Constructs a GameProfile using the provided texture hash and base64 string.
    static void
    removeTimestamp(com.mojang.authlib.GameProfile profile)
     
    static com.mojang.authlib.GameProfile
    sanitizeProfile(com.mojang.authlib.GameProfile profile)
    Uses the online/offline UUID depending on Bukkit.getOnlineMode().
    static void
    setTexturesProperty(com.mojang.authlib.GameProfile profile, String texture)
     
    static com.mojang.authlib.GameProfile
    signXSeries(com.mojang.authlib.GameProfile 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 com.mojang.authlib.GameProfile
    unwrapProfile(@Nullable Object profile)
    Tries to unwrap a GameProfile from a ResolvableProfile.
    static @Nullable Object
    wrapProfile(@Nullable com.mojang.authlib.GameProfile 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.mojang.authlib.GameProfile profile)
    • getTextureValue

      @Nullable public static @Nullable String getTextureValue(@NotNull @NotNull com.mojang.authlib.GameProfile 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.mojang.authlib.GameProfile 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.mojang.authlib.GameProfile 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.mojang.authlib.GameProfile 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.mojang.authlib.GameProfile profile)
    • unwrapProfile

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

      @Nullable public static @Nullable Object wrapProfile(@Nullable @Nullable com.mojang.authlib.GameProfile profile) throws Throwable
      Throws:
      Throwable
    • sanitizeProfile

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

      public static com.mojang.authlib.GameProfile clone(com.mojang.authlib.GameProfile gameProfile)
    • setTexturesProperty

      public static void setTexturesProperty(com.mojang.authlib.GameProfile profile, String texture)
    • encodeBase64

      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 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

      public static com.mojang.authlib.GameProfile createGameProfile(UUID uuid, String username)
    • signXSeries

      public static com.mojang.authlib.GameProfile signXSeries(com.mojang.authlib.GameProfile 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

      public static com.mojang.authlib.GameProfile createNamelessGameProfile(UUID id)