Java Code Examples for org.bukkit.Material#SKULL_ITEM
The following examples show how to use
org.bukkit.Material#SKULL_ITEM .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoldenHeadsModule.java From UHC with MIT License | 6 votes |
@EventHandler public void on(PrepareItemCraftEvent event) { if (event.getRecipe().getResult().getType() != Material.GOLDEN_APPLE) return; final ItemStack centre = event.getInventory().getMatrix()[CRAFTING_INVENTORY_CENTRE_SLOT_ID]; if (centre == null || centre.getType() != Material.SKULL_ITEM) return; if (!isEnabled()) { event.getInventory().setResult(new ItemStack(Material.AIR)); return; } final SkullMeta meta = (SkullMeta) centre.getItemMeta(); final ItemStack goldenHeadItem = getGoldenHeadItem(meta.hasOwner() ? meta.getOwner() : "Manually Crafted"); event.getInventory().setResult(goldenHeadItem); }
Example 2
Source File: DisplayArmorstand.java From AstralEdit with Apache License 2.0 | 5 votes |
/** * Initializes the armorstand * * @param player player * @param location location * @param id id * @param data data * @param watchers watchers */ public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) { super(); this.watchers = watchers; this.player = player; this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle()); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.armorStand.a(compound); this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0); this.storedId = id; this.storedData = data; ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data); this.getCraftEntity().setHelmet(stackBuilder.build()); this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0)); if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) { stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3); if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) { stackBuilder.setSkin(NMSRegistry.WATER_HEAD); } else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) { stackBuilder.setSkin(NMSRegistry.LAVA_HEAD); } else { stackBuilder.setSkin(NMSRegistry.NOT_FOUND); } ((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build()); } }
Example 3
Source File: ItemSerializer.java From PerWorldInventory with GNU General Public License v3.0 | 5 votes |
/** * Serialize an ItemStack to a JsonObject. * <p> * The item itself will be saved as a Base64 encoded string to * simplify the serialization and deserialization process. The result is * not human readable. * </p> * * @param item The item to serialize. * @param index The position in the inventory. * @return A JsonObject with the serialized item. */ public JsonObject serializeItem(ItemStack item, int index) { JsonObject values = new JsonObject(); if (item == null) return null; /* * Check to see if the item is a skull with a null owner. * This is because some people are getting skulls with null owners, which causes Spigot to throw an error * when it tries to serialize the item. If this ever gets fixed in Spigot, this will be removed. */ if (item.getType() == Material.SKULL_ITEM) { SkullMeta meta = (SkullMeta) item.getItemMeta(); if (meta.hasOwner() && (meta.getOwner() == null || meta.getOwner().isEmpty())) { item.setItemMeta(plugin.getServer().getItemFactory().getItemMeta(Material.SKULL_ITEM)); } } values.addProperty("index", index); try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); BukkitObjectOutputStream bos = new BukkitObjectOutputStream(outputStream)) { bos.writeObject(item); String encoded = Base64Coder.encodeLines(outputStream.toByteArray()); values.addProperty("item", encoded); } catch (IOException ex) { ConsoleLogger.severe("Unable to serialize item '" + item.getType().toString() + "':", ex); return null; } return values; }
Example 4
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getMaterial(String item) { if (item.equalsIgnoreCase("SKULL_ITEM")) { return new ItemStack(Material.SKULL_ITEM, 1, (short) 1); } else { return new ItemStack(Material.valueOf(item), 1); } }
Example 5
Source File: FlagTrackingSpectate.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Subscribe public void onPlayerJoinGame(PlayerJoinGameEvent event) { SpleefPlayer player = event.getPlayer(); GuiInventory trackerInventory = getTrackerInventory(); //Insert the player's head somewhere in the tracker inventory for (int y = 0; y < trackerInventory.getLines(); y++) { for (int x = 0; x < GuiInventory.SLOTS_PER_LINE; x++) { trackerInventory.getSlot(x, y); GuiInventorySlot slot = trackerInventory.getSlot(x, y); if (slot.getItem() != null) { continue; } MaterialData data = new MaterialData(Material.SKULL_ITEM, (byte)SkullType.PLAYER.ordinal()); ItemStack skull = data.toItemStack(1); SkullMeta meta = (SkullMeta) skull.getItemMeta(); meta.setDisplayName(getI18N().getVarString(Messages.Player.TRACKER_SKULL_TITLE) .setVariable("tracking", player.getDisplayName()) .toString()); meta.setOwner(player.getName()); skull.setItemMeta(meta); slot.setItem(skull); slot.setValue(player); break; } } trackerInventory.updateViews(); }
Example 6
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getMaterial(String item) { if (item.equalsIgnoreCase("SKULL_ITEM")) { return new ItemStack(Material.SKULL_ITEM, 1, (short) 1); } else { return new ItemStack(Material.valueOf(item), 1); } }
Example 7
Source File: TopTen.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * 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); } // Special case for removals. If a level of zero is given the player // needs to be removed from the list if (l < 1) { 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 = topTenList.entrySet().stream().sorted(Collections.reverseOrder(Map.Entry.comparingByValue())).limit(10) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); // Add head to cache if (Settings.warpHeads) { if (topTenList.containsKey(ownerUUID) && !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); } } } }
Example 8
Source File: LootGUI.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
private void headerConstructor(Inventory inventory) { ItemStack arrowLeft = new ItemStack(Material.SKULL_ITEM, 1, (short) 3); SkullMeta arrowLeftSkullMeta = (SkullMeta) arrowLeft.getItemMeta(); arrowLeftSkullMeta.setOwner("MHF_ArrowLeft"); arrowLeftSkullMeta.setDisplayName("Previous Item Ranks"); arrowLeft.setItemMeta(arrowLeftSkullMeta); inventory.setItem(0, arrowLeft); ItemStack arrowRight = new ItemStack(Material.SKULL_ITEM, 1, (short) 3); SkullMeta arrowRightSkullMeta = (SkullMeta) arrowRight.getItemMeta(); arrowRightSkullMeta.setOwner("MHF_ArrowRight"); arrowRightSkullMeta.setDisplayName("Next Item Ranks"); arrowRight.setItemMeta(arrowRightSkullMeta); inventory.setItem(8, arrowRight); ItemStack signature = new ItemStack(Material.SKULL_ITEM, 1, (short) 3); SkullMeta signatureSkullMeta = (SkullMeta) signature.getItemMeta(); signatureSkullMeta.setOwner("magmaguy"); signatureSkullMeta.setDisplayName("EliteMobs by MagmaGuy"); List<String> signatureList = new ArrayList<>(); signatureList.add("Support the plugins you enjoy!"); signatureSkullMeta.setLore(signatureList); signature.setItemMeta(signatureSkullMeta); inventory.setItem(4, signature); }
Example 9
Source File: GuiFactionList.java From factions-top with MIT License | 5 votes |
private ItemStack getItem(FactionWorth worth, Map<String, String> placeholders, Settings settings, String owner) { String text = insertPlaceholders(settings, worth, replace(this.text, placeholders)); List<String> lore = insertPlaceholders(settings, worth, replace(this.lore, placeholders)); ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (short) 3); SkullMeta meta = (SkullMeta) item.getItemMeta(); meta.setDisplayName(text); meta.setLore(lore); meta.setOwner(owner); item.setItemMeta(meta); return item; }
Example 10
Source File: Items.java From StaffPlus with GNU General Public License v3.0 | 5 votes |
public static ItemStack createSkull(String name) { ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1); SkullMeta skullMeta = (SkullMeta) skull.getItemMeta(); skullMeta.setOwner(name); skull.setItemMeta(skullMeta); return skull; }
Example 11
Source File: DisplayArmorstand.java From AstralEdit with Apache License 2.0 | 5 votes |
/** * Initializes the armorstand * * @param player player * @param location location * @param id id * @param data data * @param watchers watchers */ public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) { super(); this.watchers = watchers; this.player = player; this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle()); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.armorStand.a(compound); this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0); this.storedId = id; this.storedData = data; ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data); this.getCraftEntity().setHelmet(stackBuilder.build()); this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0)); if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) { stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3); if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) { stackBuilder.setSkin(NMSRegistry.WATER_HEAD); } else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) { stackBuilder.setSkin(NMSRegistry.LAVA_HEAD); } else { stackBuilder.setSkin(NMSRegistry.NOT_FOUND); } ((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build()); } }
Example 12
Source File: DisplayArmorstand.java From AstralEdit with Apache License 2.0 | 5 votes |
/** * Initializes the armorstand * * @param player player * @param location location * @param id id * @param data data * @param watchers watchers */ public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) { super(); this.watchers = watchers; this.player = player; this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle()); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.armorStand.a(compound); this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0); this.storedId = id; this.storedData = data; ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data); this.getCraftEntity().setHelmet(stackBuilder.build()); this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setGlowing(true); if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) { stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3); if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) { stackBuilder.setSkin(NMSRegistry.WATER_HEAD); } else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) { stackBuilder.setSkin(NMSRegistry.LAVA_HEAD); } else { stackBuilder.setSkin(NMSRegistry.NOT_FOUND); } ((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build()); } }
Example 13
Source File: DisplayArmorstand.java From AstralEdit with Apache License 2.0 | 5 votes |
/** * Initializes the armorstand * * @param player player * @param location location * @param id id * @param data data * @param watchers watchers */ public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) { super(); this.watchers = watchers; this.player = player; this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle()); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.armorStand.a(compound); this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0); this.storedId = id; this.storedData = data; ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data); this.getCraftEntity().setHelmet(stackBuilder.build()); this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setGlowing(true); if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) { stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3); if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) { stackBuilder.setSkin(NMSRegistry.WATER_HEAD); } else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) { stackBuilder.setSkin(NMSRegistry.LAVA_HEAD); } else { stackBuilder.setSkin(NMSRegistry.NOT_FOUND); } ((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build()); } }
Example 14
Source File: DisplayArmorstand.java From AstralEdit with Apache License 2.0 | 5 votes |
/** * Initializes the armorstand * * @param player player * @param location location * @param id id * @param data data * @param watchers watchers */ public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) { super(); this.watchers = watchers; this.player = player; this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle()); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.armorStand.a(compound); this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0); this.storedId = id; this.storedData = data; ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data); this.getCraftEntity().setHelmet(stackBuilder.build()); this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0)); this.getCraftEntity().setGlowing(true); if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) { stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3); if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) { stackBuilder.setSkin(NMSRegistry.WATER_HEAD); } else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) { stackBuilder.setSkin(NMSRegistry.LAVA_HEAD); } else { stackBuilder.setSkin(NMSRegistry.NOT_FOUND); } ((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build()); } }
Example 15
Source File: PlayerHeadProvider.java From UHC with MIT License | 5 votes |
public ItemStack getPlayerHeadItem(String name) { final ItemStack stack = new ItemStack(Material.SKULL_ITEM, 1); stack.setDurability(PLAYER_HEAD_DATA); final SkullMeta meta = (SkullMeta) stack.getItemMeta(); meta.setOwner(name); stack.setItemMeta(meta); return stack; }
Example 16
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 4 votes |
@Override public ItemStack getBlankPlayerHead() { return new ItemStack(Material.SKULL_ITEM, 1, (short) 3); }
Example 17
Source File: ItemConfigurationParser.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
public ItemStack needSkull(ConfigurationSection section, String key) throws InvalidConfigurationException { final ItemStack stack = new ItemStack(Material.SKULL_ITEM); stack.setDurability((short) SkullType.PLAYER.ordinal()); needSkull(stack, section, key); return stack; }
Example 18
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 4 votes |
@Override public ItemStack getBlankPlayerHead() { return new ItemStack(Material.SKULL_ITEM, 1, (short) 3); }
Example 19
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 4 votes |
@Override public ItemStack getBlankPlayerHead() { return new ItemStack(Material.SKULL_ITEM, 1, (short) 3); }
Example 20
Source File: NMSHandler.java From SkyWarsReloaded with GNU General Public License v3.0 | 4 votes |
@Override public ItemStack getBlankPlayerHead() { return new ItemStack(Material.SKULL_ITEM, 1, (short) 3); }