Interface SkullHandler
public interface SkullHandler
Handler interface for setting and getting skull textures.
Different implementations are used based on the Bukkit version:
- NewSkullHandler for 1.18+ with PlayerProfile API
- OldSkullHandler for older versions with GameProfile/reflection
- PaperSkullHandler for servers with PaperMC's PlayerProfile API
Provides methods to set skull textures via various sources: player names, UUIDs, texture URLs, Mojang hashes, or Base64 data.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternPattern for Base64 encoded texture data https://github.com/CryptoMorin/XSeries/blob/b11b176deca55da6d465e67a3d4be548c3ef06c6/src/main/java/com/cryptomorin/xseries/profiles/objects/ProfileInputType.javastatic final PatternPattern for Mojang SHA256 texture hashes https://github.com/CryptoMorin/XSeries/blob/b633d00608435701f1045a566b98a81edd5f923c/src/main/java/com/cryptomorin/xseries/profiles/objects/ProfileInputType.java -
Method Summary
Modifier and TypeMethodDescriptionstatic SkullHandlerGets the instance ofSkullHandler.getSkullValue(org.bukkit.inventory.meta.SkullMeta meta) Retrieves the skull texture value (URL or Base64 data) from SkullMeta.default voidSets skull texture using a string value that can be in multiple formats.voidsetSkullByBase64(org.bukkit.inventory.meta.SkullMeta meta, String base64) Sets skull texture using Base64 encoded texture data.default voidsetSkullByName(org.bukkit.inventory.meta.SkullMeta meta, String name) Sets skull texture using a player name.voidsetSkullByPlayer(org.bukkit.inventory.meta.SkullMeta meta, org.bukkit.OfflinePlayer player) Sets skull texture using an OfflinePlayer.default voidsetSkullByURL(org.bukkit.inventory.meta.SkullMeta meta, String url) Sets skull texture using a URL string.voidsetSkullByURL(org.bukkit.inventory.meta.SkullMeta meta, URL url) Sets skull texture using a URL.default voidsetSkullByUUID(org.bukkit.inventory.meta.SkullMeta meta, UUID uuid) Sets skull texture using a player UUID.
-
Field Details
-
MOJANG_SHA256_APPROX_PATTERN
Pattern for Mojang SHA256 texture hashes https://github.com/CryptoMorin/XSeries/blob/b633d00608435701f1045a566b98a81edd5f923c/src/main/java/com/cryptomorin/xseries/profiles/objects/ProfileInputType.java -
BASE64_PATTERN
Pattern for Base64 encoded texture data https://github.com/CryptoMorin/XSeries/blob/b11b176deca55da6d465e67a3d4be548c3ef06c6/src/main/java/com/cryptomorin/xseries/profiles/objects/ProfileInputType.java
-
-
Method Details
-
getInstance
Gets the instance ofSkullHandler.- Returns:
- the instance
-
setSkullByName
Sets skull texture using a player name. Uses Bukkit's OfflinePlayer lookup mechanism.- Parameters:
meta- the SkullMeta to modifyname- the player name
-
setSkullByUUID
Sets skull texture using a player UUID. Uses Bukkit's OfflinePlayer lookup mechanism.- Parameters:
meta- the SkullMeta to modifyuuid- the player UUID
-
setSkullByPlayer
void setSkullByPlayer(org.bukkit.inventory.meta.SkullMeta meta, org.bukkit.OfflinePlayer player) Sets skull texture using an OfflinePlayer. This is the most direct method.- Parameters:
meta- the SkullMeta to modifyplayer- the OfflinePlayer
-
setSkullByURL
Sets skull texture using a URL. The URL should point to a texture PNG image.- Parameters:
meta- the SkullMeta to modifyurl- the texture URL
-
setSkullByURL
Sets skull texture using a URL string. The URL string is converted to a URL object.- Parameters:
meta- the SkullMeta to modifyurl- the texture URL as a string- Throws:
RuntimeException- if the URL string is invalid
-
setSkullByBase64
Sets skull texture using Base64 encoded texture data. The data should be a Base64-encoded JSON string containing texture information.- Parameters:
meta- the SkullMeta to modifybase64- the Base64-encoded texture data
-
setSkull
Sets skull texture using a string value that can be in multiple formats. Attempts to parse the value in the following order:- As a texture URL
- As a Mojang SHA256 texture hash
- As Base64-encoded texture data
- As a player UUID
- As a player name (default fallback)
- Parameters:
meta- the SkullMeta to modifyvalue- the skull texture value in any of the supported formats
-
getSkullValue
Retrieves the skull texture value (URL or Base64 data) from SkullMeta.- Parameters:
meta- the SkullMeta to query- Returns:
- the skull texture value as a string, or empty if not found
-