@EventHandler(priority = EventPriority.LOW) public void monsterDied(EntityDeathEvent event) { if (item == null) return; LivingEntity died = event.getEntity(); if (died == null) return; Player killer = died.getKiller(); if (killer == null) return; RaCPlayer racKiller = RaCPlayerManager.get().getPlayer(killer); if (racKiller == null) return; // Check for the name. if (!neededName.isEmpty()) { String monsterName = ChatColor.stripColor(died.getCustomName()); if (!neededName.equalsIgnoreCase(monsterName)) return; } // If not in this trait -> break. if (!TraitHolderCombinder.checkContainer(racKiller, this)) return; EventWrapper wrapper = EventWrapperFactory.buildOnlyWithplayer(racKiller); boolean canBeTriggered = super.checkRestrictions(wrapper) == TraitRestriction.None; if (!canBeTriggered) return; ItemStack drop = playerKilled(died.getType()); event.getDrops().add(drop); }
@Override protected boolean onHitEntity(EntityDamageByEntityEvent event) { Entity hitTarget = event.getEntity(); if (!(hitTarget instanceof LivingEntity)) return false; if (EnemyChecker.areAllies(event.getDamager(), hitTarget)) return false; Entity damager = event.getDamager(); if (damager instanceof Arrow) damager = (Entity) CompatibilityModifier.Shooter.getShooter((Projectile) damager); if (!(damager instanceof Player)) return false; RaCPlayer shooter = RaCPlayerManager.get().getPlayer((Player) damager); double totalDamage = modifyToPlayer(shooter, this.totalDamage, "totalDamage") / duration; DotBuilder builder = new DotBuilder(getName(), RaCPlayerManager.get().getPlayer(shooter)) .setDamageEverySecond() .setDamageType(DamageType.POISON) .setTotalDamage(totalDamage) .setTotalTimeInSeconds(this.duration); return DotAPI.addDot((LivingEntity) hitTarget, builder); }