mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 21:56:47 +01:00
62 lines
1.5 KiB
Java
62 lines
1.5 KiB
Java
package com.gmail.nossr50.events.experience;
|
|
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.Cancellable;
|
|
import org.bukkit.event.HandlerList;
|
|
import org.bukkit.event.player.PlayerEvent;
|
|
|
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
import com.gmail.nossr50.util.player.UserManager;
|
|
|
|
/**
|
|
* Generic event for mcMMO experience events.
|
|
*/
|
|
public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements Cancellable {
|
|
private boolean cancelled;
|
|
protected SkillType skill;
|
|
protected int skillLevel;
|
|
|
|
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
|
super(player);
|
|
this.skill = skill;
|
|
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
|
|
}
|
|
|
|
/**
|
|
* @return The skill involved in this event
|
|
*/
|
|
public SkillType getSkill() {
|
|
return skill;
|
|
}
|
|
|
|
/**
|
|
* @return The skill level of the skill involved in this event
|
|
*/
|
|
public int getSkillLevel() {
|
|
return skillLevel;
|
|
}
|
|
|
|
/** Following are required for Cancellable **/
|
|
@Override
|
|
public boolean isCancelled() {
|
|
return cancelled;
|
|
}
|
|
|
|
@Override
|
|
public void setCancelled(boolean cancelled) {
|
|
this.cancelled = cancelled;
|
|
}
|
|
|
|
/** Rest of file is required boilerplate for custom events **/
|
|
private static final HandlerList handlers = new HandlerList();
|
|
|
|
@Override
|
|
public HandlerList getHandlers() {
|
|
return handlers;
|
|
}
|
|
|
|
public static HandlerList getHandlerList() {
|
|
return handlers;
|
|
}
|
|
}
|