Java Code Examples for org.bukkit.entity.Item#setMetadata()
The following examples show how to use
org.bukkit.entity.Item#setMetadata() .
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: SpawnableItem.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@Override public void spawn(Location location, Match match) { Item item = location.getWorld().dropItem(location, stack); item.setMetadata(Spawner.METADATA_KEY, new FixedMetadataValue(PGM.get(), METADATA_VALUE)); }
Example 2
Source File: QuadCrate.java From Crazy-Crates with MIT License | 4 votes |
@EventHandler public void onChestClick(PlayerInteractEvent e) { Player player = e.getPlayer(); if (QuadCrateSession.inSession(player)) { QuadCrateSession session = QuadCrateSession.getSession(player); if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_BLOCK) { Block block = e.getClickedBlock(); if (session.getChestLocations().contains(block.getLocation())) { e.setCancelled(true); if (!session.hasChestBeenOpened(block.getLocation())) { nms.openChest(block, true); Crate crate = session.getCrate(); Prize prize = crate.pickPrize(player, block.getLocation().add(.5, 1.3, .5)); cc.givePrize(player, prize); ItemBuilder itemBuilder = ItemBuilder.convertItemStack(prize.getDisplayItem()); itemBuilder.addLore(new Random().nextInt(Integer.MAX_VALUE) + "");//Makes sure items don't merge ItemStack item = itemBuilder.build(); NBTItem nbtItem = new NBTItem(item); nbtItem.setBoolean("crazycrates-item", true); item = nbtItem.getItem(); Item reward = player.getWorld().dropItem(block.getLocation().add(.5, 1, .5), item); reward.setMetadata("betterdrops_ignore", new FixedMetadataValue(cc.getPlugin(), true)); reward.setVelocity(new Vector(0, .2, 0)); reward.setCustomName(prize.getDisplayItem().getItemMeta().getDisplayName()); reward.setCustomNameVisible(true); reward.setPickupDelay(Integer.MAX_VALUE); session.getDisplayedRewards().add(reward); session.setChestOpened(block.getLocation(), true); if (session.allChestsOpened()) {//All 4 crates have been opened new BukkitRunnable() { @Override public void run() { session.endCrate(); player.playSound(player.getLocation(), cc.getSound("BLOCK_STONE_STEP", "STEP_STONE"), 1, 1); } }.runTaskLater(cc.getPlugin(), 60); } } } } } }
Example 3
Source File: BatBomb.java From NBTEditor with GNU General Public License v3.0 | 4 votes |
@Override public void onTrigger(Item item) { Entity bat = item.getWorld().spawnEntity(item.getLocation(), EntityType.BAT); item.setMetadata("is-active", new FixedMetadataValue(getPlugin(), true)); item.addPassenger(bat); }
Example 4
Source File: SlimefunUtils.java From Slimefun4 with GNU General Public License v3.0 | 2 votes |
/** * This will prevent the given {@link Item} from being picked up. * This is useful for display items which the {@link AncientPedestal} uses. * * @param item * The {@link Item} to prevent from being picked up * @param context * The context in which this {@link Item} was flagged */ public static void markAsNoPickup(Item item, String context) { item.setMetadata(NO_PICKUP_METADATA, new FixedMetadataValue(SlimefunPlugin.instance, context)); }