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) {