From 6358a09a40e51bd7eb564e3374c7fc8689a16d85 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Sun, 31 Oct 2021 12:09:25 +0100 Subject: [PATCH] new triggers for passive skills --- .../mmocore/api/player/PlayerData.java | 13 +- .../mmocore/api/player/stats/PlayerStats.java | 2 +- .../mmocore/api/util/MMOCoreUtils.java | 2 +- .../mythicmobs/{skill => }/MythicSkill.java | 90 ++++++++++++- .../mythicmobs/skill/PassiveSkillHandler.java | 123 ------------------ .../mythicmobs/skill/PassiveSkillType.java | 67 ---------- .../handlers/EntityDeathSkillHandler.java | 23 ---- .../handlers/PlayerAttackSkillHandler.java | 22 ---- .../PlayerDamageByEntitySkillHandler.java | 28 ---- .../handlers/PlayerDamageSkillHandler.java | 24 ---- .../handlers/PlayerDeathSkillHandler.java | 25 ---- .../handlers/PlayerLoginSkillHandler.java | 22 ---- .../skill/handlers/ShootBowSkillHandler.java | 24 ---- .../Indyuce/mmocore/manager/SkillManager.java | 2 +- .../manager/data/PlayerDataManager.java | 3 +- .../Indyuce/mmocore/skill/CasterMetadata.java | 2 +- .../java/net/Indyuce/mmocore/skill/Skill.java | 2 +- .../Indyuce/mmocore/skill/list/Fire_Rage.java | 2 +- 18 files changed, 102 insertions(+), 374 deletions(-) rename src/main/java/net/Indyuce/mmocore/comp/mythicmobs/{skill => }/MythicSkill.java (54%) delete mode 100644 src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/PassiveSkillHandler.java delete mode 100644 src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/PassiveSkillType.java delete mode 100644 src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/EntityDeathSkillHandler.java delete mode 100644 src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerAttackSkillHandler.java delete mode 100644 src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerDamageByEntitySkillHandler.java delete mode 100644 src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerDamageSkillHandler.java delete mode 100644 src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerDeathSkillHandler.java delete mode 100644 src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerLoginSkillHandler.java delete mode 100644 src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/ShootBowSkillHandler.java diff --git a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 58a53112..a55d6d27 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -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) { diff --git a/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java b/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java index 9f9438f3..a0be9d26 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/stats/PlayerStats.java @@ -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; diff --git a/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java b/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java index 4e695144..33701be5 100644 --- a/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java +++ b/src/main/java/net/Indyuce/mmocore/api/util/MMOCoreUtils.java @@ -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) { diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/MythicSkill.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicSkill.java similarity index 54% rename from src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/MythicSkill.java rename to src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicSkill.java index 1d2d5069..1d862301 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/MythicSkill.java +++ b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicSkill.java @@ -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 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 passiveType = EnumUtils.getIfPresent(PassiveSkillType.class, config.getString("passive-type").toUpperCase()); + Optional 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 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 targetEntities = new HashSet<>(); + HashSet 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)); + } } diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/PassiveSkillHandler.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/PassiveSkillHandler.java deleted file mode 100644 index 05b6e023..00000000 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/PassiveSkillHandler.java +++ /dev/null @@ -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 - *

- * 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 - *

- * 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 targetEntities = new HashSet<>(); - HashSet 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; - } -} diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/PassiveSkillType.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/PassiveSkillType.java deleted file mode 100644 index dbbeb0c4..00000000 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/PassiveSkillType.java +++ /dev/null @@ -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 - *

