diff --git a/src/main/java/net/Indyuce/mmocore/api/event/PlayerPostCastSkillEvent.java b/src/main/java/net/Indyuce/mmocore/api/event/PlayerPostCastSkillEvent.java new file mode 100644 index 00000000..88e59905 --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/api/event/PlayerPostCastSkillEvent.java @@ -0,0 +1,44 @@ +package net.Indyuce.mmocore.api.event; + +import org.bukkit.event.HandlerList; + +import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.api.skill.Skill.SkillInfo; +import net.Indyuce.mmocore.api.skill.SkillResult; + +public class PlayerPostCastSkillEvent extends PlayerDataEvent { + private static final HandlerList handlers = new HandlerList(); + + private final SkillInfo skill; + private final SkillResult result; + private final boolean successful; + + public PlayerPostCastSkillEvent(PlayerData playerData, SkillInfo skill, SkillResult result, boolean successful) { + super(playerData); + + this.skill = skill; + this.result = result; + this.successful = successful; + } + + public SkillInfo getCast() { + return skill; + } + + public SkillResult getResult() { + return result; + } + + public boolean wasSuccessful() { + return successful; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/net/Indyuce/mmocore/api/event/PlayerCastSkillEvent.java b/src/main/java/net/Indyuce/mmocore/api/event/PlayerPreCastSkillEvent.java similarity index 82% rename from src/main/java/net/Indyuce/mmocore/api/event/PlayerCastSkillEvent.java rename to src/main/java/net/Indyuce/mmocore/api/event/PlayerPreCastSkillEvent.java index f4265b95..b1665959 100644 --- a/src/main/java/net/Indyuce/mmocore/api/event/PlayerCastSkillEvent.java +++ b/src/main/java/net/Indyuce/mmocore/api/event/PlayerPreCastSkillEvent.java @@ -6,14 +6,14 @@ import org.bukkit.event.HandlerList; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.skill.Skill.SkillInfo; -public class PlayerCastSkillEvent extends PlayerDataEvent implements Cancellable { +public class PlayerPreCastSkillEvent extends PlayerDataEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private final SkillInfo skill; private boolean cancelled; - public PlayerCastSkillEvent(PlayerData playerData, SkillInfo skill) { + public PlayerPreCastSkillEvent(PlayerData playerData, SkillInfo skill) { super(playerData); this.skill = skill; 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 ac30fcc0..0bbf2803 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -25,9 +25,10 @@ import org.bukkit.scheduler.BukkitRunnable; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.ConfigMessage; import net.Indyuce.mmocore.api.Waypoint; -import net.Indyuce.mmocore.api.event.PlayerCastSkillEvent; import net.Indyuce.mmocore.api.event.PlayerExperienceGainEvent; import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent; +import net.Indyuce.mmocore.api.event.PlayerPostCastSkillEvent; +import net.Indyuce.mmocore.api.event.PlayerPreCastSkillEvent; import net.Indyuce.mmocore.api.event.PlayerRegenResourceEvent; import net.Indyuce.mmocore.api.experience.EXPSource; import net.Indyuce.mmocore.api.experience.PlayerProfessions; @@ -716,9 +717,9 @@ public class PlayerData extends OfflinePlayerData { public SkillResult cast(SkillInfo skill) { - PlayerCastSkillEvent event = new PlayerCastSkillEvent(this, skill); - Bukkit.getPluginManager().callEvent(event); - if (event.isCancelled()) + PlayerPreCastSkillEvent preEvent = new PlayerPreCastSkillEvent(this, skill); + Bukkit.getPluginManager().callEvent(preEvent); + if (preEvent.isCancelled()) return new SkillResult(this, skill, CancelReason.OTHER); /* @@ -739,6 +740,8 @@ public class PlayerData extends OfflinePlayerData { MMOCore.plugin.configManager.getSimpleMessage("casting.on-cooldown").send(getPlayer()); } + PlayerPostCastSkillEvent postEvent = new PlayerPostCastSkillEvent(this, skill, cast, false); + Bukkit.getPluginManager().callEvent(postEvent); return cast; } @@ -750,6 +753,8 @@ public class PlayerData extends OfflinePlayerData { giveMana(-cast.getManaCost()); } + PlayerPostCastSkillEvent postEvent = new PlayerPostCastSkillEvent(this, skill, cast, true); + Bukkit.getPluginManager().callEvent(postEvent); return cast; }