Search in sources :

Example 16 with SkullMeta

use of org.bukkit.inventory.meta.SkullMeta in project Village_Defense by Plajer.

the class TeleporterKit method openAndCreateTeleportationMenu.

private void openAndCreateTeleportationMenu(World world, Player p) {
    Arena arena = ArenaRegistry.getArena(p);
    Inventory inventory = plugin.getServer().createInventory(null, 18, ChatManager.colorMessage("Kits.Teleporter.Game-Item-Menu-Name"));
    for (Player player : world.getPlayers()) {
        if (ArenaRegistry.getArena(player) != null && !UserManager.getUser(player.getUniqueId()).isFakeDead()) {
            ItemStack skull = new ItemStack(397, 1, (short) 3);
            SkullMeta meta = (SkullMeta) skull.getItemMeta();
            meta.setOwner(player.getName());
            meta.setDisplayName(player.getName());
            meta.setLore(Collections.singletonList(""));
            skull.setItemMeta(meta);
            inventory.addItem(skull);
        }
    }
    for (Villager villager : arena.getVillagers()) {
        ItemStack villagerItem = new ItemStack(Material.EMERALD);
        this.setItemNameAndLore(villagerItem, villager.getCustomName(), new String[] { villager.getUniqueId().toString() });
        inventory.addItem(villagerItem);
    }
    p.openInventory(inventory);
}
Also used : Player(org.bukkit.entity.Player) Villager(org.bukkit.entity.Villager) SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack) Arena(pl.plajer.villagedefense3.arena.Arena) Inventory(org.bukkit.inventory.Inventory)

Example 17 with SkullMeta

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

the class HeadGetter method runPlayerHeadGetter.

@SuppressWarnings("deprecation")
private void runPlayerHeadGetter() {
    plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> {
        synchronized (names) {
            Iterator<Entry<UUID, String>> it = names.entrySet().iterator();
            if (it.hasNext()) {
                Entry<UUID, String> en = it.next();
                // Bukkit.getLogger().info("DEBUG: getting " + en.getValue());
                ItemStack playerSkull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
                SkullMeta meta = (SkullMeta) playerSkull.getItemMeta();
                meta.setOwner(en.getValue());
                meta.setDisplayName(ChatColor.WHITE + en.getValue());
                playerSkull.setItemMeta(meta);
                // Bukkit.getLogger().info("DEBUG: Got it!");
                // Save in cache
                cachedHeads.put(en.getKey(), new HeadInfo(en.getValue(), en.getKey(), playerSkull));
                // Tell requesters the head came in
                if (headRequesters.containsKey(en.getKey())) {
                    for (Requester req : headRequesters.get(en.getKey())) {
                        // Bukkit.getLogger().info("DEBUG: Telling requester");
                        plugin.getServer().getScheduler().runTask(plugin, () -> req.setHead(new HeadInfo(en.getValue(), en.getKey(), playerSkull)));
                    }
                }
                it.remove();
            }
        }
    }, 0L, 20L);
}
Also used : Entry(java.util.Map.Entry) SkullMeta(org.bukkit.inventory.meta.SkullMeta) UUID(java.util.UUID) ItemStack(org.bukkit.inventory.ItemStack)

Example 18 with SkullMeta

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

the class WarpPanel method addWarp.

/**
 * Adds a new warp
 * @param playerUUID - the player's UUID
 */
public void addWarp(UUID playerUUID) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: Adding warp");
    // Check cached warps
    if (cachedWarps.containsKey(playerUUID)) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Found in cache");
        // Get the item
        ItemStack playerSkull = cachedWarps.get(playerUUID);
        playerSkull = updateText(playerSkull, playerUUID);
        updatePanel();
        return;
    }
    // plugin.getLogger().info("DEBUG: New skull");
    String playerName = plugin.getPlayers().getName(playerUUID);
    if (DEBUG)
        plugin.getLogger().info("DEBUG: name of warp = " + playerName);
    if (playerName == null || playerName.isEmpty()) {
        return;
    }
    ItemStack playerSkull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    SkullMeta meta = (SkullMeta) playerSkull.getItemMeta();
    meta.setDisplayName(playerName);
    playerSkull.setItemMeta(meta);
    cachedWarps.put(playerUUID, playerSkull);
    updatePanel();
    // Get the player head async
    addName(playerUUID, playerName);
}
Also used : SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack)

Example 19 with SkullMeta

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

the class TopTen method topTenAddEntry.

/**
 * Adds a player to the top ten, if the level is good enough
 *
 * @param ownerUUID
 * @param l
 */
public void topTenAddEntry(UUID ownerUUID, long l) {
    if (DEBUG) {
        plugin.getLogger().info("DEBUG: adding top ten entry " + ownerUUID + " " + l);
    }
    // needs to be removed from the list
    if (l < 1) {
        if (topTenList.containsKey(ownerUUID)) {
            topTenList.remove(ownerUUID);
        }
        return;
    }
    // Try and see if the player is online
    Player player = plugin.getServer().getPlayer(ownerUUID);
    if (player != null) {
        // Online
        if (!player.hasPermission(Settings.PERMPREFIX + "intopten")) {
            topTenList.remove(ownerUUID);
            return;
        }
    }
    topTenList.put(ownerUUID, l);
    topTenList = MapUtil.sortByValue(topTenList);
    // Add head to cache
    if (!topTenHeads.containsKey(ownerUUID)) {
        String name = plugin.getPlayers().getName(ownerUUID);
        if (name != null && !name.isEmpty()) {
            ItemStack playerSkull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
            SkullMeta meta = (SkullMeta) playerSkull.getItemMeta();
            meta.setDisplayName(name);
            playerSkull.setItemMeta(meta);
            topTenHeads.put(ownerUUID, playerSkull);
            // Get skull async
            plugin.getHeadGetter().getHead(ownerUUID, this);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack)

Example 20 with SkullMeta

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

the class TopTen method onInventoryClick.

@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
    // The inventory that was clicked in
    Inventory inventory = event.getInventory();
    if (inventory.getName() == null) {
        return;
    }
    // The player that clicked the item
    Player player = (Player) event.getWhoClicked();
    if (!inventory.getTitle().equals(plugin.myLocale(player.getUniqueId()).topTenGuiTitle)) {
        return;
    }
    event.setCancelled(true);
    player.updateInventory();
    if (event.getCurrentItem() != null && event.getCurrentItem().getType().equals(Material.SKULL_ITEM) && event.getCurrentItem().hasItemMeta()) {
        if (((SkullMeta) event.getCurrentItem().getItemMeta()).hasOwner()) {
            Util.runCommand(player, "is warp " + ((SkullMeta) event.getCurrentItem().getItemMeta()).getOwner());
            player.closeInventory();
        }
        return;
    }
    if (event.getSlotType().equals(SlotType.OUTSIDE)) {
        player.closeInventory();
        return;
    }
    if (event.getClick().equals(ClickType.SHIFT_RIGHT)) {
        player.closeInventory();
        return;
    }
}
Also used : Player(org.bukkit.entity.Player) SkullMeta(org.bukkit.inventory.meta.SkullMeta) Inventory(org.bukkit.inventory.Inventory) 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