From 556515eefde184c5e71e9c1df6658a7f39169481 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Tue, 20 Oct 2020 09:43:44 +0100 Subject: [PATCH] Add SkillActivationPerkEvent --- pom.xml | 2 +- .../skills/SkillActivationPerkEvent.java | 49 +++++++++++++++++++ .../gmail/nossr50/util/skills/PerksUtils.java | 7 ++- 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/events/skills/SkillActivationPerkEvent.java diff --git a/pom.xml b/pom.xml index 77cb38b4a..a6c89b72a 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.166 + 2.1.167-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/events/skills/SkillActivationPerkEvent.java b/src/main/java/com/gmail/nossr50/events/skills/SkillActivationPerkEvent.java new file mode 100644 index 000000000..89c41dd6f --- /dev/null +++ b/src/main/java/com/gmail/nossr50/events/skills/SkillActivationPerkEvent.java @@ -0,0 +1,49 @@ +package com.gmail.nossr50.events.skills; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +public class SkillActivationPerkEvent extends Event { + + + + + private static final HandlerList handlers = new HandlerList(); + private final Player player; + private int ticks; + private final int maxTicks; + + public SkillActivationPerkEvent(Player player, int ticks, int maxTicks) { + + this.player = player; + this.ticks = ticks; + this.maxTicks = maxTicks; + } + + public Player getPlayer() { + return player; + } + + public int getTicks() { + return ticks; + } + + public void setTicks(int ticks) { + this.ticks = ticks; + } + + public int getMaxTicks() { + return maxTicks; + } + + @Override + public @NotNull HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java b/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java index 165008068..588b944e1 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java @@ -2,8 +2,11 @@ package com.gmail.nossr50.util.skills; import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.events.skills.SkillActivationPerkEvent; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; + +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -42,7 +45,9 @@ public final class PerksUtils { ticks += 4; } - return ticks; + final SkillActivationPerkEvent skillActivationPerkEvent = new SkillActivationPerkEvent(player, ticks, maxTicks); + Bukkit.getPluginManager().callEvent(skillActivationPerkEvent); + return skillActivationPerkEvent.getTicks(); } public static float handleXpPerks(Player player, float xp, PrimarySkillType skill) {