Add SkillActivationPerkEvent

This commit is contained in:
Shane Freeder 2020-10-20 09:43:44 +01:00
parent 0466a28a5f
commit 556515eefd
3 changed files with 56 additions and 2 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.166</version>
<version>2.1.167-SNAPSHOT</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>

View File

@ -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;
}
}

View File

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