Search in sources :

Example 6 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project MagicPlugin by elBukkit.

the class ShrinkEntityAction method dropHead.

@SuppressWarnings("deprecation")
protected void dropHead(Location location, String ownerName, String itemName, byte data) {
    ItemStack shrunkenHead = new ItemStack(Material.SKULL_ITEM, 1, (short) 0, data);
    ItemMeta meta = shrunkenHead.getItemMeta();
    if (itemName != null) {
        meta.setDisplayName(itemName);
    }
    if (meta instanceof SkullMeta && ownerName != null) {
        SkullMeta skullData = (SkullMeta) meta;
        skullData.setOwner(ownerName);
    }
    shrunkenHead.setItemMeta(meta);
    location.getWorld().dropItemNaturally(location, shrunkenHead);
}
Also used : SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 7 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project FireAPI by FireBlade-Serv.

the class EventsAT method generateSkull.

public static ItemStack generateSkull(String owner) {
    ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
    skullMeta.setOwner(owner);
    skullMeta.setDisplayName("§d" + owner);
    skull.setItemMeta(skullMeta);
    return skull;
}
Also used : SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack)

Example 8 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project FireAPI by FireBlade-Serv.

the class FriendsActionInventoryGUI method formHead.

public ItemStack formHead(String owner) {
    ItemStack i = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
    SkullMeta m = (SkullMeta) i.getItemMeta();
    m.setDisplayName((this.connected.contains(owner)) ? "§2" + owner : "§8" + owner);
    m.setLore((this.connected.contains(owner) ? Arrays.asList("§a§oConnecté") : Arrays.asList("§c§oDéconnecté")));
    m.setOwner(owner);
    i.setItemMeta(m);
    return i;
}
Also used : SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack)

Example 9 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project Citizens2 by CitizensDev.

the class EventListen method onMetaDeserialise.

@EventHandler
public void onMetaDeserialise(CitizensDeserialiseMetaEvent event) {
    if (event.getKey().keyExists("skull")) {
        String owner = event.getKey().getString("skull.owner", "");
        UUID uuid = event.getKey().keyExists("skull.uuid") ? UUID.fromString(event.getKey().getString("skull.uuid")) : null;
        if (owner.isEmpty() && uuid == null) {
            return;
        }
        GameProfile profile = new GameProfile(uuid, owner);
        for (DataKey sub : event.getKey().getRelative("skull.properties").getSubKeys()) {
            String propertyName = sub.name();
            for (DataKey property : sub.getIntegerSubKeys()) {
                profile.getProperties().put(propertyName, new Property(property.getString("name"), property.getString("value"), property.keyExists("signature") ? property.getString("signature") : null));
            }
        }
        SkullMeta meta = (SkullMeta) Bukkit.getItemFactory().getItemMeta(Material.SKULL_ITEM);
        NMS.setProfile(meta, profile);
        event.getItemStack().setItemMeta(meta);
    }
}
Also used : GameProfile(com.mojang.authlib.GameProfile) DataKey(net.citizensnpcs.api.util.DataKey) SkullMeta(org.bukkit.inventory.meta.SkullMeta) UUID(java.util.UUID) Property(com.mojang.authlib.properties.Property) EventHandler(org.bukkit.event.EventHandler)

Example 10 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project Citizens2 by CitizensDev.

the class EventListen method onMetaSerialise.

@EventHandler
public void onMetaSerialise(CitizensSerialiseMetaEvent event) {
    if (!(event.getMeta() instanceof SkullMeta))
        return;
    SkullMeta meta = (SkullMeta) event.getMeta();
    GameProfile profile = NMS.getProfile(meta);
    if (profile == null)
        return;
    if (profile.getName() != null) {
        event.getKey().setString("skull.owner", profile.getName());
    }
    if (profile.getId() != null) {
        event.getKey().setString("skull.uuid", profile.getId().toString());
    }
    if (profile.getProperties() != null) {
        for (Entry<String, Collection<Property>> entry : profile.getProperties().asMap().entrySet()) {
            DataKey relative = event.getKey().getRelative("skull.properties." + entry.getKey());
            int i = 0;
            for (Property value : entry.getValue()) {
                relative.getRelative(i).setString("name", value.getName());
                if (value.getSignature() != null) {
                    relative.getRelative(i).setString("signature", value.getSignature());
                }
                relative.getRelative(i).setString("value", value.getValue());
                i++;
            }
        }
    }
}
Also used : GameProfile(com.mojang.authlib.GameProfile) DataKey(net.citizensnpcs.api.util.DataKey) Collection(java.util.Collection) SkullMeta(org.bukkit.inventory.meta.SkullMeta) Property(com.mojang.authlib.properties.Property) EventHandler(org.bukkit.event.EventHandler)

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