Search in sources :

Example 1 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project EliteMobs by MagmaGuy.

the class LootGUI method lootNavigationConstructor.

private void lootNavigationConstructor(Inventory inventory) {
    ItemStack arrowLeft = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    SkullMeta arrowLeftSkullMeta = (SkullMeta) arrowLeft.getItemMeta();
    arrowLeftSkullMeta.setOwner("MHF_ArrowLeft");
    arrowLeftSkullMeta.setDisplayName("Previous Loot Page");
    arrowLeft.setItemMeta(arrowLeftSkullMeta);
    inventory.setItem(27, arrowLeft);
    ItemStack arrowRight = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    SkullMeta arrowRightSkullMeta = (SkullMeta) arrowRight.getItemMeta();
    arrowRightSkullMeta.setOwner("MHF_ArrowRight");
    arrowRightSkullMeta.setDisplayName("Next Loot Page");
    arrowRight.setItemMeta(arrowRightSkullMeta);
    inventory.setItem(35, arrowRight);
}
Also used : SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack)

Example 2 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project acidisland by tastybento.

the class TopTen method getSkull.

static ItemStack getSkull(int rank, Long long1, UUID player) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: Getting the skull");
    String playerName = plugin.getPlayers().getName(player);
    if (DEBUG) {
        plugin.getLogger().info("DEBUG: playername = " + playerName);
        plugin.getLogger().info("DEBUG: second chance = " + plugin.getPlayers().getName(player));
    }
    ItemStack playerSkull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    if (playerName == null)
        return null;
    SkullMeta meta = (SkullMeta) playerSkull.getItemMeta();
    if (topTenHeads.containsKey(player)) {
        playerSkull = topTenHeads.get(player);
        meta = (SkullMeta) playerSkull.getItemMeta();
    }
    meta.setDisplayName((plugin.myLocale(player).topTenGuiHeading.replace("[name]", plugin.getGrid().getIslandName(player))).replace("[rank]", String.valueOf(rank)));
    // meta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + "<!> " + ChatColor.YELLOW + "Island: " + ChatColor.GOLD + ChatColor.UNDERLINE + plugin.getGrid().getIslandName(player) + ChatColor.GRAY + " (#" + rank + ")");
    List<String> lore = new ArrayList<String>();
    lore.add(ChatColor.YELLOW + plugin.myLocale(player).levelislandLevel + " " + long1);
    if (plugin.getPlayers().inTeam(player)) {
        final List<UUID> pMembers = plugin.getPlayers().getMembers(player);
        // Need to make this a vertical list, because some teams are very large and it'll go off the screen otherwise
        List<String> memberList = new ArrayList<>();
        for (UUID members : pMembers) {
            memberList.add(ChatColor.AQUA + plugin.getPlayers().getName(members));
        }
        lore.addAll(memberList);
    }
    meta.setLore(lore);
    playerSkull.setItemMeta(meta);
    return playerSkull;
}
Also used : ArrayList(java.util.ArrayList) SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack) UUID(java.util.UUID)

Example 3 with SkullMeta

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

the class MagicController method getSkull.

@Override
@Nonnull
public ItemStack getSkull(Entity entity, String itemName) {
    byte data = 3;
    String ownerName = null;
    switch(entity.getType()) {
        case CREEPER:
            data = 4;
            break;
        case ZOMBIE:
            data = 2;
            break;
        case SKELETON:
            Skeleton skeleton = (Skeleton) entity;
            data = (byte) (skeleton.getSkeletonType() == Skeleton.SkeletonType.NORMAL ? 0 : 1);
            break;
        case PLAYER:
            ownerName = entity.getName();
            break;
        default:
            ownerName = getMobSkin(entity.getType());
    }
    ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 0, data);
    ItemMeta meta = skull.getItemMeta();
    if (itemName != null) {
        meta.setDisplayName(itemName);
    }
    if (meta instanceof SkullMeta && ownerName != null) {
        SkullMeta skullData = (SkullMeta) meta;
        skullData.setOwner(ownerName);
    }
    skull.setItemMeta(meta);
    return skull;
}
Also used : Skeleton(org.bukkit.entity.Skeleton) SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Nonnull(javax.annotation.Nonnull)

Example 4 with SkullMeta

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

the class PlayerSelectAction method start.

@Override
public SpellResult start(CastContext context) {
    Mage mage = context.getMage();
    MageController controller = context.getController();
    Player player = mage.getPlayer();
    if (player == null) {
        return SpellResult.PLAYER_REQUIRED;
    }
    List<Player> allPlayers = null;
    players.clear();
    if (allowCrossWorld) {
        allPlayers = new ArrayList<>(controller.getPlugin().getServer().getOnlinePlayers());
    } else {
        allPlayers = context.getLocation().getWorld().getPlayers();
    }
    Collections.sort(allPlayers, new Comparator<Player>() {

        @Override
        public int compare(Player p1, Player p2) {
            return p1.getDisplayName().compareTo(p2.getDisplayName());
        }
    });
    int index = 0;
    for (Player targetPlayer : allPlayers) {
        if (!context.getTargetsCaster() && targetPlayer == player)
            continue;
        if (targetPlayer.hasPotionEffect(PotionEffectType.INVISIBILITY))
            continue;
        if (!context.canTarget(targetPlayer))
            continue;
        players.put(index++, new WeakReference<>(targetPlayer));
    }
    if (players.size() == 0)
        return SpellResult.NO_TARGET;
    String inventoryTitle = context.getMessage("title", "Select Player");
    int invSize = ((players.size() + 9) / 9) * 9;
    Inventory displayInventory = CompatibilityUtils.createInventory(null, invSize, inventoryTitle);
    for (Map.Entry<Integer, WeakReference<Player>> entry : players.entrySet()) {
        Player targetPlayer = entry.getValue().get();
        if (targetPlayer == null)
            continue;
        String name = targetPlayer.getName();
        String displayName = targetPlayer.getDisplayName();
        @SuppressWarnings("deprecation") ItemStack playerItem = new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 3);
        ItemMeta meta = playerItem.getItemMeta();
        meta.setDisplayName(displayName);
        if (meta instanceof SkullMeta) {
            SkullMeta skullData = (SkullMeta) meta;
            skullData.setOwner(name);
        }
        if (!name.equals(displayName)) {
            List<String> lore = new ArrayList<>();
            lore.add(name);
            meta.setLore(lore);
        }
        playerItem.setItemMeta(meta);
        displayInventory.setItem(entry.getKey(), playerItem);
    }
    active = true;
    mage.activateGUI(this, displayInventory);
    return SpellResult.NO_ACTION;
}
Also used : Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) SkullMeta(org.bukkit.inventory.meta.SkullMeta) MageController(com.elmakers.mine.bukkit.api.magic.MageController) Mage(com.elmakers.mine.bukkit.api.magic.Mage) WeakReference(java.lang.ref.WeakReference) ItemStack(org.bukkit.inventory.ItemStack) HashMap(java.util.HashMap) Map(java.util.Map) Inventory(org.bukkit.inventory.Inventory) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 5 with SkullMeta

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

the class ShrinkBlockAction 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)

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