@EventHandler public void mobKilled(EntityDeathEvent event) { if (type != ItemDropType.MOBKILL) return; dB.echoDebug("...checking kill"); if (event.getEntity().getKiller() != player.getPlayerEntity()) return; dB.echoDebug("...killed by player"); if (event.getEntity().getType() != mob) return; dB.echoDebug("...proper mob"); if (location != null) { if (location.distance(player.getPlayerEntity().getLocation()) > radius) return; } dB.echoDebug("...within range"); if (region != null) { if (!WorldGuardUtilities.inRegion(player.getPlayerEntity().getLocation(), region)) return; } dB.echoDebug("...within region"); dB.echoDebug("...trying to drop item"); if (Utilities.getRandom().nextInt(101) < dropRate) { dB.echoDebug("...item should drop now"); event.getEntity().getWorld().dropItem(event.getEntity().getLocation(), item); qtyDropped++; dB.echoDebug("...item dropped"); check(); } }
@EventHandler public void blockPlaced(BlockPlaceEvent event) { if (type != ItemDropType.BLOCKPLACE) return; dB.echoDebug("...checking blockplaceevent"); if (event.getPlayer() != player.getPlayerEntity()) return; dB.echoDebug("...placed by player"); if (event.getBlock().getType() != block) return; dB.echoDebug("...proper block placed"); if (location != null) { if (location.distance(player.getPlayerEntity().getLocation()) > radius) return; } dB.echoDebug("...within range"); if (region != null) { if (!WorldGuardUtilities.inRegion(player.getPlayerEntity().getLocation(), region)) return; } dB.echoDebug("...within region"); if (Utilities.getRandom().nextInt(101) < dropRate) { event.getBlock().getWorld().dropItem(event.getBlock().getLocation(), item); qtyDropped++; dB.echoDebug("...item dropped"); check(); } }