Search in sources :

Example 31 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project Essentials by drtshock.

the class Commandskull method run.

@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
    String owner;
    if (args.length > 0 && user.isAuthorized("essentials.skull.others")) {
        if (!args[0].matches("^[A-Za-z0-9_]+$")) {
            throw new IllegalArgumentException(tl("alphaNames"));
        }
        owner = args[0];
    } else {
        owner = user.getName();
    }
    ItemStack itemSkull = user.getBase().getItemInHand();
    SkullMeta metaSkull = null;
    boolean spawn = false;
    if (itemSkull != null && itemSkull.getType() == Material.SKULL_ITEM && itemSkull.getDurability() == 3) {
        metaSkull = (SkullMeta) itemSkull.getItemMeta();
    } else if (user.isAuthorized("essentials.skull.spawn")) {
        itemSkull = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
        metaSkull = (SkullMeta) itemSkull.getItemMeta();
        spawn = true;
    } else {
        throw new Exception(tl("invalidSkull"));
    }
    if (metaSkull.hasOwner() && !user.isAuthorized("essentials.skull.modify")) {
        throw new Exception(tl("noPermissionSkull"));
    }
    metaSkull.setDisplayName("§fSkull of " + owner);
    metaSkull.setOwner(owner);
    itemSkull.setItemMeta(metaSkull);
    if (spawn) {
        InventoryWorkaround.addItems(user.getBase().getInventory(), itemSkull);
        user.sendMessage(tl("givenSkull", owner));
    } else {
        user.sendMessage(tl("skullChanged", owner));
    }
}
Also used : SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack)

Example 32 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project PixelsSkyblock by dudullle.

the class Inventories method run_PlayersInventory_invite.

public static void run_PlayersInventory_invite(InventoryClickEvent event) {
    try {
        Player pl = (Player) event.getWhoClicked();
        SkullMeta skull = (SkullMeta) event.getInventory().getItem(event.getSlot()).getItemMeta();
        Player cible = Bukkit.getPlayer(skull.getOwner());
        SPlayer p_sender = PlayersManager.getSPlayer(pl);
        SPlayer p_cible = PlayersManager.getSPlayer(cible);
        p_cible.setLastIsInvite(p_sender.getIsland().getID());
        cible.sendTitle("§a" + pl.getDisplayName() + " vous veut sur son île!", "§eFaites /is accept pour accepter !", 10, 20, 10);
    } catch (Exception ex) {
    }
}
Also used : Player(org.bukkit.entity.Player) SPlayer(pixelssky.objects.SPlayer) SkullMeta(org.bukkit.inventory.meta.SkullMeta) SPlayer(pixelssky.objects.SPlayer)

Example 33 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project PixelsSkyblock by dudullle.

the class Items method getHead.

public static ItemStack getHead(Player player) {
    ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    SkullMeta skull = (SkullMeta) item.getItemMeta();
    skull.setDisplayName(player.getName());
    skull.setOwner(player.getName());
    item.setItemMeta(skull);
    return item;
}
Also used : SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack)

Example 34 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project PixelsSkyblock by dudullle.

the class Items method getHead.

public static ItemStack getHead(String pName, String itemName) {
    ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    SkullMeta skull = (SkullMeta) item.getItemMeta();
    skull.setDisplayName(itemName);
    skull.setOwner(pName);
    item.setItemMeta(skull);
    return item;
}
Also used : SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack)

Example 35 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project SkinsRestorerX by DoNotSpamPls.

the class SkinsGUI method createSkull.

private static ItemStack createSkull(Object s, String name) {
    ItemStack is = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    SkullMeta sm = (SkullMeta) is.getItemMeta();
    List<String> lore = new ArrayList<>();
    lore.add(Locale.SELECT_SKIN);
    sm.setDisplayName(name);
    sm.setLore(lore);
    is.setItemMeta(sm);
    is = setSkin(is, ((Property) s).getValue());
    return is;
}
Also used : SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack) Property(com.mojang.authlib.properties.Property)

Aggregations

SkullMeta (org.bukkit.inventory.meta.SkullMeta)59 ItemStack (org.bukkit.inventory.ItemStack)43 ItemMeta (org.bukkit.inventory.meta.ItemMeta)22 Enchantment (org.bukkit.enchantments.Enchantment)10 LeatherArmorMeta (org.bukkit.inventory.meta.LeatherArmorMeta)10 ArrayList (java.util.ArrayList)9 PotionMeta (org.bukkit.inventory.meta.PotionMeta)9 UUID (java.util.UUID)8 Player (org.bukkit.entity.Player)8 BookMeta (org.bukkit.inventory.meta.BookMeta)7 EnchantmentStorageMeta (org.bukkit.inventory.meta.EnchantmentStorageMeta)7 Entry (java.util.Map.Entry)6 FireworkEffectMeta (org.bukkit.inventory.meta.FireworkEffectMeta)5 PotionEffect (org.bukkit.potion.PotionEffect)5 HashMap (java.util.HashMap)4 List (java.util.List)4 Pattern (org.bukkit.block.banner.Pattern)4 Inventory (org.bukkit.inventory.Inventory)4 BannerMeta (org.bukkit.inventory.meta.BannerMeta)4 Property (com.mojang.authlib.properties.Property)3