fixed passive skills

This commit is contained in:
Indyuce 2021-10-29 14:40:18 +02:00
parent f4551be1db
commit 9729a49b04
14 changed files with 287 additions and 206 deletions

View File

@ -842,8 +842,7 @@ public class PlayerData extends OfflinePlayerData {
MMOCore.plugin.configManager.getSimpleMessage("casting.on-cooldown").send(getPlayer());
}
PlayerPostCastSkillEvent postEvent = new PlayerPostCastSkillEvent(this, skill, cast);
Bukkit.getPluginManager().callEvent(postEvent);
Bukkit.getPluginManager().callEvent(new PlayerPostCastSkillEvent(this, skill, cast));
return cast;
}
@ -859,8 +858,7 @@ public class PlayerData extends OfflinePlayerData {
giveStamina(-cast.getStaminaCost(), PlayerResourceUpdateEvent.UpdateReason.SKILL_COST);
}
PlayerPostCastSkillEvent postEvent = new PlayerPostCastSkillEvent(this, skill, cast);
Bukkit.getPluginManager().callEvent(postEvent);
Bukkit.getPluginManager().callEvent(new PlayerPostCastSkillEvent(this, skill, cast));
return cast;
}

View File

@ -82,7 +82,7 @@ public class MythicSkill extends Skill {
@Override
public SkillMetadata whenCast(CasterMetadata caster, SkillInfo skill) {
SkillMetadata cast = new SkillMetadata(caster, skill);
if (!cast.isSuccessful() || isPassive())
if (isPassive() || !cast.isSuccessful())
return cast;
// Gather MythicMobs skill info
@ -101,7 +101,7 @@ public class MythicSkill extends Skill {
skillMeta.getVariables().putObject("MMOSkill", cast);
skillMeta.getVariables().putObject("MMOStatMap", caster.getStats());
// Yo is that me or the second argument is f***ing useless
// Yo is that me or the second argument is f***ing useless
if (this.skill.usable(skillMeta, SkillTrigger.CAST))
this.skill.execute(skillMeta);
else

View File

@ -1,65 +0,0 @@
package net.Indyuce.mmocore.comp.mythicmobs.skill;
import io.lumine.xikage.mythicmobs.adapters.AbstractEntity;
import io.lumine.xikage.mythicmobs.adapters.AbstractLocation;
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter;
import io.lumine.xikage.mythicmobs.mobs.GenericCaster;
import io.lumine.xikage.mythicmobs.skills.SkillCaster;
import io.lumine.xikage.mythicmobs.skills.SkillTrigger;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.skill.CasterMetadata;
import net.Indyuce.mmocore.skill.Skill;
import net.Indyuce.mmocore.skill.metadata.SkillMetadata;
import org.bukkit.entity.Entity;
import org.bukkit.event.Listener;
import java.util.HashSet;
public abstract class PassiveMythicSkillHandler implements Listener {
protected final MythicSkill skill;
/**
* Core class for all passive types
*/
protected PassiveMythicSkillHandler(MythicSkill skill) {
this.skill = skill;
}
public SkillMetadata castSkill(PlayerData data) {
return castSkill(data, null);
}
public SkillMetadata castSkill(PlayerData playerData, Entity target) {
if (!playerData.getProfess().hasSkill(skill))
return null;
Skill.SkillInfo skill = playerData.getProfess().getSkill(this.skill);
CasterMetadata caster = new CasterMetadata(playerData);
SkillMetadata cast = new SkillMetadata(caster, skill);
if (!cast.isSuccessful() || this.skill.isPassive())
return cast;
HashSet<AbstractEntity> targetEntities = new HashSet<>();
HashSet<AbstractLocation> targetLocations = new HashSet<>();
// The only difference
if (target != null)
targetEntities.add(BukkitAdapter.adapt(target));
AbstractEntity trigger = BukkitAdapter.adapt(caster.getPlayer());
SkillCaster skillCaster = new GenericCaster(trigger);
io.lumine.xikage.mythicmobs.skills.SkillMetadata skillMeta = new io.lumine.xikage.mythicmobs.skills.SkillMetadata(SkillTrigger.API, skillCaster, trigger, BukkitAdapter.adapt(caster.getPlayer().getEyeLocation()), targetEntities, targetLocations, 1);
// Disable anticheat
if (MMOCore.plugin.hasAntiCheat())
MMOCore.plugin.antiCheatSupport.disableAntiCheat(caster.getPlayer(), this.skill.getAntiCheat());
if (this.skill.getSkill().usable(skillMeta, SkillTrigger.API))
this.skill.getSkill().execute(skillMeta);
else
cast.abort();
return cast;
}
}

View File

@ -0,0 +1,123 @@
package net.Indyuce.mmocore.comp.mythicmobs.skill;
import io.lumine.mythic.lib.player.CooldownInfo;
import io.lumine.xikage.mythicmobs.adapters.AbstractEntity;
import io.lumine.xikage.mythicmobs.adapters.AbstractLocation;
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter;
import io.lumine.xikage.mythicmobs.mobs.GenericCaster;
import io.lumine.xikage.mythicmobs.skills.SkillCaster;
import io.lumine.xikage.mythicmobs.skills.SkillTrigger;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.event.PlayerPostCastSkillEvent;
import net.Indyuce.mmocore.api.event.PlayerPreCastSkillEvent;
import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.skill.CasterMetadata;
import net.Indyuce.mmocore.skill.Skill;
import net.Indyuce.mmocore.skill.metadata.SkillMetadata;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.event.Listener;
import java.util.HashSet;
public abstract class PassiveSkillHandler implements Listener {
protected final MythicSkill skill;
/**
* Core class for all passive types
*/
protected PassiveSkillHandler(MythicSkill skill) {
this.skill = skill;
}
/**
* Forces the player to cast the skill without a target
*
* @param playerData Player casting the skill
* @return Metadata of cast skill
*/
public SkillMetadata castSkill(PlayerData playerData) {
return castSkill(playerData, null);
}
/**
* Forces the player to cast the skill with a target
* <p>
* DRY ALERT
* This is a mere copy of the {@link PlayerData#cast(Skill.SkillInfo)} method
* yet there isn't any other solution since MMOCore skills do not support targets.
* The only way to make sure MythicMobs takes the event target into account is
* to rewrite everything
* <p>
* This will change in the future when Mythic and MMOCore skills finally merge
*
* @param playerData Player casting the skill
* @param target Skill target
* @return Metadata of cast skill
*/
public SkillMetadata castSkill(PlayerData playerData, Entity target) {
if (!playerData.getProfess().hasSkill(skill))
return null;
// Check for Bukkit pre cast event
Skill.SkillInfo skill = playerData.getProfess().getSkill(this.skill);
PlayerPreCastSkillEvent preEvent = new PlayerPreCastSkillEvent(playerData, skill);
Bukkit.getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled())
return new SkillMetadata(playerData, skill, SkillMetadata.CancelReason.OTHER);
// Gather MMOCore skill info
CasterMetadata caster = new CasterMetadata(playerData);
SkillMetadata cast = new SkillMetadata(caster, skill);
if (!cast.isSuccessful())
return cast;
// Gather MythicMobs skill info
HashSet<AbstractEntity> targetEntities = new HashSet<>();
HashSet<AbstractLocation> targetLocations = new HashSet<>();
// The only difference
if (target != null)
targetEntities.add(BukkitAdapter.adapt(target));
AbstractEntity trigger = BukkitAdapter.adapt(caster.getPlayer());
SkillCaster skillCaster = new GenericCaster(trigger);
io.lumine.xikage.mythicmobs.skills.SkillMetadata skillMeta = new io.lumine.xikage.mythicmobs.skills.SkillMetadata(SkillTrigger.API, skillCaster, trigger, BukkitAdapter.adapt(caster.getPlayer().getEyeLocation()), targetEntities, targetLocations, 1);
// Check if the MythicMobs skill can be cast
if (!this.skill.getSkill().usable(skillMeta, SkillTrigger.CAST)) {
cast.abort();
return cast;
}
// Disable anticheat
if (MMOCore.plugin.hasAntiCheat())
MMOCore.plugin.antiCheatSupport.disableAntiCheat(caster.getPlayer(), this.skill.getAntiCheat());
// Place cast skill info in a variable
skillMeta.getVariables().putObject("MMOSkill", cast);
skillMeta.getVariables().putObject("MMOStatMap", caster.getStats());
// Apply cooldown, mana and stamina costs
if (!playerData.noCooldown) {
// Cooldown
double flatCooldownReduction = Math.max(0, Math.min(1, playerData.getStats().getStat(StatType.COOLDOWN_REDUCTION) / 100));
CooldownInfo cooldownHandler = playerData.getCooldownMap().applyCooldown(cast.getSkill(), cast.getCooldown());
cooldownHandler.reduceInitialCooldown(flatCooldownReduction);
// Mana and stamina cost
playerData.giveMana(-cast.getManaCost(), PlayerResourceUpdateEvent.UpdateReason.SKILL_COST);
playerData.giveStamina(-cast.getStaminaCost(), PlayerResourceUpdateEvent.UpdateReason.SKILL_COST);
}
// Execute the MythicMobs skill
this.skill.getSkill().execute(skillMeta);
Bukkit.getPluginManager().callEvent(new PlayerPostCastSkillEvent(playerData, skill, cast));
return cast;
}
}

View File

@ -2,30 +2,66 @@ package net.Indyuce.mmocore.comp.mythicmobs.skill;
import net.Indyuce.mmocore.comp.mythicmobs.skill.handlers.*;
public enum PassiveSkillType {
PLAYER_ATTACK,
PLAYER_DAMAGE,
PLAYER_DAMAGE_BY_ENTITY,
PLAYER_DEATH,
PLAYER_KILL_ENTITY,
PLAYER_LOGIN,
SHOOT_BOW;
import java.util.function.Function;
public PassiveMythicSkillHandler getHandler(MythicSkill skill) {
if (this == PLAYER_ATTACK)
return new PlayerAttackSkillHandler(skill);
if (this == PLAYER_DAMAGE)
return new PlayerDamageSkillHandler(skill);
if (this == PLAYER_KILL_ENTITY)
return new EntityDeathSkillHandler(skill);
if (this == PLAYER_DAMAGE_BY_ENTITY)
return new PlayerDamageByEntitySkillHandler(skill);
if (this == PLAYER_DEATH)
return new PlayerDeathSkillHandler(skill);
if (this == SHOOT_BOW)
return new ShootBowSkillHandler(skill);
if (this == PLAYER_LOGIN)
return new PlayerLoginSkillHandler(skill);
throw new NullPointerException();
}
public enum PassiveSkillType {
/**
* Activates the skill when the player attacks something
* <p>
* Trigger target: The entity the player attacked
*/
PLAYER_ATTACK(skill -> new PlayerAttackSkillHandler(skill)),
/**
* Activates the skill when the player takes damage
* <p>
* Trigger target: The player
*/
PLAYER_DAMAGE(skill -> new PlayerDamageSkillHandler(skill)),
/**
* Activates the skill when the player takes damage from an entity
* <p>
* Trigger target: The entity that damaged the player
*/
PLAYER_DAMAGE_BY_ENTITY(skill -> new PlayerDamageByEntitySkillHandler(skill)),
/**
* Activates the skill when the player dies
* <p>
* Trigger target: The player
*/
PLAYER_DEATH(skill -> new PlayerDeathSkillHandler(skill)),
/**
* Activates the skill when a player kills an entity
* <p>
* Trigger target:The killed entity
*/
PLAYER_KILL_ENTITY(skill -> new EntityDeathSkillHandler(skill)),
/**
* Activates the skill when a player shoots an arrow from a bow
* <p>
* Trigger target: The arrow that was shot
*/
SHOOT_BOW(skill -> new ShootBowSkillHandler(skill)),
/**
* Activates the skill when a player logins
* <p>
* Trigger target: The player
*/
PLAYER_LOGIN(skill -> new PlayerLoginSkillHandler(skill));
private final Function<MythicSkill, PassiveSkillHandler> handler;
PassiveSkillType(Function<MythicSkill, PassiveSkillHandler> handler) {
this.handler = handler;
}
public PassiveSkillHandler getHandler(MythicSkill skill) {
return handler.apply(skill);
}
}

View File

@ -1,26 +1,23 @@
package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
import io.lumine.mythic.lib.api.event.EntityKillEntityEvent;
import io.lumine.mythic.lib.api.event.PlayerKillEntityEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveSkillHandler;
import org.bukkit.event.EventHandler;
public class EntityDeathSkillHandler extends PassiveMythicSkillHandler {
/**
* Used to handle passive skills which trigger when a player kills
* another entity
*/
public EntityDeathSkillHandler(MythicSkill skill) {
super(skill);
}
/**
* Used to handle passive skills which trigger when a player kills
* another entity
*/
public class EntityDeathSkillHandler extends PassiveSkillHandler {
public EntityDeathSkillHandler(MythicSkill skill) {
super(skill);
}
@EventHandler
private void event(EntityKillEntityEvent e) {
if (e.getEntity().getType() == EntityType.PLAYER)
castSkill(PlayerData.get((Player) e.getEntity()), e.getTarget());
}
@EventHandler
private void event(PlayerKillEntityEvent event) {
castSkill(PlayerData.get(event.getPlayer()), event.getTarget());
}
}

View File

@ -1,23 +1,22 @@
package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
import io.lumine.mythic.lib.api.event.PlayerAttackEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveSkillHandler;
import org.bukkit.event.EventHandler;
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
import io.lumine.mythic.lib.api.event.PlayerAttackEvent;
/**
* Used to handle passive skills which trigger when a player attacks another
* entity
*/
public class PlayerAttackSkillHandler extends PassiveSkillHandler {
public PlayerAttackSkillHandler(MythicSkill skill) {
super(skill);
}
public class PlayerAttackSkillHandler extends PassiveMythicSkillHandler {
/**
* Used to handle passive skills which trigger when a player attacks another
* entity
*/
public PlayerAttackSkillHandler(MythicSkill skill) {
super(skill);
}
@EventHandler
private void event(PlayerAttackEvent e) {
castSkill(PlayerData.get(e.getData().getUniqueId()), e.getEntity());
}
@EventHandler
private void event(PlayerAttackEvent event) {
castSkill(PlayerData.get(event.getData().getUniqueId()), event.getEntity());
}
}

View File

@ -4,24 +4,25 @@ import io.lumine.mythic.lib.comp.target.InteractionType;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveSkillHandler;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
public class PlayerDamageByEntitySkillHandler extends PassiveMythicSkillHandler {
/**
* Used to handle passive skills which trigger when a player takes damage
* from another entity
*/
public PlayerDamageByEntitySkillHandler(MythicSkill skill) {
super(skill);
}
/**
* Used to handle passive skills which trigger when a player takes damage
* from another entity
*/
public class PlayerDamageByEntitySkillHandler extends PassiveSkillHandler {
public PlayerDamageByEntitySkillHandler(MythicSkill skill) {
super(skill);
}
@EventHandler
private void a(EntityDamageByEntityEvent event) {
if (event.getEntity().getType() == EntityType.PLAYER && MMOCoreUtils.canTarget(PlayerData.get(event.getEntity().getUniqueId()), event.getDamager(), InteractionType.OFFENSE_SKILL))
castSkill(PlayerData.get((Player) event.getEntity()), event.getDamager());
}
@EventHandler
private void a(EntityDamageByEntityEvent event) {
if (event.getEntity().getType() == EntityType.PLAYER && PlayerData.has(event.getEntity().getUniqueId())
&& MMOCoreUtils.canTarget(PlayerData.get(event.getEntity().getUniqueId()), event.getDamager(), InteractionType.OFFENSE_SKILL))
castSkill(PlayerData.get((Player) event.getEntity()), event.getDamager());
}
}

View File

@ -1,25 +1,24 @@
package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveSkillHandler;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
/**
* Used to handle passive skills which trigger when a player takes damage
*/
public class PlayerDamageSkillHandler extends PassiveSkillHandler {
public PlayerDamageSkillHandler(MythicSkill skill) {
super(skill);
}
public class PlayerDamageSkillHandler extends PassiveMythicSkillHandler {
/**
* Used to handle passive skills which trigger when a player takes damage
*/
public PlayerDamageSkillHandler(MythicSkill skill) {
super(skill);
}
@EventHandler
private void event(EntityDamageEvent event) {
if (event.getEntityType() == EntityType.PLAYER && !event.getEntity().hasMetadata("NPC"))
castSkill(PlayerData.get((Player) event.getEntity()));
}
@EventHandler
private void event(EntityDamageEvent event) {
if (event.getEntityType() == EntityType.PLAYER && PlayerData.has(event.getEntity().getUniqueId()))
castSkill(PlayerData.get((Player) event.getEntity()));
}
}

View File

@ -7,19 +7,19 @@ import org.bukkit.event.entity.EntityDeathEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveSkillHandler;
public class PlayerDeathSkillHandler extends PassiveMythicSkillHandler {
/**
* Used to handle passive skills which trigger when a player dies
*/
/**
* Used to handle passive skills which trigger when a player dies
*/
public class PlayerDeathSkillHandler extends PassiveSkillHandler {
public PlayerDeathSkillHandler(MythicSkill skill) {
super(skill);
}
@EventHandler
private void event(EntityDeathEvent e) {
if (e.getEntityType() == EntityType.PLAYER)
castSkill(PlayerData.get((Player) e.getEntity()));
private void event(EntityDeathEvent event) {
if (event.getEntityType() == EntityType.PLAYER && PlayerData.has(event.getEntity().getUniqueId()))
castSkill(PlayerData.get((Player) event.getEntity()));
}
}

View File

@ -1,28 +1,22 @@
package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerLoginEvent;
import io.lumine.mythic.utils.Schedulers;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveSkillHandler;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerLoginEvent;
public class PlayerLoginSkillHandler extends PassiveMythicSkillHandler {
/**
* Used when a player logins
*
* @param skill
*/
/**
* Used when a player logins
*/
public class PlayerLoginSkillHandler extends PassiveSkillHandler {
public PlayerLoginSkillHandler(MythicSkill skill) {
super(skill);
}
@EventHandler
private void event(PlayerLoginEvent e){
Schedulers.sync().runLater(() -> {
castSkill(PlayerData.get( e.getPlayer()));
}, 50);
private void event(PlayerLoginEvent event) {
Schedulers.sync().runLater(() -> castSkill(PlayerData.get(event.getPlayer())), 50);
}
}

View File

@ -1,25 +1,24 @@
package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveSkillHandler;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
/**
* Used to handle passive skills which trigger when a player shoots a bow
*/
public class ShootBowSkillHandler extends PassiveSkillHandler {
public ShootBowSkillHandler(MythicSkill skill) {
super(skill);
}
public class ShootBowSkillHandler extends PassiveMythicSkillHandler {
/**
* Used to handle passive skills which trigger when a player shoots a bow
*/
public ShootBowSkillHandler(MythicSkill skill) {
super(skill);
}
@EventHandler
private void event(EntityShootBowEvent e) {
if(e.getEntity().getType() == EntityType.PLAYER)
castSkill(PlayerData.get((Player) e.getEntity()), e.getProjectile());
}
@EventHandler
private void event(EntityShootBowEvent event) {
if (event.getEntity().getType() == EntityType.PLAYER && PlayerData.has(event.getEntity().getUniqueId()))
castSkill(PlayerData.get((Player) event.getEntity()), event.getProjectile());
}
}

View File

@ -1,16 +1,15 @@
package net.Indyuce.mmocore.experience.source;
import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.mythic.lib.api.event.EntityKillEntityEvent;
import io.lumine.mythic.lib.api.event.PlayerKillEntityEvent;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser;
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -28,11 +27,10 @@ public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
public ExperienceSourceManager<KillMobExperienceSource> newManager() {
return new ExperienceSourceManager<KillMobExperienceSource>() {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void a(EntityKillEntityEvent event) {
public void a(PlayerKillEntityEvent event) {
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> {
if (event.getTarget().isDead() && event.getEntity() instanceof Player && !event.getEntity().hasMetadata("NPC")
&& !event.getTarget().hasMetadata("spawner_spawned")) {
PlayerData data = PlayerData.get((Player) event.getEntity());
if (event.getTarget().isDead() && !event.getTarget().hasMetadata("spawner_spawned")) {
PlayerData data = PlayerData.get(event.getPlayer());
for (KillMobExperienceSource source : getSources())
if (source.matches(data, event.getTarget()))

View File

@ -118,7 +118,9 @@ public class SkillMetadata implements MythicSkillInfo {
LOCKED,
/**
* Anything else
* Anything else, used for instance when MythicMobs
* skill conditions prevent the skill from casting or
* when the Bukkit pre cast event is cancelled
*/
OTHER;
}