Search in sources :

Example 1 with SkillAPIDrop

use of io.lumine.xikage.mythicmobs.drops.droppables.SkillAPIDrop in project Parties by AlessioDP.

the class MythicMobsHandler method onMythicMobDeath.

@EventHandler
public void onMythicMobDeath(MythicMobLootDropEvent event) {
    if (active && event.getKiller() instanceof Player) {
        Entity killedEntity = event.getEntity();
        if (event.getKiller() != null) {
            PartyPlayerImpl killer = plugin.getPlayerManager().getPlayer(event.getKiller().getUniqueId());
            if (killer.isInParty()) {
                plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_EXP_MMHANDLING, event.getMobType().getInternalName(), killer.getName(), killer.getPlayerUUID().toString()), true);
                double vanillaExp = 0;
                double skillapiExp = 0;
                if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_NORMAL)
                    vanillaExp = event.getExp();
                if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_SKILLAPI) {
                    for (Drop drop : event.getDrops().getDrops()) {
                        if (drop instanceof SkillAPIDrop) {
                            skillapiExp += drop.getAmount();
                        }
                    }
                }
                ExpDrop drop = new ExpDrop(killer, killedEntity, vanillaExp, skillapiExp);
                boolean result = ((BukkitExpManager) plugin.getExpManager()).distributeExp(drop);
                if (result && BukkitConfigMain.ADDITIONAL_EXP_DROP_CONVERT_REMOVEREALEXP) {
                    // Remove exp from the event if hooked
                    if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_NORMAL) {
                        // Be sure that we are removing exp from intangible drops
                        for (Drop d : event.getDrops().getLootTableIntangible().values()) {
                            if (d instanceof ExperienceDrop) {
                                d.setAmount(0);
                            }
                        }
                        // Add it to an array list that contains a list of entities
                        // that we need to manually remove drop experience
                        mobsExperienceToSuppress.add(event.getEntity().getUniqueId());
                    }
                    // Remove skillapi exp from the event if hooked
                    if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_SKILLAPI) {
                        event.getDrops().getLootTableIntangible().remove(SkillAPIDrop.class);
                    }
                }
            }
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) SkillAPIDrop(io.lumine.xikage.mythicmobs.drops.droppables.SkillAPIDrop) ExpDrop(com.alessiodp.parties.bukkit.players.objects.ExpDrop) BukkitExpManager(com.alessiodp.parties.bukkit.parties.BukkitExpManager) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) ExperienceDrop(io.lumine.xikage.mythicmobs.drops.droppables.ExperienceDrop) ExpDrop(com.alessiodp.parties.bukkit.players.objects.ExpDrop) Drop(io.lumine.xikage.mythicmobs.drops.Drop) SkillAPIDrop(io.lumine.xikage.mythicmobs.drops.droppables.SkillAPIDrop) ExperienceDrop(io.lumine.xikage.mythicmobs.drops.droppables.ExperienceDrop) EventHandler(org.bukkit.event.EventHandler)

Aggregations

BukkitExpManager (com.alessiodp.parties.bukkit.parties.BukkitExpManager)1 ExpDrop (com.alessiodp.parties.bukkit.players.objects.ExpDrop)1 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)1 Drop (io.lumine.xikage.mythicmobs.drops.Drop)1 ExperienceDrop (io.lumine.xikage.mythicmobs.drops.droppables.ExperienceDrop)1 SkillAPIDrop (io.lumine.xikage.mythicmobs.drops.droppables.SkillAPIDrop)1 Entity (org.bukkit.entity.Entity)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1