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);
}
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);
}
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);
}
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);
}
}
}
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;
}
}
Aggregations