2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.skills;
|
|
|
|
|
2019-01-28 03:11:51 +01:00
|
|
|
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
|
|
|
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
2019-01-13 08:54:53 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
2014-04-18 21:56:03 +02:00
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
2013-03-01 06:52:01 +01:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
public abstract class SkillManager {
|
2020-11-10 01:46:52 +01:00
|
|
|
protected McMMOPlayer mmoPlayer;
|
2019-01-13 08:54:53 +01:00
|
|
|
protected PrimarySkillType skill;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2020-11-10 01:46:52 +01:00
|
|
|
public SkillManager(McMMOPlayer mmoPlayer, PrimarySkillType skill) {
|
|
|
|
this.mmoPlayer = mmoPlayer;
|
2013-03-01 06:52:01 +01:00
|
|
|
this.skill = skill;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Player getPlayer() {
|
2020-11-10 01:46:52 +01:00
|
|
|
return mmoPlayer.getPlayer();
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getSkillLevel() {
|
2020-11-10 01:46:52 +01:00
|
|
|
return mmoPlayer.getSkillLevel(skill);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2019-01-28 03:11:51 +01:00
|
|
|
/**
|
|
|
|
* Applies XP to a player, provides SELF as an XpGainSource source
|
|
|
|
* @param xp amount of XP to apply
|
|
|
|
* @param xpGainReason the reason for the XP gain
|
|
|
|
* @deprecated use applyXpGain(float, XPGainReason, XPGainSource)
|
|
|
|
*/
|
|
|
|
@Deprecated
|
2014-04-18 21:56:03 +02:00
|
|
|
public void applyXpGain(float xp, XPGainReason xpGainReason) {
|
2020-11-10 01:46:52 +01:00
|
|
|
mmoPlayer.beginXpGain(skill, xp, xpGainReason, XPGainSource.SELF);
|
2019-01-28 03:11:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Applies XP to a player
|
|
|
|
* @param xp amount of XP to apply
|
|
|
|
* @param xpGainReason the reason for the XP gain
|
|
|
|
* @param xpGainSource the source of the XP
|
|
|
|
*/
|
|
|
|
public void applyXpGain(float xp, XPGainReason xpGainReason, XPGainSource xpGainSource) {
|
2020-11-10 01:46:52 +01:00
|
|
|
mmoPlayer.beginXpGain(skill, xp, xpGainReason, xpGainSource);
|
2014-04-18 21:56:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public XPGainReason getXPGainReason(LivingEntity target, Entity damager) {
|
|
|
|
return (damager instanceof Player && target instanceof Player) ? XPGainReason.PVP : XPGainReason.PVE;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|