org.bukkit.Material#SKULL_ITEM源码实例Demo

下面列出了org.bukkit.Material#SKULL_ITEM 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: UHC   文件: GoldenHeadsModule.java
@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);
}
 
源代码2 项目: AstralEdit   文件: DisplayArmorstand.java
/**
 * 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());
    }
}
 
源代码3 项目: AstralEdit   文件: DisplayArmorstand.java
/**
 * 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());
    }
}
 
源代码4 项目: AstralEdit   文件: DisplayArmorstand.java
/**
 * 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());
    }
}
 
源代码5 项目: AstralEdit   文件: DisplayArmorstand.java
/**
 * 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());
    }
}
 
源代码6 项目: AstralEdit   文件: DisplayArmorstand.java
/**
 * 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());
    }
}
 
源代码7 项目: StaffPlus   文件: Items.java
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;
}
 
源代码8 项目: factions-top   文件: GuiFactionList.java
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;
}
 
源代码9 项目: EliteMobs   文件: LootGUI.java
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);

    }
 
源代码10 项目: askyblock   文件: TopTen.java
/**
 * 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);
            }
        }
    } 
}
 
源代码11 项目: SkyWarsReloaded   文件: NMSHandler.java
@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);
	}
}
 
源代码12 项目: HeavySpleef   文件: FlagTrackingSpectate.java
@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();
}
 
源代码13 项目: SkyWarsReloaded   文件: NMSHandler.java
@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);
	}
}
 
源代码14 项目: PerWorldInventory   文件: ItemSerializer.java
/**
 * 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;
}
 
源代码15 项目: UHC   文件: PlayerHeadProvider.java
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;
}
 
源代码16 项目: ProjectAres   文件: ItemConfigurationParser.java
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;
}
 
源代码17 项目: SkyWarsReloaded   文件: NMSHandler.java
@Override
public ItemStack getBlankPlayerHead() {
	return new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
}
 
源代码18 项目: SkyWarsReloaded   文件: NMSHandler.java
@Override
public ItemStack getBlankPlayerHead() {
	return new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
}
 
源代码19 项目: SkyWarsReloaded   文件: NMSHandler.java
@Override
public ItemStack getBlankPlayerHead() {
	return new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
}
 
源代码20 项目: SkyWarsReloaded   文件: NMSHandler.java
@Override
public ItemStack getBlankPlayerHead() {
	return new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
}
 
 方法所在类
 同类方法