Package com.cryptomorin.xseries.profiles
Class PlayerProfiles
java.lang.Object
com.cryptomorin.xseries.profiles.PlayerProfiles
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringIn v1.20.2 there were some changes to the Mojang API.static final com.mojang.authlib.GameProfilestatic final StringThe value after this URL is probably an SHA-252 value that Mojang uses to unique identify player skins.static final StringSome people use this without quotes surrounding the keys, not sure if that'd work. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.mojang.authlib.GameProfileclone(com.mojang.authlib.GameProfile gameProfile) static com.mojang.authlib.GameProfilecreateGameProfile(UUID uuid, String username) static com.mojang.authlib.GameProfilestatic StringdecodeBase64(String base64) Tries to decode the string as a Base64 value.static StringencodeBase64(String str) Encodes the provided string into Base64 format.static StringgetPropertyValue(com.mojang.authlib.properties.Property property) Retrieves the value of aProperty, handling differences between versions.static StringgetSkinValue(com.mojang.authlib.GameProfile profile) Retrieves the skin value from the givenGameProfile.static Optional<com.mojang.authlib.properties.Property> getTextureProperty(com.mojang.authlib.GameProfile profile) static booleanhasTextures(com.mojang.authlib.GameProfile profile) Checks if the providedGameProfilehas a texture property.static com.mojang.authlib.GameProfileprofileFromHashAndBase64(String hash, String base64) Constructs aGameProfileusing the provided texture hash and base64 string.static voidremoveTimestamp(com.mojang.authlib.GameProfile profile) static com.mojang.authlib.GameProfilesanitizeProfile(com.mojang.authlib.GameProfile profile) Uses the online/offline UUID depending onBukkit.getOnlineMode().static voidsetTexturesProperty(com.mojang.authlib.GameProfile profile, String texture) static com.mojang.authlib.GameProfilesignXSeries(com.mojang.authlib.GameProfile profile) AllGameProfilecreated/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.
-
Field Details
-
DEFAULT_PROFILE_NAME
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 blankHere, "blank" is null for UUID, andCharacter.isWhitespacefor the name field.- See Also:
-
NIL
public static final com.mojang.authlib.GameProfile NIL -
TEXTURES_NBT_PROPERTY_PREFIX
Some people use this without quotes surrounding the keys, not sure if that'd work.- See Also:
-
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
MojangAPIUUID_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) -
getSkinValue
Retrieves the skin value from the givenGameProfile.- Parameters:
profile- TheGameProfileto retrieve the skin value from.- Returns:
- The skin value as a
String, ornullif not found. - Throws:
NullPointerException- ifprofileisnull.
-
getPropertyValue
Retrieves the value of aProperty, handling differences between versions.- Since:
- 4.0.1
-
hasTextures
public static boolean hasTextures(com.mojang.authlib.GameProfile profile) Checks if the providedGameProfilehas a texture property.- Parameters:
profile- TheGameProfileto check.- Returns:
trueif the profile has a texture property,falseotherwise.
-
profileFromHashAndBase64
@Nonnull public static com.mojang.authlib.GameProfile profileFromHashAndBase64(String hash, String base64) Constructs aGameProfileusing 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) -
sanitizeProfile
public static com.mojang.authlib.GameProfile sanitizeProfile(com.mojang.authlib.GameProfile profile) Uses the online/offline UUID depending onBukkit.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
-
encodeBase64
Encodes the provided string into Base64 format.- Parameters:
str- The string to encode.- Returns:
- The Base64 encoded string.
-
decodeBase64
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
-
signXSeries
public static com.mojang.authlib.GameProfile signXSeries(com.mojang.authlib.GameProfile profile) AllGameProfilecreated/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
-