2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.skills;
|
|
|
|
|
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;
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
|
|
|
import com.gmail.nossr50.util.skills.PerksUtils;
|
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 {
|
|
|
|
protected McMMOPlayer mcMMOPlayer;
|
|
|
|
protected int activationChance;
|
2019-01-13 08:54:53 +01:00
|
|
|
protected PrimarySkillType skill;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2019-01-13 08:54:53 +01:00
|
|
|
public SkillManager(McMMOPlayer mcMMOPlayer, PrimarySkillType skill) {
|
2013-03-01 06:52:01 +01:00
|
|
|
this.mcMMOPlayer = mcMMOPlayer;
|
|
|
|
this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill);
|
|
|
|
this.skill = skill;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Player getPlayer() {
|
|
|
|
return mcMMOPlayer.getPlayer();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getSkillLevel() {
|
2013-10-29 16:02:57 +01:00
|
|
|
return mcMMOPlayer.getSkillLevel(skill);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2014-04-18 21:56:03 +02:00
|
|
|
public void applyXpGain(float xp, XPGainReason xpGainReason) {
|
|
|
|
mcMMOPlayer.beginXpGain(skill, xp, xpGainReason);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|