/** * Add ore to chest on drop * * @param event Item spawn event instance */ @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onItemSpawn(ItemSpawnEvent event) { if (event.getEntityType() != EntityType.DROPPED_ITEM || Meta.hasMeta(event.getEntity().getItemStack()) || event.getEntity().hasMetadata("playerDrop")) return; for (int i = 0; i < MATERIALS.length; i++) { ItemStack stack = event.getEntity().getItemStack(); if (MATERIALS[i] != stack.getType()) continue; ItemStack newStack = stack.clone(); this.inventory.addItem(Meta.addMeta(newStack)); event.getEntity().setItemStack(Meta.addMeta(event.getEntity().getItemStack())); } }
/** * Delete different type of certains blocks * * @param event Event */ @EventHandler public void onItemSpawn(ItemSpawnEvent event) { if (event.getEntityType() != EntityType.DROPPED_ITEM) return; if (event.getEntity().hasMetadata("playerDrop")) return; Material material = event.getEntity().getItemStack().getType(); if (material == Material.LOG || material == Material.LOG_2) event.getEntity().setItemStack(new ItemStack(Material.LOG, event.getEntity().getItemStack().getAmount())); else if (material == Material.COBBLESTONE) event.getEntity().setItemStack(new ItemStack(Material.COBBLESTONE, event.getEntity().getItemStack().getAmount())); else if (material == Material.STONE) event.getEntity().setItemStack(new ItemStack(Material.COBBLESTONE, event.getEntity().getItemStack().getAmount())); }
/** * Soup dropping * * @param event Event */ @EventHandler public void onItemSpawn(ItemSpawnEvent event) { if (event.getEntityType() != EntityType.DROPPED_ITEM) return; if (event.getEntity().hasMetadata("playerDrop")) return; Material material = event.getEntity().getItemStack().getType(); if (material == Material.BROWN_MUSHROOM || material == Material.RED_MUSHROOM) event.getEntity().setItemStack(new ItemStack(Material.MUSHROOM_SOUP, 2)); else if (material == Material.POTATO_ITEM) event.getEntity().setItemStack(new ItemStack(Material.BAKED_POTATO, 1)); else if (material == Material.CARROT_ITEM) event.getEntity().setItemStack(new ItemStack(Material.GOLDEN_CARROT, 1)); else if (material == Material.WHEAT) event.getEntity().setItemStack(new ItemStack(Material.BREAD, 1)); else if (material == Material.PUMPKIN) event.getEntity().setItemStack(new ItemStack(Material.PUMPKIN_PIE, 1)); }
/** * Double ore's drop * * @param event Event */ @EventHandler public void onItemSpawn(ItemSpawnEvent event) { if (event.getEntityType() != EntityType.DROPPED_ITEM) return; if(Meta.hasMeta(event.getEntity().getItemStack())) return; ItemStack stack = event.getEntity().getItemStack(); if (this.drops.containsKey(stack)) { ItemStack newStack = this.drops.get(stack).getDrop(stack, this.random); if (newStack != null) { event.getEntity().setItemStack(Meta.addMeta(newStack)); this.spawnXP(event.getEntity(), this.drops.get(stack).getExperienceModifier(this.random)); } } }
/** * Chance to drop a diamond when a player breaks a flower * * @param event Event */ @EventHandler public void onItemSpawn(ItemSpawnEvent event) { if (event.getEntityType() != EntityType.DROPPED_ITEM) return; if (event.getEntity().hasMetadata("playerDrop")) return; if (event.getEntity().getItemStack().getType() != Material.YELLOW_FLOWER && event.getEntity().getItemStack().getType() != Material.RED_ROSE && (event.getEntity().getItemStack().getType() != Material.DOUBLE_PLANT || (event.getEntity().getItemStack().getDurability() > 1 && event.getEntity().getItemStack().getDurability() < 4))) return; if (this.random.nextDouble() <= (double) this.moduleConfiguration.get("chance")) event.getEntity().getWorld().dropItemNaturally(event.getLocation(), Meta.addMeta(new ItemStack(Material.DIAMOND, (int) this.moduleConfiguration.get("diamonds")))); event.setCancelled(true); }
@EventHandler(priority = EventPriority.LOWEST) public void onItemSpawn(ItemSpawnEvent event) { if (physicsFreeze) { event.setCancelled(true); return; } Location loc = event.getLocation(); int cx = loc.getBlockX() >> 4; int cz = loc.getBlockZ() >> 4; int[] count = getCount(cx, cz); if (count[2] >= Settings.IMP.TICK_LIMITER.ITEMS) { event.setCancelled(true); return; } if (++count[2] >= Settings.IMP.TICK_LIMITER.ITEMS) { cleanup(loc.getChunk()); cancelNearby(cx, cz); if (rateLimit <= 0) { rateLimit = 20; Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled item lag source at " + loc); } event.setCancelled(true); return; } }
@EventHandler public void itemSpawn(ItemSpawnEvent event) { ItemStack stack = event.getEntity().getItemStack(); if (stack == null || isMarked(stack)) return; Material material = stack.getType(); LootRule rule = LootRule.getRule(material); if (rule == null) return; if (rule.getProbability() < 1 && new Random().nextDouble() > rule.getProbability()) return; MaterialData target = rule.getTarget(); ItemStack replace = new ItemStack(target.getItemType(), stack.getAmount() * rule.getMultiplier()); replace.setData(target); event.getEntity().setItemStack(mark(replace)); }
@EventHandler(priority = EventPriority.NORMAL) public void onItemSpawn(final ItemSpawnEvent event) { if (event.isCancelled()) return; final Entity item = event.getEntity(); if (item.getType() != EntityType.DROPPED_ITEM || ((Item) item).getItemStack().getType() != Material.SUGAR_CANE) return; // Stop sugarcane block from decaying (workaround for lack of 1.7.2-R0.1 physics support) final WorldCoord coord = new WorldCoord((Item) item); final Gate nearestGate = Gates.gateFromPortal(coord); if (nearestGate != null) { if (nearestGate.getMaterial() != Material.SUGAR_CANE_BLOCK) return; event.getEntity().remove(); plugin.getServer().getScheduler().scheduleSyncDelayedTask(Plugin.instance, new Runnable() { @Override public void run() { coord.getBlock().setType(Material.SUGAR_CANE_BLOCK); } }, 1); } }
@EventHandler(priority=EventPriority.LOWEST) public void onItemSpawn(ItemSpawnEvent event) { Item entity = event.getEntity(); Chunk chunk = entity.getLocation().getChunk(); if (chunk == lastChunk) { event.getEntity().remove(); event.setCancelled(true); return; } if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) { return; } Entity[] entities = chunk.getEntities(); if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { event.getEntity().remove(); event.setCancelled(true); lastChunk = chunk; } else { lastChunk = null; } }
@EventHandler(priority = EventPriority.HIGHEST) public void OnItemSpawn(ItemSpawnEvent event) { ItemStack stack = event.getEntity().getItemStack(); if (LoreMaterial.isCustom(stack)) { LoreMaterial.getMaterial(stack).onItemSpawn(event); } if (isUnwantedVanillaItem(stack)) { if (!stack.getType().equals(Material.HOPPER) && !stack.getType().equals(Material.HOPPER_MINECART)) { event.setCancelled(true); event.getEntity().remove(); } } }
@EventHandler(priority = EventPriority.MONITOR) public void OnItemSpawn(ItemSpawnEvent event) { Item item = event.getEntity(); BonusGoodie goodie = CivGlobal.getBonusGoodie(item.getItemStack()); if (goodie == null) { return; } // Cant validate here, validate in drop item events... goodie.setItem(item); try { goodie.update(false); goodie.updateLore(item.getItemStack()); } catch (CivException e) { e.printStackTrace(); } }
@EventHandler(priority = EventPriority.LOWEST) public void onItemSpawn(ItemSpawnEvent event) { Item entity = event.getEntity(); Chunk chunk = entity.getLocation().getChunk(); if (chunk == this.lastChunk) { event.getEntity().remove(); event.setCancelled(true); return; } if (!PS.get().hasPlotArea(chunk.getWorld().getName())) { return; } Entity[] entities = chunk.getEntities(); if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) { event.getEntity().remove(); event.setCancelled(true); this.lastChunk = chunk; } else { this.lastChunk = null; } }
@EventHandler public void onItemSpawn(ItemSpawnEvent e) { if (e.getEntity().getItemStack().getType() == Material.EGG) { if (e.getEntity().getVelocity().getY() * 10 == 2) { e.getEntity().remove(); } } }
@SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void processItemRemoval(ItemSpawnEvent event) { final ItemStack item = event.getEntity().getItemStack(); if(patterns.stream().anyMatch(pattern -> pattern.matches(item))) { event.setCancelled(true); } }
@EventHandler public void onItemSpawn(ItemSpawnEvent event) { ItemStack stack = event.getEntity().getItemStack(); if(applyRules(stack)) { event.getEntity().setItemStack(stack); } }
@EventHandler public void onDrop(ItemSpawnEvent event) { if(event.isCancelled()) return; final Item itemDrop = event.getEntity(); if(itemDrop.getItemStack().getType() == Material.BOWL) { final Runnable task = new Runnable() { public void run() { if(itemDrop.getItemStack().getAmount() != 1) return; Location itemLocation = itemDrop.getLocation(); if(itemLocation.getBlock().getType() == Material.WATER || itemLocation.getBlock().getType() == Material.STATIONARY_WATER) { itemDrop.remove(); ItemStack i_beetroot = new ItemStack(Material.BEETROOT_SOUP, 1); ItemMeta beetrootMeta= i_beetroot.getItemMeta(); beetrootMeta.setDisplayName(ChatColor.RESET + Survival.instance.Words.get("Water Bowl")); i_beetroot.setItemMeta(beetrootMeta); itemDrop.getWorld().dropItem(itemLocation, i_beetroot); } } }; Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, task, 20L); } }
@EventHandler public void onGhastTearSlimeBlock(ItemSpawnEvent e) { if(e.getEntityType() == EntityType.DROPPED_ITEM) { Item i = (Item)e.getEntity(); switch(i.getItemStack().getType()) { case GHAST_TEAR: Bukkit.getScheduler().runTaskLater(Survival.instance, initRunnable(i), 20); break; default: } } }
/** * Drop some utilities * * @param event Event */ @EventHandler public void onItemSpawn(ItemSpawnEvent event) { if (event.getEntityType() != EntityType.DROPPED_ITEM) return; if (Meta.hasMeta(event.getEntity().getItemStack())) return; ItemStack stack = event.getEntity().getItemStack(); for (ItemStack drop : this.drops.keySet()) { if (drop.getType() == stack.getType()) { if (drop.getDurability() == -1 || (drop.getDurability() == stack.getDurability())) { ItemStack finalDrop = this.drops.get(drop).getDrop(stack, this.random); if (finalDrop == null) event.setCancelled(true); else event.getEntity().setItemStack(finalDrop); break; } } } }
/** * Remove barrier on drop * * @param event Event */ @EventHandler public void onItemSpawn(ItemSpawnEvent event) { if (event.getEntityType() != EntityType.DROPPED_ITEM) return; if (event.getEntity().getItemStack().getType() == Material.BARRIER) event.setCancelled(true); }
/** * Replace world's drop by custom ones * * @param event Event */ @EventHandler public void onItemSpawn(ItemSpawnEvent event) { if (event.getEntityType() != EntityType.DROPPED_ITEM) return; if (Meta.hasMeta(event.getEntity().getItemStack())) return; if (!this.drops.containsKey(event.getEntity().getItemStack().getType())) return; event.getEntity().setItemStack(Meta.addMeta(this.drops.get(event.getEntity().getItemStack().getType()))); }
/** * Replace coal by torch * * @param event Event */ @EventHandler public void onItemSpawn(ItemSpawnEvent event) { if (event.getEntityType() != EntityType.DROPPED_ITEM) return; if (event.getEntity().hasMetadata("playerDrop")) return; if (event.getEntity().getItemStack().getType() == Material.COAL) event.getEntity().setItemStack(new ItemStack(Material.TORCH, (int) this.moduleConfiguration.get("torch"))); }
public FlexItem spawnItem( Location location, ItemStack itemStack ) { FlexItem item = new FlexItem( nextEntityId(), location, this ); item.setItemStack( itemStack ); if ( !EventFactory.call( new ItemSpawnEvent( item, location ) ).isCancelled() ) { this.addEntity( item, false ); } return item; }
@EventHandler public void onItemSpawn(ItemSpawnEvent event) { Item item = event.getEntity(); ItemStack stack = item.getItemStack(); World world = item.getWorld(); if (world.getEnvironment() != Environment.THE_END || stack.getType() != Material.DRAGON_EGG || stack.hasItemMeta()) return; DragonTemplate dragon = plugin.getDEDManager().getWorldWrapper(world).getActiveBattle(); DragonLoot loot = dragon.getLoot(); String eggName = loot.getEggName().replace("%dragon%", dragon.getName()); List<String> eggLore = loot.getEggLore().stream() .map(s -> s.replace("%dragon%", dragon.getName())) .collect(Collectors.toList()); ItemMeta eggMeta = stack.getItemMeta(); if (eggName != null && !eggName.isEmpty()) { eggMeta.setDisplayName(eggName); } if (eggLore != null && !eggLore.isEmpty()) { eggMeta.setLore(eggLore); } stack.setItemMeta(eggMeta); }
@EventHandler public void onItemSpawn(ItemSpawnEvent e) { if (e.isCancelled()) { return; } Item item = e.getEntity(); ItemStack is = item.getItemStack(); if (isMoneyItem(is)) { item.setCustomName(is.getItemMeta().getDisplayName()); item.setCustomNameVisible(true); } }
/** * Prevent items from spawning if they are in the item-remove tag in XML. * * @param event The event. */ @EventHandler(ignoreCancelled = true) public void onItemSpawn(ItemSpawnEvent event) { Match match = Cardinal.getMatch(event.getWorld()); MaterialData data = event.getEntity().getItemStack().getData(); for (MaterialType type : materials.get(match)) { if (type.isType(data)) { event.setCancelled(true); break; } } }
/** * Track the location of a pearl if it spawns as an item for any reason * @param e The event args */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onItemSpawn(ItemSpawnEvent e) { Item item = e.getEntity(); ExilePearl pearl = pearlApi.getPearlFromItemStack(item.getItemStack()); if (pearl == null) { return; } pearl.setHolder(item); }
/** * Removes the help item when dropped * @param e The event args */ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onHelpItemDrop(ItemSpawnEvent e) { if (isHelpItem(e.getEntity().getItemStack())) { e.setCancelled(true); } }
@EventHandler(priority = EventPriority.LOWEST) public void onItemSpawn(ItemSpawnEvent event) { //if in a creative world, cancel the event (don't drop items on the ground) if(GriefPrevention.instance.creativeRulesApply(event.getLocation())) { event.setCancelled(true); } }
@EventHandler(priority = EventPriority.MONITOR) public void onItemSpawn(ItemSpawnEvent event) { if (!data.getChestCache().isChestListEmpty() && event.getEntity() instanceof Item )//&& plugin.worldSet.contains(event.getEntity().getWorld().getName())) { for (Loc loc : data.getChestCache().getChestList()) { Location l = loc.toLocation(); if (event.getEntity().getLocation().getWorld().getName().equals(l.getWorld().getName()) && l.distanceSquared(event.getEntity().getLocation()) < 4) { ((Item) event.getEntity()).setPickupDelay(20); } } } }
@EventHandler(ignoreCancelled = true) public void onItemSpawnEvent(ItemSpawnEvent e) { plugin.tm.onArmourDrop(e); if (!e.isCancelled()) { if (plugin.rm.isInGame(e.getEntity().getWorld())) { if (plugin.rm.isProhibited(e.getEntity())) { e.setCancelled(true); } } } }
public void onArmourDrop(ItemSpawnEvent e) { List<String> lore = e.getEntity().getItemStack().getItemMeta().getLore(); if (lore == null) { return; } if (lore.contains(armourBrandName)) { e.setCancelled(true); } }
@Override public void onItemSpawn(ItemSpawnEvent event) { for (ItemComponent comp : this.components.values()) { comp.onItemSpawn(event); } }
@EventHandler public void onItemSpawn(ItemSpawnEvent event) { if ((event.getEntity().getItemStack().getType() == Material.SADDLE || event.getEntity().getItemStack().getType() == Material.IRON_BARDING || event.getEntity().getItemStack().getType() == Material.GOLD_BARDING || event.getEntity().getItemStack().getType() == Material.DIAMOND_BARDING) && this.DisableItemDrops == true) { // Workaround to prevent saddle/armor drops due to bukkit bug if (event.getEntity().getVelocity().getY() == 0.20000000298023224) { event.setCancelled(true); } } }
@EventHandler public void onItemSpawn(ItemSpawnEvent event) { if (removed.contains(event.getEntity().getItemStack().getType())) { event.setCancelled(true); } }
@EventHandler public void onItemSpawn(ItemSpawnEvent event) { if (event.getEntity().getItemStack() != null && event.getEntity().getItemStack().getType() == Material.LEASH) event.setCancelled(true); }
/** * Concentrate stacks * * @param event Event */ @EventHandler public void onItemSpawn(ItemSpawnEvent event) { if (event.getEntityType() != EntityType.DROPPED_ITEM) return; Item newEntity = event.getEntity(); List<Entity> entityList = newEntity.getNearbyEntities(this.radius, 1, this.radius); int maxSize = newEntity.getItemStack().getMaxStackSize(); for (Entity anEntityList : entityList) { if (anEntityList instanceof Item) { Item curEntity = (Item) anEntityList; if (!curEntity.isDead() && curEntity.getItemStack().getType().equals(newEntity.getItemStack().getType()) && curEntity.getItemStack().getData().getData() == newEntity.getItemStack().getData().getData() && curEntity.getItemStack().getDurability() == newEntity.getItemStack().getDurability() && Math.abs(curEntity.getLocation().getX() - newEntity.getLocation().getX()) <= this.radius && Math.abs(curEntity.getLocation().getY() - newEntity.getLocation().getY()) <= this.radius && Math.abs(curEntity.getLocation().getZ() - newEntity.getLocation().getZ()) <= this.radius) { int newAmount = newEntity.getItemStack().getAmount(); int curAmount = curEntity.getItemStack().getAmount(); int more = Math.min(newAmount, maxSize - curAmount); curAmount += more; newAmount -= more; curEntity.getItemStack().setAmount(curAmount); newEntity.getItemStack().setAmount(newAmount); if (newAmount <= 0) event.setCancelled(true); return; } } } }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onSpawn(ItemSpawnEvent e) { if (cm.isAntiNegativeItemDupe && e.getEntity() != null && e.getEntity().getItemStack() != null && e.getEntity().getItemStack().getAmount() <= 0) { e.setCancelled(true); } }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onItemSpawn(ItemSpawnEvent event) { if (this.isMatchIdle()) { event.setCancelled(true); } }