Package com.cryptomorin.xseries.profiles
Class PlayerProfiles
java.lang.Object
com.cryptomorin.xseries.profiles.PlayerProfiles
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic 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.static final StringIn v1.20.2 there were some changes to the Mojang API. -
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 @Nullable StringdecodeBase64(String base64) Tries to decode the string as a Base64 value.static StringencodeBase64(String str) Encodes the provided string into Base64 format.static @Nullable StringgetOriginalValue(@Nullable com.mojang.authlib.GameProfile profile) static @NotNull StringgetPropertyValue(@NotNull com.mojang.authlib.properties.Property property) Retrieves the value of aProperty, handling differences between versions.static Optional<com.mojang.authlib.properties.Property> getTextureProperty(com.mojang.authlib.GameProfile profile) static @Nullable StringgetTextureValue(@NotNull com.mojang.authlib.GameProfile profile) Retrieves the skin value from the givenGameProfile.static booleanhasTextures(com.mojang.authlib.GameProfile profile) Checks if the providedGameProfilehas a texture property.static @NotNull 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.static @Nullable com.mojang.authlib.GameProfileunwrapProfile(@Nullable Object profile) Tries to unwrap aGameProfilefrom aResolvableProfile.static @Nullable ObjectwrapProfile(@Nullable com.mojang.authlib.GameProfile profile)
-
Field Details
-
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 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) -
getTextureValue
@Nullable public static @Nullable String getTextureValue(@NotNull @NotNull com.mojang.authlib.GameProfile profile) 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.- 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 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.- See Also:
-
profileFromHashAndBase64
@NotNull public static @NotNull 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) -
unwrapProfile
@Nullable public static @Nullable com.mojang.authlib.GameProfile unwrapProfile(@Nullable @Nullable Object profile) throws Throwable Tries to unwrap aGameProfilefrom aResolvableProfile.- 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 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
-