Search in sources :

Example 1 with ExpDrop

use of com.alessiodp.parties.bukkit.players.objects.ExpDrop 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)

Example 2 with ExpDrop

use of com.alessiodp.parties.bukkit.players.objects.ExpDrop in project Parties by AlessioDP.

the class BukkitExpListener method onEntityDie.

@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityDie(EntityDeathEvent event) {
    if (BukkitConfigMain.ADDITIONAL_EXP_ENABLE && BukkitConfigMain.ADDITIONAL_EXP_DROP_ENABLE) {
        Entity killedEntity = event.getEntity();
        if (event.getEntity().getKiller() != null) {
            PartyPlayerImpl killer = plugin.getPlayerManager().getPlayer(event.getEntity().getKiller().getUniqueId());
            if (killer.isInParty()) {
                if (checkForMythicMobsHandler(event)) {
                    return;
                }
                int vanillaExp = 0;
                int skillapiExp = 0;
                if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_NORMAL)
                    vanillaExp = event.getDroppedExp();
                if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_SKILLAPI)
                    skillapiExp = (int) SkillAPIHandler.getExp(killedEntity);
                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 vanilla event if hooked
                    if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_NORMAL)
                        event.setDroppedExp(0);
                    // Remove exp drop from SkillAPI
                    if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_SKILLAPI)
                        SkillAPIHandler.fakeEntity(killedEntity);
                    plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_EXP_REMOVINGEXP, BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_NORMAL, BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_SKILLAPI), true);
                }
            }
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) ExpDrop(com.alessiodp.parties.bukkit.players.objects.ExpDrop) BukkitExpManager(com.alessiodp.parties.bukkit.parties.BukkitExpManager) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) EventHandler(org.bukkit.event.EventHandler)

Aggregations

BukkitExpManager (com.alessiodp.parties.bukkit.parties.BukkitExpManager)2 ExpDrop (com.alessiodp.parties.bukkit.players.objects.ExpDrop)2 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)2 Entity (org.bukkit.entity.Entity)2 EventHandler (org.bukkit.event.EventHandler)2 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 Player (org.bukkit.entity.Player)1