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.cryptomorin.xseries.profiles.gameprofile.MojangGameProfilecreateGameProfile(UUID uuid, String username) static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfilecreateGameProfile(UUID uuid, String username, com.mojang.authlib.properties.PropertyMap properties) static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfilestatic @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 com.mojang.authlib.GameProfilefromResolvableProfile(@Nullable Object profile) Tries to unwrap aGameProfilefrom aResolvableProfile.static @Nullable StringgetOriginalValue(@Nullable com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile 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.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile) static @Nullable StringgetTextureValue(@NotNull com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile) Retrieves the skin value from the givenGameProfile.static booleanhasTextures(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile) Checks if the providedGameProfilehas a texture property.static @NotNull com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfileprofileFromHashAndBase64(String hash, String base64) Constructs aGameProfileusing the provided texture hash and base64 string.static voidremoveTimestamp(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile) static com.mojang.authlib.GameProfilesanitizeProfile(com.mojang.authlib.GameProfile gameProfile) Uses the online/offline UUID depending onBukkit.getOnlineMode().static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfilesetTexturesProperty(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile profile, String texture) static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfilesignXSeries(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile 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 ObjecttoResolvableProfile(@Nullable com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile 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.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 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.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 aProperty, handling differences between versions.- Since:
- 4.0.1
-
hasTextures
public static boolean hasTextures(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile 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.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile 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.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 aGameProfilefrom aResolvableProfile.- 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 onBukkit.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
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
-
createGameProfile
-
signXSeries
@Contract(pure=true) public static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile signXSeries(com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile 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
@Contract(pure=true) public static com.cryptomorin.xseries.profiles.gameprofile.MojangGameProfile createNamelessGameProfile(UUID id)
-