@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); }
/** * Returns a list of Traits the Player has. <br> * This excludes ones that are out of his level range. * * @return reduced Trait list. */ public List<Trait> getTraits() { int level = getLevelManager().getCurrentLevel(); List<Trait> returnList = new LinkedList<Trait>(); Set<Trait> traits = TraitHolderCombinder.getSkillTreeReducedTraitsOfPlayer(this); for (Trait trait : traits) { if (trait instanceof StaticTrait) continue; if (trait instanceof TraitWithRestrictions) { if (((TraitWithRestrictions) trait).isInLevelRange(level)) { returnList.add(trait); } } } return returnList; }