From ad39c94773d450be98bacc1260609abe10c5dabf Mon Sep 17 00:00:00 2001 From: T00thpick1 Date: Tue, 14 May 2013 12:18:52 -0400 Subject: [PATCH] AbilityDeactivateEvent --- .../nossr50/datatypes/skills/SkillType.java | 10 +++++++++ .../McMMOPlayerAbilityDeactivateEvent.java | 22 +++++++++++++++++++ .../runnables/skills/AbilityDisableTask.java | 5 +++++ 3 files changed, 37 insertions(+) create mode 100644 src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityDeactivateEvent.java diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java index ac291a8e9..3cdbe89f4 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java @@ -144,4 +144,14 @@ public enum SkillType { public Color getRunescapeModeColor() { return runescapeColor; } + + public static SkillType byAbility(AbilityType ability) { + for (SkillType type : values()) { + if (type.getAbility() == ability) { + return type; + } + } + + return null; + } } diff --git a/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityDeactivateEvent.java b/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityDeactivateEvent.java new file mode 100644 index 000000000..41621c440 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityDeactivateEvent.java @@ -0,0 +1,22 @@ +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 McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerSkillEvent { + + private AbilityType ability; + + public McMMOPlayerAbilityDeactivateEvent(Player player, SkillType skill) { + super(player, skill); + this.ability = skill.getAbility(); + } + + public AbilityType getAbility() { + return ability; + } + +} diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java index aac9e8632..0026dfaea 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java @@ -7,6 +7,8 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.AbilityType; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.SkillUtils; @@ -44,6 +46,9 @@ public class AbilityDisableTask extends BukkitRunnable { break; } + McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, SkillType.byAbility(ability)); + mcMMO.p.getServer().getPluginManager().callEvent(event); + mcMMOPlayer.setAbilityMode(ability, false); mcMMOPlayer.setAbilityInformed(ability, false);