Java Code Examples for org.bukkit.event.entity.EntityDeathEvent#getDroppedExp()
The following examples show how to use
org.bukkit.event.entity.EntityDeathEvent#getDroppedExp() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityListener.java From Guilds with MIT License | 5 votes |
/** * Handles extra XP dropped from mobs * * @param event */ @EventHandler public void onMobDeath(EntityDeathEvent event) { if (!(event.getEntity() instanceof Monster)) return; Monster monster = (Monster) event.getEntity(); Player killer = monster.getKiller(); if (killer == null) return; Guild guild = guildHandler.getGuild(killer); if (guild == null) { return; } double xp = event.getDroppedExp(); double multiplier = guild.getTier().getMobXpMultiplier(); event.setDroppedExp((int) Math.round(xp * multiplier)); }
Example 2
Source File: BukkitExpListener.java From Parties with GNU Affero General Public License v3.0 | 5 votes |
@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.getPartyName().isEmpty()) { if (checkForMythicMobsHandler(event)) { return; } double vanillaExp = 0; double skillapiExp = 0; if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_NORMAL) vanillaExp = event.getDroppedExp(); if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_SKILLAPI) skillapiExp = SkillAPIHandler.getExp(killedEntity); ExpDrop drop = new ExpDrop((int) vanillaExp, (int) skillapiExp, killer, killedEntity); boolean result = 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(PartiesConstants.DEBUG_EXP_REMOVINGEXP .replace("{value1}", Boolean.toString(BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_NORMAL)) .replace("{value2}", Boolean.toString(BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_SKILLAPI)), true); } } } } }
Example 3
Source File: BukkitExpListener.java From Parties with GNU Affero General Public License v3.0 | 5 votes |
/** * Used to hook into Mythic Mobs mobs handling * necessary to completely remove exp from the mob * * @return Returns true to cancel main event */ private boolean checkForMythicMobsHandler(EntityDeathEvent event) { boolean ret = false; if (BukkitConfigMain.ADDITIONAL_EXP_DROP_ADDITIONAL_MYTHICMOBS_ENABLE) { if (MythicMobsHandler.isMythicMob(event.getEntity())) { // Mythic Mob // Remove experience of mobs if handled by MythicMobHandler if (BukkitConfigMain.ADDITIONAL_EXP_DROP_CONVERT_REMOVEREALEXP && BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_NORMAL && event.getDroppedExp() > 0 && MythicMobsHandler.getMobsExperienceToSuppress().remove(event.getEntity().getUniqueId())) { // We already know that the killer is a Player // Remove entity experience if the event has been handled by MythicMobHandler // This is a workaround to fix MythicMobs exp drop bug event.setDroppedExp(0); } plugin.getLoggerManager().logDebug(PartiesConstants.DEBUG_EXP_MMBYPASS, true); // MythicMobHandler will handle this event ret = true; } else { // Non Mythic Mob if (BukkitConfigMain.ADDITIONAL_EXP_DROP_ADDITIONAL_MYTHICMOBS_HANDLEONLYMMMOBS) { // Return after this method ends ret = true; } } } return ret; }
Example 4
Source File: DefaultDropsHandler.java From EliteMobs with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onDeath(EntityDeathEvent event) { if (!EntityTracker.isEliteMob(event.getEntity())) return; if (!EntityTracker.isNaturalEntity(event.getEntity()) && !ConfigValues.itemsDropSettingsConfig.getBoolean(ItemsDropSettingsConfig.SPAWNER_DEFAULT_LOOT_MULTIPLIER)) return; List<ItemStack> droppedItems = event.getDrops(); int mobLevel = (int) (EntityTracker.getEliteMobEntity(event.getEntity()).getLevel() * ConfigValues.itemsDropSettingsConfig.getDouble(ItemsDropSettingsConfig.DEFAULT_LOOT_MULTIPLIER)); if (mobLevel > ConfigValues.itemsDropSettingsConfig.getInt(ItemsDropSettingsConfig.MAXIMUM_LEVEL_FOR_LOOT_MULTIPLIER)) mobLevel = ConfigValues.itemsDropSettingsConfig.getInt(ItemsDropSettingsConfig.MAXIMUM_LEVEL_FOR_LOOT_MULTIPLIER); inventoryItemsConstructor(event.getEntity()); for (ItemStack itemStack : droppedItems) { // ItemStack can be null for some reason, probably due to other plugins if (itemStack == null) continue; boolean itemIsWorn = false; for (ItemStack wornItem : wornItems) if (wornItem.isSimilar(itemStack)) itemIsWorn = true; if (!itemIsWorn) for (int i = 0; i < mobLevel * 0.1; i++) event.getEntity().getLocation().getWorld().dropItem(event.getEntity().getLocation(), itemStack); } mobLevel = (int) (EntityTracker.getEliteMobEntity(event.getEntity()).getLevel() * ConfigValues.itemsDropSettingsConfig.getDouble(ItemsDropSettingsConfig.EXPERIENCE_LOOT_MULTIPLIER)); int droppedXP = (int) (event.getDroppedExp() + event.getDroppedExp() * 0.1 * mobLevel); event.setDroppedExp(0); event.getEntity().getWorld().spawn(event.getEntity().getLocation(), ExperienceOrb.class).setExperience(droppedXP); }