@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { GlowSkull skull = (GlowSkull) block.getState(); ItemStack drop = new ItemStack(Material.SKULL_ITEM, 1); if (skull.hasOwner()) { SkullMeta meta = (SkullMeta) drop.getItemMeta(); meta.setOwner(skull.getOwner()); drop.setItemMeta(meta); } drop.setDurability((short) skull.getSkullType().ordinal()); return Arrays.asList(drop); } }
@Override public void afterPlace(GlowPlayer player, GlowBlock block, ItemStack holding, GlowBlockState oldState) { GlowSkull skull = (GlowSkull) block.getState(); skull.setSkullType(getType(holding.getDurability())); if (skull.getSkullType() == SkullType.PLAYER) { SkullMeta meta = (SkullMeta) holding.getItemMeta(); if (meta != null) { skull.setOwner(meta.getOwner()); } } MaterialData data = skull.getData(); if (!(data instanceof Skull)) { warnMaterialData(Skull.class, data); return; } Skull skullData = (Skull) data; if (canRotate(skullData)) { // Can be rotated skull.setRotation(player.getFacing().getOppositeFace()); } skull.update(); // Wither for (int i = 0; i < 3; i++) { if (WITHER_PATTERN.matches(block.getLocation().clone(), true, i, 0)) { block.getWorld() .spawnEntity(block.getLocation().clone().subtract(0, 2, 0), EntityType.WITHER); break; } } }
/** * Creates an instance by copying from the given {@link ItemMeta}. If that item is another * {@link SkullMeta} with an owner, attempts to copy the owning player. * @param meta the {@link ItemMeta} to copy */ public GlowMetaSkull(ItemMeta meta) { super(meta); if (!(meta instanceof SkullMeta)) { return; } SkullMeta skull = (SkullMeta) meta; if (skull.hasOwner()) { if (skull instanceof GlowMetaSkull) { owner.set(((GlowMetaSkull) skull).owner.get()); } else { if (!setOwningPlayerInternal(skull.getOwningPlayer())) { owner.set(UNKNOWN_PLAYER); // necessary to preserve the return value of hasOwner() } } } }
public void openSpectatorCompass(Player player) { if (!this.isSpectator(player)) { return; } int teamplayers = this.getTeamPlayers().size(); int nom = (teamplayers % 9 == 0) ? 9 : (teamplayers % 9); int size = teamplayers + (9 - nom); Inventory compass = Bukkit .createInventory(null, size, BedwarsRel._l(player, "ingame.spectator")); for (Team t : this.getTeams().values()) { for (Player p : t.getPlayers()) { ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3); SkullMeta meta = (SkullMeta) head.getItemMeta(); meta.setDisplayName(t.getChatColor() + p.getDisplayName()); meta.setLore(Arrays.asList(t.getChatColor() + t.getDisplayName())); meta.setOwner(p.getName()); head.setItemMeta(meta); compass.addItem(head); } } player.openInventory(compass); }
return ((BookMeta) meta).getTitle(); } else if (meta instanceof SkullMeta) { if (((SkullMeta) meta).hasOwner()) { if (Utils.getMajorVersion() >= 13) { return String.format(langConfig.getString("block.minecraft.player_head.named", "%s's Head"), ((SkullMeta) meta).getOwningPlayer().getName()); } else { return String.format(langConfig.getString("item.skull.player.name", "%s's Head"), ((SkullMeta) meta).getOwner());
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1); SkullMeta skull = (SkullMeta) head.getItemMeta(); skull.setOwningPlayer(op); skull.setDisplayName(op.getName()); ArrayList<String> lore = new ArrayList<>(); lore.add(c); skull.setLore(lore); head.setItemMeta(skull); heads[i] = head;
@Override public boolean hasOwner() { return sm.hasOwner(); }
@Override public void setOwningPlayer(MCOfflinePlayer player) { sm.setOwningPlayer((OfflinePlayer) player.getHandle()); } }
@Override public MCOfflinePlayer getOwningPlayer() { return new BukkitMCOfflinePlayer(sm.getOwningPlayer()); }
public void openSpectatorCompass(Player player) { if (!this.isSpectator(player)) { return; } int teamplayers = this.getTeamPlayers().size(); int nom = (teamplayers % 9 == 0) ? 9 : (teamplayers % 9); int size = teamplayers + (9 - nom); Inventory compass = Bukkit .createInventory(null, size, BedwarsRel._l(player, "ingame.spectator")); for (Team t : this.getTeams().values()) { for (Player p : t.getPlayers()) { ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3); SkullMeta meta = (SkullMeta) head.getItemMeta(); meta.setDisplayName(t.getChatColor() + p.getDisplayName()); meta.setLore(Arrays.asList(t.getChatColor() + t.getDisplayName())); meta.setOwner(p.getName()); head.setItemMeta(meta); compass.addItem(head); } } player.openInventory(compass); }
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1); SkullMeta skull = (SkullMeta) head.getItemMeta(); skull.setOwningPlayer(p); skull.setDisplayName(p.getName()); ArrayList<String> lore = new ArrayList<>(); lore.add(p.getUniqueId().toString()); skull.setLore(lore); head.setItemMeta(skull); heads[i] = head;
@Override public LuaValue call() { return LuaValue.valueOf(meta.hasOwner()); } });
drop.setDurability((short) 3); SkullMeta skullMeta = (SkullMeta) drop.getItemMeta(); skullMeta.setOwningPlayer(targetPlayer); drop.setItemMeta(skullMeta); break;
public ItemStackBuilder owner(String name) { if (itemMeta instanceof SkullMeta) { ((SkullMeta) itemMeta).setOwner(name); } return this; }
npc.setDurability((short) 3); SkullMeta npcMeta = (SkullMeta) npc.getItemMeta(); npcMeta.setOwner(npcName); npcMeta.setDisplayName(npcNameColor + npcName); npcMeta.setLore(stringToLines(response, npcTextColor, null)); npc.setItemMeta(npcMeta); buttons[0] = npc;
@Override public String getOwner() { return sm.getOwner(); }
public ItemBuilder skullOwner(String name) { if (itemMeta instanceof SkullMeta) { ((SkullMeta) itemMeta).setOwner(name); } return this; }
@Override public boolean setOwner(String owner) { return sm.setOwner(owner); }