From 44b7676f177ad37d27280ec1264726846858ea2b Mon Sep 17 00:00:00 2001 From: Indyuce Date: Mon, 23 Dec 2019 22:11:33 +0100 Subject: [PATCH] !Update classes utilizing PlayerAttackEvent --- .../api/event/EntityKillEntityEvent.java | 31 ------------------- .../source/KillMobExperienceSource.java | 2 +- .../event/trigger/AttackEventTrigger.java | 2 +- .../mmocore/api/player/stats/StatType.java | 2 ++ .../api/quest/objective/KillMobObjective.java | 2 +- .../mmocore/skill/Empowered_Attack.java | 4 +-- .../java/net/Indyuce/mmocore/skill/Evade.java | 2 +- .../Indyuce/mmocore/skill/Fire_Berserker.java | 2 +- .../net/Indyuce/mmocore/skill/Power_Mark.java | 4 +-- .../Indyuce/mmocore/skill/Sneaky_Picky.java | 2 +- 10 files changed, 12 insertions(+), 41 deletions(-) delete mode 100644 src/main/java/net/Indyuce/mmocore/api/event/EntityKillEntityEvent.java diff --git a/src/main/java/net/Indyuce/mmocore/api/event/EntityKillEntityEvent.java b/src/main/java/net/Indyuce/mmocore/api/event/EntityKillEntityEvent.java deleted file mode 100644 index 2ff91e1e..00000000 --- a/src/main/java/net/Indyuce/mmocore/api/event/EntityKillEntityEvent.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.Indyuce.mmocore.api.event; - -import org.bukkit.entity.Entity; -import org.bukkit.event.HandlerList; -import org.bukkit.event.entity.EntityEvent; - -public class EntityKillEntityEvent extends EntityEvent { - private static final HandlerList handlers = new HandlerList(); - - private final Entity target; - - public EntityKillEntityEvent(Entity what, Entity target) { - super(what); - - this.target = target; - } - - public Entity getTarget() { - return target; - } - - @Override - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } - -} diff --git a/src/main/java/net/Indyuce/mmocore/api/experience/source/KillMobExperienceSource.java b/src/main/java/net/Indyuce/mmocore/api/experience/source/KillMobExperienceSource.java index 36091e32..9de885e4 100644 --- a/src/main/java/net/Indyuce/mmocore/api/experience/source/KillMobExperienceSource.java +++ b/src/main/java/net/Indyuce/mmocore/api/experience/source/KillMobExperienceSource.java @@ -8,12 +8,12 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import net.Indyuce.mmocore.MMOCore; -import net.Indyuce.mmocore.api.event.EntityKillEntityEvent; import net.Indyuce.mmocore.api.experience.Profession; import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.api.load.MMOLineConfig; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.manager.profession.ExperienceManager; +import net.mmogroup.mmolib.api.event.EntityKillEntityEvent; public class KillMobExperienceSource extends SpecificExperienceSource { public final EntityType type; diff --git a/src/main/java/net/Indyuce/mmocore/api/player/profess/event/trigger/AttackEventTrigger.java b/src/main/java/net/Indyuce/mmocore/api/player/profess/event/trigger/AttackEventTrigger.java index 808c4ad5..1b0d2f09 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/profess/event/trigger/AttackEventTrigger.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/profess/event/trigger/AttackEventTrigger.java @@ -21,7 +21,7 @@ public class AttackEventTrigger implements EventTriggerHandler { PlayerData player = event.getData().getMMOCore(); PlayerClass profess = player.getProfess(); - for (DamageType type : event.getAttackInfo().getTypes()) { + for (DamageType type : event.getAttack().getTypes()) { String path = type.getPath() + "-damage"; if (profess.hasEventTriggers(path)) profess.getEventTriggers(path).getTriggers().forEach(trigger -> trigger.apply(player)); diff --git a/src/main/java/net/Indyuce/mmocore/api/player/stats/StatType.java b/src/main/java/net/Indyuce/mmocore/api/player/stats/StatType.java index 0c4b7aaa..764be663 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/stats/StatType.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/stats/StatType.java @@ -32,6 +32,8 @@ public enum StatType { CRITICAL_STRIKE_CHANCE, CRITICAL_STRIKE_POWER, + SPELL_CRITICAL_STRIKE_CHANCE, + SPELL_CRITICAL_STRIKE_POWER, BLOCK_POWER, BLOCK_RATING, diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/objective/KillMobObjective.java b/src/main/java/net/Indyuce/mmocore/api/quest/objective/KillMobObjective.java index 8ad13d7f..ebdf7d40 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/objective/KillMobObjective.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/objective/KillMobObjective.java @@ -5,10 +5,10 @@ import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import net.Indyuce.mmocore.api.event.EntityKillEntityEvent; import net.Indyuce.mmocore.api.load.MMOLineConfig; import net.Indyuce.mmocore.api.quest.ObjectiveProgress; import net.Indyuce.mmocore.api.quest.QuestProgress; +import net.mmogroup.mmolib.api.event.EntityKillEntityEvent; public class KillMobObjective extends Objective { private final EntityType type; diff --git a/src/main/java/net/Indyuce/mmocore/skill/Empowered_Attack.java b/src/main/java/net/Indyuce/mmocore/skill/Empowered_Attack.java index f829b3f6..95a19eec 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Empowered_Attack.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Empowered_Attack.java @@ -100,7 +100,7 @@ public class Empowered_Attack extends Skill { target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, .5f); target.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, target.getLocation().add(0, target.getHeight() / 2, 0), 32, 0, 0, 0, .2); - double sweep = event.getDamage() * r; + double sweep = event.getAttack().getDamage() * r; Location src = target.getLocation().add(0, target.getHeight() / 2, 0); for (Entity entity : target.getNearbyEntities(rad, rad, rad)) @@ -113,7 +113,7 @@ public class Empowered_Attack extends Skill { * apply damage afterwards otherwise the damage dealt to nearby * entities scale with the extra ability damage. */ - event.setDamage(event.getDamage() * c); + event.getAttack().multiplyDamage(1 + c); } } } diff --git a/src/main/java/net/Indyuce/mmocore/skill/Evade.java b/src/main/java/net/Indyuce/mmocore/skill/Evade.java index 13d8af11..525c99c4 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Evade.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Evade.java @@ -65,7 +65,7 @@ public class Evade extends Skill { @EventHandler(priority = EventPriority.HIGHEST) public void b(PlayerAttackEvent event) { - if (event.isWeapon() && !event.isCancelled() && event.getData().equals(data)) + if (event.isWeapon() && !event.isCancelled() && event.getData().getMMOCore().equals(data)) close(); } diff --git a/src/main/java/net/Indyuce/mmocore/skill/Fire_Berserker.java b/src/main/java/net/Indyuce/mmocore/skill/Fire_Berserker.java index 06d98af1..d5acbaeb 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Fire_Berserker.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Fire_Berserker.java @@ -29,6 +29,6 @@ public class Fire_Berserker extends Skill implements Listener { public void a(PlayerAttackEvent event) { PlayerData data = event.getData().getMMOCore(); if (event.getPlayer().getFireTicks() > 0 && data.hasSkillUnlocked(this)) - event.setDamage(event.getDamage() * (1 + data.getProfess().getSkill(this).getModifier("extra", data.getSkillLevel(this)))); + event.getAttack().multiplyDamage(1 + data.getProfess().getSkill(this).getModifier("extra", data.getSkillLevel(this))); } } diff --git a/src/main/java/net/Indyuce/mmocore/skill/Power_Mark.java b/src/main/java/net/Indyuce/mmocore/skill/Power_Mark.java index 3366feab..32eafdcb 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Power_Mark.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Power_Mark.java @@ -88,8 +88,8 @@ public class Power_Mark extends Skill implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void stackDamage(PlayerAttackEvent event) { - if (!event.isCancelled() && j < 20 * (duration - 2) && radiusCheck(event.getEntity().getLocation()) && event.getData().equals(data)) { - accumulate += event.getDamage() * ratio; + if (!event.isCancelled() && j < 20 * (duration - 2) && radiusCheck(event.getEntity().getLocation()) && event.getData().getMMOCore().equals(data)) { + accumulate += event.getAttack().getDamage() * ratio; new ParabolicProjectile(event.getEntity().getLocation().add(0, event.getEntity().getHeight() / 2, 0), loc, () -> loc.getWorld().playSound(loc, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1), Color.PURPLE); } } diff --git a/src/main/java/net/Indyuce/mmocore/skill/Sneaky_Picky.java b/src/main/java/net/Indyuce/mmocore/skill/Sneaky_Picky.java index 6c80e62b..a226e511 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Sneaky_Picky.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Sneaky_Picky.java @@ -36,7 +36,7 @@ public class Sneaky_Picky extends Skill { data.cast(cast.getInfo()); - event.setDamage((1 + cast.getModifier("extra") / 100) * event.getDamage()); + event.getAttack().multiplyDamage(1 + cast.getModifier("extra") / 100); LivingEntity target = (LivingEntity) event.getEntity(); target.getWorld().spawnParticle(Particle.SMOKE_NORMAL, target.getLocation().add(0, target.getHeight() / 2, 0), 64, 0, 0, 0, .05); target.getWorld().playSound(target.getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, 2);