mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-28 00:55:29 +01:00
new triggers for passive skills
This commit is contained in:
parent
bc9b208fb2
commit
6358a09a40
@ -1,8 +1,8 @@
|
||||
package net.Indyuce.mmocore.api.player;
|
||||
|
||||
import io.lumine.mythic.lib.api.player.MMOPlayerData;
|
||||
import io.lumine.mythic.lib.player.CooldownInfo;
|
||||
import io.lumine.mythic.lib.player.CooldownMap;
|
||||
import io.lumine.mythic.lib.player.MMOPlayerData;
|
||||
import io.lumine.mythic.lib.player.cooldown.CooldownInfo;
|
||||
import io.lumine.mythic.lib.player.cooldown.CooldownMap;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||
import net.Indyuce.mmocore.api.Waypoint;
|
||||
@ -21,6 +21,7 @@ import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
import net.Indyuce.mmocore.api.quest.PlayerQuests;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.api.util.math.particle.SmallParticleEffect;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.MythicSkill;
|
||||
import net.Indyuce.mmocore.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.experience.PlayerProfessions;
|
||||
import net.Indyuce.mmocore.listener.SpellCast.SkillCasting;
|
||||
@ -757,6 +758,12 @@ public class PlayerData extends OfflinePlayerData {
|
||||
|
||||
// Update stats
|
||||
getStats().updateStats();
|
||||
|
||||
// Update skill triggers
|
||||
mmoData.unregisterSkillTriggers("MMOCorePassiveSkill");
|
||||
for (SkillInfo skill : getProfess().getSkills())
|
||||
if (skill.getSkill() instanceof MythicSkill && skill.getSkill().isPassive())
|
||||
mmoData.registerSkillTrigger(((MythicSkill) skill.getSkill()).toMythicLib());
|
||||
}
|
||||
|
||||
public boolean hasSkillBound(int slot) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.Indyuce.mmocore.api.player.stats;
|
||||
|
||||
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
||||
import io.lumine.mythic.lib.player.EquipmentSlot;
|
||||
import io.lumine.mythic.lib.api.stat.StatInstance;
|
||||
import io.lumine.mythic.lib.api.stat.StatMap;
|
||||
import io.lumine.mythic.lib.api.stat.modifier.ModifierSource;
|
||||
|
@ -190,7 +190,7 @@ public class MMOCoreUtils {
|
||||
* @return If the player can target the entity given the attack type (buff or attack)
|
||||
*/
|
||||
public static boolean canTarget(PlayerData player, Entity target, InteractionType interaction) {
|
||||
return target instanceof LivingEntity && MythicLib.plugin.getEntities().canTarget(player.getPlayer(), (LivingEntity) target, interaction);
|
||||
return target instanceof LivingEntity && MythicLib.plugin.getEntities().canTarget(player.getPlayer(), target, interaction);
|
||||
}
|
||||
|
||||
public static void heal(LivingEntity target, double value) {
|
||||
|
@ -1,6 +1,11 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.skill;
|
||||
package net.Indyuce.mmocore.comp.mythicmobs;
|
||||
|
||||
import io.lumine.mythic.lib.api.util.EnumUtils;
|
||||
import io.lumine.mythic.lib.player.cooldown.CooldownInfo;
|
||||
import io.lumine.mythic.lib.skill.metadata.TriggerMetadata;
|
||||
import io.lumine.mythic.lib.skill.trigger.PassiveSkill;
|
||||
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
||||
import io.lumine.mythic.lib.skill.trigger.TriggeredSkill;
|
||||
import io.lumine.xikage.mythicmobs.MythicMobs;
|
||||
import io.lumine.xikage.mythicmobs.adapters.AbstractEntity;
|
||||
import io.lumine.xikage.mythicmobs.adapters.AbstractLocation;
|
||||
@ -9,6 +14,11 @@ 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.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.IntegerLinearValue;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||
@ -27,9 +37,10 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MythicSkill extends Skill {
|
||||
public class MythicSkill extends Skill implements TriggeredSkill {
|
||||
private final io.lumine.xikage.mythicmobs.skills.Skill skill;
|
||||
private final Map<CheatType, Integer> antiCheat = new HashMap<>();
|
||||
private final PassiveSkill mythicLibSkill;
|
||||
|
||||
public MythicSkill(String id, FileConfiguration config) {
|
||||
super(id);
|
||||
@ -64,11 +75,12 @@ public class MythicSkill extends Skill {
|
||||
}
|
||||
|
||||
if (config.isString("passive-type")) {
|
||||
Optional<PassiveSkillType> passiveType = EnumUtils.getIfPresent(PassiveSkillType.class, config.getString("passive-type").toUpperCase());
|
||||
Optional<TriggerType> passiveType = EnumUtils.getIfPresent(TriggerType.class, config.getString("passive-type").toUpperCase());
|
||||
Validate.isTrue(passiveType.isPresent(), "Invalid passive skill type");
|
||||
setPassive();
|
||||
Bukkit.getPluginManager().registerEvents(passiveType.get().getHandler(this), MMOCore.plugin);
|
||||
}
|
||||
mythicLibSkill = new PassiveSkill("MMOCorePassiveSkill", passiveType.get(), this);
|
||||
} else
|
||||
mythicLibSkill = null;
|
||||
}
|
||||
|
||||
public Map<CheatType, Integer> getAntiCheat() {
|
||||
@ -79,6 +91,10 @@ public class MythicSkill extends Skill {
|
||||
return skill;
|
||||
}
|
||||
|
||||
public PassiveSkill toMythicLib() {
|
||||
return mythicLibSkill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkillMetadata whenCast(CasterMetadata caster, SkillInfo skill) {
|
||||
SkillMetadata cast = new SkillMetadata(caster, skill);
|
||||
@ -117,4 +133,68 @@ public class MythicSkill extends Skill {
|
||||
private LinearValue readLinearValue(ConfigurationSection section) {
|
||||
return section.getBoolean("int") ? new IntegerLinearValue(section) : new LinearValue(section);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(TriggerMetadata triggerMeta) {
|
||||
PlayerData playerData = PlayerData.get(triggerMeta.getAttack().getPlayer().getUniqueId());
|
||||
if (!playerData.getProfess().hasSkill(this))
|
||||
return;
|
||||
|
||||
// Check for Bukkit pre cast event
|
||||
Skill.SkillInfo skill = playerData.getProfess().getSkill(this);
|
||||
PlayerPreCastSkillEvent preEvent = new PlayerPreCastSkillEvent(playerData, skill);
|
||||
Bukkit.getPluginManager().callEvent(preEvent);
|
||||
if (preEvent.isCancelled())
|
||||
return;
|
||||
|
||||
// Gather MMOCore skill info
|
||||
CasterMetadata caster = new CasterMetadata(playerData);
|
||||
SkillMetadata cast = new SkillMetadata(caster, skill);
|
||||
if (!cast.isSuccessful())
|
||||
return;
|
||||
|
||||
// Gather MythicMobs skill info
|
||||
HashSet<AbstractEntity> targetEntities = new HashSet<>();
|
||||
HashSet<AbstractLocation> targetLocations = new HashSet<>();
|
||||
|
||||
// The only difference
|
||||
if (triggerMeta.getTarget() != null)
|
||||
targetEntities.add(BukkitAdapter.adapt(triggerMeta.getTarget()));
|
||||
|
||||
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.usable(skillMeta, SkillTrigger.CAST)) {
|
||||
cast.abort();
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable anticheat
|
||||
if (MMOCore.plugin.hasAntiCheat())
|
||||
MMOCore.plugin.antiCheatSupport.disableAntiCheat(caster.getPlayer(), antiCheat);
|
||||
|
||||
// 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.execute(skillMeta);
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new PlayerPostCastSkillEvent(playerData, skill, cast));
|
||||
}
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.skill;
|
||||
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.handlers.*;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
|
||||
|
||||
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.PassiveSkillHandler;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
|
||||
/**
|
||||
* 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(PlayerKillEntityEvent event) {
|
||||
castSkill(PlayerData.get(event.getPlayer()), event.getTarget());
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Used to handle passive skills which trigger when a player attacks another
|
||||
* entity
|
||||
*/
|
||||
public class PlayerAttackSkillHandler extends PassiveSkillHandler {
|
||||
public PlayerAttackSkillHandler(MythicSkill skill) {
|
||||
super(skill);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void event(PlayerAttackEvent event) {
|
||||
castSkill(PlayerData.get(event.getData().getUniqueId()), event.getEntity());
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
|
||||
|
||||
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.PassiveSkillHandler;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
/**
|
||||
* 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 && 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());
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Used to handle passive skills which trigger when a player takes damage
|
||||
*/
|
||||
public class PlayerDamageSkillHandler extends PassiveSkillHandler {
|
||||
public PlayerDamageSkillHandler(MythicSkill skill) {
|
||||
super(skill);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void event(EntityDamageEvent event) {
|
||||
if (event.getEntityType() == EntityType.PLAYER && PlayerData.has(event.getEntity().getUniqueId()))
|
||||
castSkill(PlayerData.get((Player) event.getEntity()));
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
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.PassiveSkillHandler;
|
||||
|
||||
/**
|
||||
* 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 event) {
|
||||
if (event.getEntityType() == EntityType.PLAYER && PlayerData.has(event.getEntity().getUniqueId()))
|
||||
castSkill(PlayerData.get((Player) event.getEntity()));
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
|
||||
|
||||
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.PassiveSkillHandler;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
/**
|
||||
* Used when a player logins
|
||||
*/
|
||||
public class PlayerLoginSkillHandler extends PassiveSkillHandler {
|
||||
public PlayerLoginSkillHandler(MythicSkill skill) {
|
||||
super(skill);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void event(PlayerLoginEvent event) {
|
||||
Schedulers.sync().runLater(() -> castSkill(PlayerData.get(event.getPlayer())), 50);
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Used to handle passive skills which trigger when a player shoots a bow
|
||||
*/
|
||||
public class ShootBowSkillHandler extends PassiveSkillHandler {
|
||||
public ShootBowSkillHandler(MythicSkill skill) {
|
||||
super(skill);
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigFile;
|
||||
import net.Indyuce.mmocore.skill.Skill;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.MythicSkill;
|
||||
|
||||
public class SkillManager {
|
||||
private final Map<String, Skill> skills = new LinkedHashMap<>();
|
||||
|
@ -1,12 +1,11 @@
|
||||
package net.Indyuce.mmocore.manager.data;
|
||||
|
||||
import io.lumine.mythic.lib.api.player.MMOPlayerData;
|
||||
import io.lumine.mythic.lib.player.MMOPlayerData;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.AsyncPlayerDataLoadEvent;
|
||||
import net.Indyuce.mmocore.api.event.PlayerDataLoadEvent;
|
||||
import net.Indyuce.mmocore.api.player.OfflinePlayerData;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.Indyuce.mmocore.skill;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
||||
import io.lumine.mythic.lib.player.EquipmentSlot;
|
||||
import io.lumine.mythic.lib.api.stat.StatMap;
|
||||
import io.lumine.mythic.lib.damage.AttackMetadata;
|
||||
import io.lumine.mythic.lib.damage.DamageMetadata;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.Indyuce.mmocore.skill;
|
||||
|
||||
import io.lumine.mythic.lib.player.CooldownObject;
|
||||
import io.lumine.mythic.lib.player.cooldown.CooldownObject;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.IntegerLinearValue;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.Indyuce.mmocore.skill.list;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
||||
import io.lumine.mythic.lib.player.EquipmentSlot;
|
||||
import io.lumine.mythic.lib.api.stat.StatMap;
|
||||
import io.lumine.mythic.lib.damage.DamageType;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
|
Loading…
Reference in New Issue
Block a user