Java Code Examples for org.bukkit.inventory.meta.SkullMeta#setOwningPlayer()

The following examples show how to use org.bukkit.inventory.meta.SkullMeta#setOwningPlayer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SkullUtils.java    From XSeries with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Nonnull
public static SkullMeta applySkin(@Nonnull ItemMeta head, @Nonnull String player) {
    boolean isId = isUUID(getFullUUID(player));
    SkullMeta meta = (SkullMeta) head;

    if (isId || isUsername(player)) {
        if (isId) return getSkullByValue(meta, getSkinValue(player, true));
        if (XMaterial.isNewVersion()) meta.setOwningPlayer(Bukkit.getOfflinePlayer(player));
        else meta.setOwner(player);
    }

    if (player.contains("textures.minecraft.net")) return getValueFromTextures(meta, player);
    if (player.length() > 100 && isBase64(player)) return getSkullByValue(meta, player);
    return getTexturesFromUrlValue(meta, player);
}
 
Example 2
Source File: ItemService.java    From Transport-Pipes with MIT License 6 votes vote down vote up
public ItemStack createHeadItem(String uuid, String textureValue, String textureSignature) {
    WrappedGameProfile wrappedProfile = new WrappedGameProfile(UUID.fromString(uuid), null);
    wrappedProfile.getProperties().put("textures", new WrappedSignedProperty("textures", textureValue, textureSignature));

    ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
    SkullMeta sm = (SkullMeta) skull.getItemMeta();
    sm.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(uuid)));

    Field profileField;
    try {
        profileField = sm.getClass().getDeclaredField("profile");
        profileField.setAccessible(true);
        profileField.set(sm, wrappedProfile.getHandle());
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
        e1.printStackTrace();
    }

    skull.setItemMeta(sm);
    return skull;
}
 
Example 3
Source File: SkullUtils.java    From XSeries with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Nonnull
public static ItemStack getSkull(@Nonnull UUID id) {
    ItemStack head = XMaterial.PLAYER_HEAD.parseItem();
    SkullMeta meta = (SkullMeta) head.getItemMeta();

    if (XMaterial.isNewVersion()) meta.setOwningPlayer(Bukkit.getOfflinePlayer(id));
    else meta.setOwner(id.toString());

    head.setItemMeta(meta);
    return head;
}
 
Example 4
Source File: VersionUtils_1_13.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack createPlayerSkull(String name, UUID uuid) {
    ItemStack item = UniversalMaterial.PLAYER_HEAD.getStack();
    SkullMeta im = (SkullMeta) item.getItemMeta();
    im.setOwningPlayer(Bukkit.getOfflinePlayer(uuid));
    item.setItemMeta(im);
    return item;
}
 
Example 5
Source File: ExprSkull.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
@Nullable
public ItemType convert(final Object o) {
	ItemType skull = playerSkull.clone();
	SkullMeta meta = (SkullMeta) skull.getItemMeta();
	if (newSkullOwner)
		meta.setOwningPlayer((OfflinePlayer) o);
	else
		meta.setOwner(((OfflinePlayer) o).getName());
	skull.setItemMeta(meta);
	return skull;
}
 
Example 6
Source File: SkullCreator.java    From Crazy-Crates with MIT License 5 votes vote down vote up
/**
 * Creates a player skull based on a UUID. 1.13 only.
 *
 * @param item The item to apply the name to
 * @param id The Player's UUID
 * @return The head of the Player
 */
public static ItemStack itemWithUuid(ItemStack item, UUID id) {
    notNull(item, "item");
    notNull(id, "id");
    
    SkullMeta meta = (SkullMeta) item.getItemMeta();
    meta.setOwningPlayer(Bukkit.getOfflinePlayer(id));
    item.setItemMeta(meta);
    
    return item;
}
 
Example 7
Source File: SkullItem.java    From CS-CoreLib with GNU General Public License v3.0 5 votes vote down vote up
public SkullItem(OfflinePlayer player) {
	super(new ItemStack(MaterialHook.parse("PLAYER_HEAD", "SKULL_ITEM")));
	this.owner = player.getName();
	SkullMeta meta = (SkullMeta) getItemMeta();
	meta.setOwningPlayer(player);
	setItemMeta(meta);
}
 
Example 8
Source File: ItemFactory.java    From TradePlus with GNU General Public License v3.0 5 votes vote down vote up
static ItemStack getPlayerSkull(Player player, String displayName) {
  ItemStack skull = UMaterial.PLAYER_HEAD_ITEM.getItemStack();
  Preconditions.checkNotNull(skull, "Failed to load skull.");
  if (Sounds.version < 113) skull.getData().setData((byte) 3);
  SkullMeta meta = (SkullMeta) skull.getItemMeta();
  meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayName));
  if (Sounds.version >= 112) meta.setOwningPlayer(player);
  else meta.setOwner(player.getName());
  skull.setItemMeta(meta);
  return skull;
}
 
Example 9
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
public void updateSkull(SkullMeta meta1, Player player) {
	meta1.setOwningPlayer(player);
}