Java Code Examples for org.bukkit.World#dropItem()
The following examples show how to use
org.bukkit.World#dropItem() .
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: CommonCustomMob.java From civcraft with GNU General Public License v2.0 | 5 votes |
public void dropItems() { try { if (entity == null) { return; } LinkedList<MobDrop> dropped = getRandomDrops(); World world = entity.getBukkitEntity().getWorld(); Location loc = getLocation(entity); for (MobDrop d : dropped) { ItemStack stack; if (d.isVanillaDrop) { stack = ItemManager.createItemStack(d.vanillaType, 1, d.vanillaData); } else { LoreCraftableMaterial craftMat = LoreCraftableMaterial.getCraftMaterialFromId(d.craftMatId); stack = LoreCraftableMaterial.spawn(craftMat); } world.dropItem(loc, stack); } if (this.coinMax != 0 && this.coinMin != 0) { ExperienceOrb orb = (ExperienceOrb)world.spawn(loc, ExperienceOrb.class); Random random = new Random(); int coins = random.nextInt(this.coinMax - this.coinMin) + this.coinMin; orb.setExperience(coins); } } catch(Exception e) { e.printStackTrace(); } }
Example 2
Source File: FlagItemReward.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onPlayerWinGame(PlayerWinGameEvent event) { SpleefPlayer[] winners = event.getWinners(); for (SpleefPlayer player : winners) { Player bukkitPlayer = player.getBukkitPlayer(); World world = bukkitPlayer.getWorld(); Inventory inventory = bukkitPlayer.getInventory(); boolean invFull = false; for (ItemStack reward : getValue()) { if (reward.getType() == Material.AIR) { continue; } if (invFull) { world.dropItem(bukkitPlayer.getLocation(), reward); } else { if (isInventoryFull(inventory)) { invFull = true; world.dropItem(bukkitPlayer.getLocation(), reward); bukkitPlayer.sendMessage(getI18N().getString(Messages.Player.ITEMREWARD_ITEMS_DROPPED)); } else { inventory.addItem(reward); } } } } }