diff --git a/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityActivateEvent.java b/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityActivateEvent.java new file mode 100644 index 000000000..9fe6e956c --- /dev/null +++ b/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityActivateEvent.java @@ -0,0 +1,32 @@ +package com.gmail.nossr50.events.skills.abilities; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent; + +public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerSkillEvent { + + private AbilityType abilityType; + private boolean cancelled; + + public McMMOPlayerAbilityActivateEvent(Player player, SkillType skill) { + super(player, skill); + abilityType = skill.getAbility(); + cancelled = false; + } + + public AbilityType getAbilityType() { + return abilityType; + } + + public boolean isCancelled() { + return cancelled; + } + + public void setCancelled(boolean value) { + this.cancelled = value; + } + +} diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index 6f733d8d9..192ffdec5 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -30,6 +30,7 @@ import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent; import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; +import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.runnables.skills.AbilityDisableTask; import com.gmail.nossr50.runnables.skills.ToolLowerTask; @@ -329,6 +330,13 @@ public class SkillUtils { } if (!mcMMOPlayer.getAbilityMode(ability) && cooldownOver(playerProfile.getSkillDATS(ability), ability.getCooldown(), player)) { + McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, type); + mcMMO.p.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + int ticks = PerksUtils.handleActivationPerks(player, 2 + (playerProfile.getSkillLevel(type) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks()); ParticleEffectUtils.playAbilityEnabledEffect(player);