2012-03-27 07:09:28 +02:00
|
|
|
package com.gmail.nossr50.events.experience;
|
2012-03-27 05:01:51 +02:00
|
|
|
|
|
|
|
import org.bukkit.entity.Player;
|
2013-02-15 18:39:55 +01:00
|
|
|
import org.bukkit.event.Cancellable;
|
2012-03-27 05:01:51 +02:00
|
|
|
import org.bukkit.event.HandlerList;
|
|
|
|
import org.bukkit.event.player.PlayerEvent;
|
|
|
|
|
2013-01-30 17:53:51 +01:00
|
|
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
2013-02-08 13:04:26 +01:00
|
|
|
import com.gmail.nossr50.util.Users;
|
2012-03-27 05:01:51 +02:00
|
|
|
|
2012-04-01 04:20:35 +02:00
|
|
|
/**
|
|
|
|
* Generic event for mcMMO experience events.
|
|
|
|
*/
|
2013-02-15 18:39:55 +01:00
|
|
|
public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements Cancellable {
|
|
|
|
private boolean cancelled;
|
2012-03-27 05:01:51 +02:00
|
|
|
protected SkillType skill;
|
2012-03-27 06:14:20 +02:00
|
|
|
protected int skillLevel;
|
2012-03-27 05:01:51 +02:00
|
|
|
|
2013-01-26 23:01:55 +01:00
|
|
|
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
2012-03-27 05:01:51 +02:00
|
|
|
super(player);
|
|
|
|
this.skill = skill;
|
2013-02-08 13:04:26 +01:00
|
|
|
this.skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill);
|
2012-03-27 05:01:51 +02:00
|
|
|
}
|
|
|
|
|
2012-04-01 04:20:35 +02:00
|
|
|
/**
|
|
|
|
* @return The skill involved in this event
|
|
|
|
*/
|
2012-03-27 05:01:51 +02:00
|
|
|
public SkillType getSkill() {
|
|
|
|
return skill;
|
|
|
|
}
|
|
|
|
|
2012-04-01 04:20:35 +02:00
|
|
|
/**
|
|
|
|
* @return The skill level of the skill involved in this event
|
|
|
|
*/
|
2012-03-27 06:14:20 +02:00
|
|
|
public int getSkillLevel() {
|
|
|
|
return skillLevel;
|
|
|
|
}
|
|
|
|
|
2012-03-27 05:01:51 +02:00
|
|
|
/** Rest of file is required boilerplate for custom events **/
|
|
|
|
private static final HandlerList handlers = new HandlerList();
|
2012-04-01 04:20:35 +02:00
|
|
|
|
2012-03-27 05:01:51 +02:00
|
|
|
@Override
|
|
|
|
public HandlerList getHandlers() {
|
|
|
|
return handlers;
|
|
|
|
}
|
2012-04-01 04:20:35 +02:00
|
|
|
|
2012-03-27 05:01:51 +02:00
|
|
|
public static HandlerList getHandlerList() {
|
|
|
|
return handlers;
|
|
|
|
}
|
2013-02-15 18:39:55 +01:00
|
|
|
|
|
|
|
/** Following are required for Cancellable **/
|
|
|
|
@Override
|
|
|
|
public boolean isCancelled() {
|
|
|
|
return cancelled;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setCancelled(boolean cancelled) {
|
|
|
|
this.cancelled = cancelled;
|
|
|
|
}
|
2012-03-27 05:01:51 +02:00
|
|
|
}
|