From 96ac7a9c00a7acc699da4073fdc5cce258a05c16 Mon Sep 17 00:00:00 2001 From: Rosenthalk0 Date: Fri, 23 Jun 2023 14:00:48 -0500 Subject: [PATCH] API method for leaveSkillCasting to fire event! --- .../mmocore/api/player/PlayerData.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index fb5c562d..b9347df0 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -1028,15 +1028,26 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD return Objects.requireNonNull(skillCasting, "Player not in casting mode"); } - public void leaveSkillCasting() { + /** + * API Method to leave casting mode and fire the PlayerExitCastingModeEvent + */ + public void leaveSkillCasting(){ + this.leaveSkillCasting(false); + } + + /** + * @param skipEvent Skip the PlayerExitCastingModeEvent + */ + public void leaveSkillCasting(boolean skipEvent) { Validate.isTrue(isCasting(), "Player not in casting mode"); - PlayerExitCastingModeEvent event = new PlayerExitCastingModeEvent(getPlayer()); - Bukkit.getPluginManager().callEvent(event); + if (!skipEvent) { + PlayerExitCastingModeEvent event = new PlayerExitCastingModeEvent(getPlayer()); + Bukkit.getPluginManager().callEvent(event); - if (event.isCancelled()){ - return; + if (event.isCancelled()) { + return; + } } - skillCasting.close(); this.skillCasting = null; setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE, 0); // Reset action bar