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);
}
}
}
}
}
}
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);
}
}
}
}
}
Aggregations