public void clearNearbyItems() { if (item == null) { return; } List<Entity> nearbyEntities = item.getNearbyEntities(7, 7, 7); for (Entity entity : nearbyEntities) { if (entity instanceof Item) { Item nearbyItem = (Item) entity; boolean display = false; for (MetadataValue cmeta : nearbyItem.getMetadata("HyperConomy")) { if (cmeta.asString().equalsIgnoreCase("item_display")) { display = true; break; } } if (!nearbyItem.equals(item) && !display) { if (nearbyItem.getItemStack().getType() == item.getItemStack().getType()) { HyperItemStack near = new HyperItemStack(nearbyItem.getItemStack()); HyperItemStack displayItem = new HyperItemStack(item.getItemStack()); if (near.getDamageValue() == displayItem.getDamageValue()) { entity.remove(); } } } } } }
public boolean blockItemDrop(Item droppedItem) { HyperItemStack dropped = new HyperItemStack(droppedItem.getItemStack()); HyperItemStack displayItem = new HyperItemStack(item.getItemStack()); Location l = droppedItem.getLocation(); Material dropType = droppedItem.getItemStack().getType(); int dropda = dropped.getDamageValue(); double dropx = l.getX(); double dropy = l.getY(); double dropz = l.getZ(); World dropworld = l.getWorld(); Material type = item.getItemStack().getType(); int da = displayItem.getDamageValue(); if (type == dropType) { if (da == dropda) { if (dropworld.equals(location.getWorld())) { if (Math.abs(dropx - location.getX()) < 10) { if (Math.abs(dropz - location.getZ()) < 10) { if (Math.abs(dropy - location.getY()) < 30) { return true; } else { droppedItem.setVelocity(new Vector(0, 0, 0)); Block dblock = droppedItem.getLocation().getBlock(); while (dblock.getType().equals(Material.AIR)) { dblock = dblock.getRelative(BlockFace.DOWN); } if (dblock.getLocation().getY() <= (location.getBlockY() + 10)) { return true; } } } } } } } return false; }