Class XSkull
Some websites to get custom heads:
Usage
The basic usage format of this API is as follows:
XSkull.createItem().profile(Profileable.of(player)).apply();
XSkull.of(item/block).profile(Profileable.of(configStringValue)).apply();
Note: Make sure to read ProfileInstruction.applyAsync() if you're going to
be requesting heads in the main thread.
This API replaces SkullMeta and Skull which doesn't properly handle skulls
in edge cases just like any other system that relies on the default Mojang handlers.
It also specifically supports offline servers too.
Mechanism
The basic premise behind this API is that the final skull data is contained in a GameProfile
either by ID, name or encoded textures URL property.
Different versions of Minecraft client handle this differently. In newer versions the client seem to prioritize the texture property over the set UUID and name, in older versions however using the same UUID for all GameProfiles caused all skulls (that use base64) to look the same. The client is responsible for caching skull textures. If the download were to fail (either because of connection issues or invalid values) the client will cache that skull UUID and the skull will remain as a steve head until the client is completely restarted. I don't know if this cache system works across other servers or is just specific to one server.
- Version:
- 12.0.0
- Author:
- Crypto Morin, Erick Alexander
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ProfileInstruction<org.bukkit.inventory.ItemStack> Creates aProfileInstructionfor anItemStack.protected static @NotNull ProfileableThe defaultGameProfileused byProfileInstructionas a last resort when none of the fallback values could be retrieved.static @NotNull ProfileInstruction<org.bukkit.block.Block> of(@NotNull org.bukkit.block.Block block) Creates aProfileInstructionfor aBlock.static @NotNull ProfileInstruction<org.bukkit.block.Skull> of(@NotNull org.bukkit.block.BlockState state) Creates aProfileInstructionfor aBlockState.static @NotNull ProfileInstruction<org.bukkit.inventory.ItemStack> of(@NotNull org.bukkit.inventory.ItemStack stack) Creates aProfileInstructionfor anItemStack.static @NotNull ProfileInstruction<org.bukkit.inventory.meta.ItemMeta> of(@NotNull org.bukkit.inventory.meta.ItemMeta meta) Creates aProfileInstructionfor anItemMeta.
-
Constructor Details
-
XSkull
public XSkull()
-
-
Method Details
-
createItem
@NotNull @Contract(value="-> new", pure=true) public static @NotNull ProfileInstruction<org.bukkit.inventory.ItemStack> createItem()Creates aProfileInstructionfor anItemStack. This method initializes a new player head.- Returns:
- A
ProfileInstructionthat sets the profile for the generatedItemStack.
-
of
@NotNull @Contract(value="_ -> new", pure=true) public static @NotNull ProfileInstruction<org.bukkit.inventory.ItemStack> of(@NotNull @NotNull org.bukkit.inventory.ItemStack stack) Creates aProfileInstructionfor anItemStack.- Parameters:
stack- TheItemStackto set the profile for.- Returns:
- A
ProfileInstructionthat sets the profile for the givenItemStack.
-
of
@NotNull @Contract(value="_ -> new", pure=true) public static @NotNull ProfileInstruction<org.bukkit.inventory.meta.ItemMeta> of(@NotNull @NotNull org.bukkit.inventory.meta.ItemMeta meta) Creates aProfileInstructionfor anItemMeta.- Parameters:
meta- TheItemMetato set the profile for.- Returns:
- An
ProfileInstructionthat sets the profile for the givenItemMeta.
-
of
@NotNull @Contract(value="_ -> new", pure=true) public static @NotNull ProfileInstruction<org.bukkit.block.Block> of(@NotNull @NotNull org.bukkit.block.Block block) Creates aProfileInstructionfor aBlock.- Parameters:
block- TheBlockto set the profile for.- Returns:
- An
ProfileInstructionthat sets the profile for the givenBlock.
-
of
@NotNull @Contract(value="_ -> new", pure=true) public static @NotNull ProfileInstruction<org.bukkit.block.Skull> of(@NotNull @NotNull org.bukkit.block.BlockState state) Creates aProfileInstructionfor aBlockState.- Parameters:
state- TheBlockStateto set the profile for.- Returns:
- An
ProfileInstructionthat sets the profile for the givenBlockState.
-
getDefaultProfile
@NotNull @Contract(value="-> new", pure=true) protected static @NotNull Profileable getDefaultProfile()The defaultGameProfileused byProfileInstructionas a last resort when none of the fallback values could be retrieved. This profile represents a red prohibition sign on a silver head. This method creates a clone of the default profile to prevent modifications to the original.- Returns:
- A clone of the default
Profileable.
-