- * Trigger target: The entity the player attacked - */ - PLAYER_ATTACK(skill -> new PlayerAttackSkillHandler(skill)), - - /** - * Activates the skill when the player takes damage - *

- * Trigger target: The player - */ - PLAYER_DAMAGE(skill -> new PlayerDamageSkillHandler(skill)), - - /** - * Activates the skill when the player takes damage from an entity - *

- * Trigger target: The entity that damaged the player - */ - PLAYER_DAMAGE_BY_ENTITY(skill -> new PlayerDamageByEntitySkillHandler(skill)), - - /** - * Activates the skill when the player dies - *

- * Trigger target: The player - */ - PLAYER_DEATH(skill -> new PlayerDeathSkillHandler(skill)), - - /** - * Activates the skill when a player kills an entity - *

- * Trigger target:The killed entity - */ - PLAYER_KILL_ENTITY(skill -> new EntityDeathSkillHandler(skill)), - - /** - * Activates the skill when a player shoots an arrow from a bow - *

- * Trigger target: The arrow that was shot - */ - SHOOT_BOW(skill -> new ShootBowSkillHandler(skill)), - - /** - * Activates the skill when a player logins - *

- * Trigger target: The player - */ - PLAYER_LOGIN(skill -> new PlayerLoginSkillHandler(skill)); - - private final Function handler; - - PassiveSkillType(Function handler) { - this.handler = handler; - } - - public PassiveSkillHandler getHandler(MythicSkill skill) { - return handler.apply(skill); - } -} diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/EntityDeathSkillHandler.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/EntityDeathSkillHandler.java deleted file mode 100644 index 71275bb3..00000000 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/EntityDeathSkillHandler.java +++ /dev/null @@ -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()); - } -} diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerAttackSkillHandler.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerAttackSkillHandler.java deleted file mode 100644 index a391c0b4..00000000 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerAttackSkillHandler.java +++ /dev/null @@ -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()); - } -} \ No newline at end of file diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerDamageByEntitySkillHandler.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerDamageByEntitySkillHandler.java deleted file mode 100644 index 3bed526b..00000000 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerDamageByEntitySkillHandler.java +++ /dev/null @@ -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()); - } -} diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerDamageSkillHandler.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerDamageSkillHandler.java deleted file mode 100644 index bbb85f1c..00000000 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerDamageSkillHandler.java +++ /dev/null @@ -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())); - } -} diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerDeathSkillHandler.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerDeathSkillHandler.java deleted file mode 100644 index 3e804444..00000000 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerDeathSkillHandler.java +++ /dev/null @@ -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())); - } -} diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerLoginSkillHandler.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerLoginSkillHandler.java deleted file mode 100644 index bddf32ef..00000000 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/PlayerLoginSkillHandler.java +++ /dev/null @@ -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); - } -} diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/ShootBowSkillHandler.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/ShootBowSkillHandler.java deleted file mode 100644 index 80ab0fb8..00000000 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/skill/handlers/ShootBowSkillHandler.java +++ /dev/null @@ -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()); - } -} diff --git a/src/main/java/net/Indyuce/mmocore/manager/SkillManager.java b/src/main/java/net/Indyuce/mmocore/manager/SkillManager.java index 9f3b5f1c..7a2ef6f4 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/SkillManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/SkillManager.java @@ -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 skills = new LinkedHashMap<>(); diff --git a/src/main/java/net/Indyuce/mmocore/manager/data/PlayerDataManager.java b/src/main/java/net/Indyuce/mmocore/manager/data/PlayerDataManager.java index 067e870f..27294614 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/data/PlayerDataManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/data/PlayerDataManager.java @@ -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; diff --git a/src/main/java/net/Indyuce/mmocore/skill/CasterMetadata.java b/src/main/java/net/Indyuce/mmocore/skill/CasterMetadata.java index 573a092b..f29f303e 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/CasterMetadata.java +++ b/src/main/java/net/Indyuce/mmocore/skill/CasterMetadata.java @@ -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; diff --git a/src/main/java/net/Indyuce/mmocore/skill/Skill.java b/src/main/java/net/Indyuce/mmocore/skill/Skill.java index 9bfe13f5..68889ee4 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Skill.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Skill.java @@ -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; diff --git a/src/main/java/net/Indyuce/mmocore/skill/list/Fire_Rage.java b/src/main/java/net/Indyuce/mmocore/skill/list/Fire_Rage.java index ca3e5b66..c3403522 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/list/Fire_Rage.java +++ b/src/main/java/net/Indyuce/mmocore/skill/list/Fire_Rage.java @@ -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;