Added new PlayerLevelUpEvent API event
This commit is contained in:
1 parent
785151aa0f
commit
22e37f942f
2 files changed
+42
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package com.planetgallium.kitpvp.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerLevelUpEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private final int level;
|
||||
|
||||
private boolean isCancelled;
|
||||
|
||||
public PlayerLevelUpEvent(Player player, int level) {
|
||||
this.player = player;
|
||||
this.level = level;
|
||||
this.isCancelled = false;
|
||||
}
|
||||
|
||||
public Player getPlayer() { return player; }
|
||||
|
||||
public int getLevel() { return level; }
|
||||
|
||||
public HandlerList getHandlers() { return HANDLERS; }
|
||||
|
||||
public String getEventName() { return "PlayerLevelUpEvent"; }
|
||||
|
||||
public static HandlerList getHandlerList() { return HANDLERS; }
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() { return this.isCancelled; }
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean option) { this.isCancelled = option; }
|
||||
|
||||
}
|
||||
@@ -2,8 +2,10 @@ package com.planetgallium.kitpvp.game;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.planetgallium.kitpvp.api.PlayerLevelUpEvent;
|
||||
import com.planetgallium.kitpvp.util.Config;
|
||||
import com.planetgallium.kitpvp.util.Resources;
|
||||
import com.planetgallium.kitpvp.util.Toolkit;
|
||||
@@ -28,6 +30,7 @@ public class Levels {
|
||||
if (arena.getLevels().getExperience(p.getUniqueId()) >= resources.getLevels().getInt("Levels.General.Experience.Levelup")) {
|
||||
|
||||
arena.getLevels().levelUp(p);
|
||||
Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(p, this.getLevel(p.getUniqueId())));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user