@Override public void call(Event event) { PlayerDropItemEvent e = (PlayerDropItemEvent) event; if (e.getItemDrop().getItemStack().getType() == Material.SULPHUR) { Item item = e.getItemDrop(); item.getWorld().createExplosion(item.getLocation(), 10f, false); } }
public static void checkSecond() { for (Item i : Bukkit.getWorld("PrisonMap").getEntitiesByClass(Item.class)) { if (tnts.contains(i.getUniqueId())) { ParticleEffect.SMOKE_NORMAL.display( 0.25f, 0.25f, 0.25f, 0.0001f, 5, i.getLocation().clone().add(0, 0.5, 0), 100); if (i.getTicksLived() > 30) { ParticleEffect.EXPLOSION_HUGE.display( 0.5f, 0.5f, 0.5f, 0.1f, 5, i.getLocation().clone().add(0, 1, 0), 100); for (Entity e : i.getNearbyEntities(3.5, 3.5, 3.5)) { if (e instanceof Player) { Location midPoint = i.getLocation(); Vector direction = e.getLocation().toVector().subtract(midPoint.toVector()).normalize(); direction.multiply(1.1).setY(0.7); e.setVelocity(direction); ((Player) e).damage(0.0); } } final List<Location> blocks = new ArrayList<Location>(); int radius = 3; int bX = i.getLocation().getBlockX(); int bY = i.getLocation().getBlockY(); int bZ = i.getLocation().getBlockZ(); for (int x = bX - radius; x <= bX + radius; x++) { for (int y = bY - radius; y <= bY + radius; y++) { for (int z = bZ - radius; z <= bZ + radius; z++) { double distance = ((bX - x) * (bX - x) + ((bZ - z) * (bZ - z)) + ((bY - y) * (bY - y))); if (distance < radius * radius) { Location loc = new Location(i.getWorld(), x, y, z); if (loc.getBlock().getType() != Material.AIR) { blocks.add(loc); } } } } } for (Location loc : blocks) { Random r = new Random(); int i1 = r.nextInt(3) + 1; if (Game.isBreakable(loc.getBlock().getType()) && (i1 == 1 || i1 == 2)) { loc.getBlock().setType(Material.AIR); } } Game.playSound(Sound.EXPLODE, i.getLocation(), 1f, 1f); tnts.remove(i.getUniqueId()); i.teleport(i.getLocation().subtract(0, 500, 0)); } } } }
@Override void onUpdate() { try { for (Item item : melonBlocks) { if (item.isOnGround()) { item.getWorld().playEffect(item.getLocation(), Effect.STEP_SOUND, 103); for (int i = 0; i < 8; i++) { final Item melon = getPlayer() .getWorld() .dropItem( item.getLocation(), ItemFactory.create( Material.MELON, (byte) 0x0, UUID.randomUUID().toString())); melon.setVelocity( new Vector( random.nextDouble() - 0.5, random.nextDouble() / 2.0, random.nextDouble() - 0.5) .multiply(0.75D)); melons.add(melon); Bukkit.getScheduler() .runTaskLaterAsynchronously( Core.getPlugin(), new BukkitRunnable() { @Override public void run() { if (melon.isValid()) { melon.remove(); melons.remove(melon); } } }, 100); } melonBlocks.remove(item); item.remove(); } } } catch (Exception exc) { } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerDropItem(PlayerDropItemEvent event) { final Player p = event.getPlayer(); final Item item = event.getItemDrop(); if (isWorld(item.getWorld())) { new BukkitRunnable() { @Override public void run() { if (item.isDead()) { cancel(); return; } List<Entity> ents = EntityChecker.getNearbyEntities(item, 2); for (Entity ent : ents) { MetadataValue meta; if (ent instanceof ArmorStand && (meta = EntityChecker.getMeta(ent, "isFireplace")) != null && meta.asBoolean()) { ItemStack result = item.getItemStack(); item.remove(); Material type = result.getType(); switch (type) { case RAW_CHICKEN: result.setType(Material.COOKED_CHICKEN); break; case RAW_BEEF: result.setType(Material.COOKED_BEEF); break; case RAW_FISH: result.setType(Material.COOKED_FISH); break; case PORK: result.setType(Material.GRILLED_PORK); break; case POTATO_ITEM: result.setType(Material.BAKED_POTATO); break; default: break; } cancel(); if (p.isOnline()) { p.getWorld().dropItem(p.getLocation(), result).setPickupDelay(0); } else { p.getWorld().dropItem(item.getLocation(), result).setPickupDelay(0); } break; } } } }.runTaskTimer(getCraftZ(), 10, 10); } }