mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 08:36:45 +01:00
Wrap these inside McMMOPlayer for easier access.
This commit is contained in:
parent
a8d1376533
commit
97b9214d6e
@ -50,34 +50,34 @@ public final class AbilityAPI {
|
||||
}
|
||||
|
||||
public static void resetCooldowns(Player player) {
|
||||
UserManager.getPlayer(player).getProfile().resetCooldowns();
|
||||
UserManager.getPlayer(player).resetCooldowns();
|
||||
}
|
||||
|
||||
public static void setBerserkCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setAbilityDATS(AbilityType.BERSERK, cooldown);
|
||||
UserManager.getPlayer(player).setAbilityDATS(AbilityType.BERSERK, cooldown);
|
||||
}
|
||||
|
||||
public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setAbilityDATS(AbilityType.GIGA_DRILL_BREAKER, cooldown);
|
||||
UserManager.getPlayer(player).setAbilityDATS(AbilityType.GIGA_DRILL_BREAKER, cooldown);
|
||||
}
|
||||
|
||||
public static void setGreenTerraCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setAbilityDATS(AbilityType.GREEN_TERRA, cooldown);
|
||||
UserManager.getPlayer(player).setAbilityDATS(AbilityType.GREEN_TERRA, cooldown);
|
||||
}
|
||||
|
||||
public static void setSerratedStrikesCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setAbilityDATS(AbilityType.SERRATED_STRIKES, cooldown);
|
||||
UserManager.getPlayer(player).setAbilityDATS(AbilityType.SERRATED_STRIKES, cooldown);
|
||||
}
|
||||
|
||||
public static void setSkullSplitterCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setAbilityDATS(AbilityType.SKULL_SPLITTER, cooldown);
|
||||
UserManager.getPlayer(player).setAbilityDATS(AbilityType.SKULL_SPLITTER, cooldown);
|
||||
}
|
||||
|
||||
public static void setSuperBreakerCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setAbilityDATS(AbilityType.SUPER_BREAKER, cooldown);
|
||||
UserManager.getPlayer(player).setAbilityDATS(AbilityType.SUPER_BREAKER, cooldown);
|
||||
}
|
||||
|
||||
public static void setTreeFellerCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setAbilityDATS(AbilityType.TREE_FELLER, cooldown);
|
||||
UserManager.getPlayer(player).setAbilityDATS(AbilityType.TREE_FELLER, cooldown);
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ public final class ExperienceAPI {
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getXP(Player player, String skillType) {
|
||||
return UserManager.getPlayer(player).getProfile().getSkillXpLevel(getNonChildSkillType(skillType));
|
||||
return UserManager.getPlayer(player).getSkillXpLevel(getNonChildSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,7 +217,7 @@ public final class ExperienceAPI {
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static float getXPRaw(Player player, String skillType) {
|
||||
return UserManager.getPlayer(player).getProfile().getSkillXpLevelRaw(getNonChildSkillType(skillType));
|
||||
return UserManager.getPlayer(player).getSkillXpLevelRaw(getNonChildSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -250,7 +250,7 @@ public final class ExperienceAPI {
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getXPToNextLevel(Player player, String skillType) {
|
||||
return UserManager.getPlayer(player).getProfile().getXpToLevel(getNonChildSkillType(skillType));
|
||||
return UserManager.getPlayer(player).getXpToLevel(getNonChildSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -323,7 +323,7 @@ public final class ExperienceAPI {
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void addLevel(Player player, String skillType, int levels) {
|
||||
UserManager.getPlayer(player).getProfile().addLevels(getSkillType(skillType), levels);
|
||||
UserManager.getPlayer(player).addLevels(getSkillType(skillType), levels);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -369,7 +369,7 @@ public final class ExperienceAPI {
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static int getLevel(Player player, String skillType) {
|
||||
return UserManager.getPlayer(player).getProfile().getSkillLevel(getSkillType(skillType));
|
||||
return UserManager.getPlayer(player).getSkillLevel(getSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -492,7 +492,7 @@ public final class ExperienceAPI {
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void setLevel(Player player, String skillType, int skillLevel) {
|
||||
UserManager.getPlayer(player).getProfile().modifySkill(getSkillType(skillType), skillLevel);
|
||||
UserManager.getPlayer(player).modifySkill(getSkillType(skillType), skillLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -524,7 +524,7 @@ public final class ExperienceAPI {
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static void setXP(Player player, String skillType, int newValue) {
|
||||
UserManager.getPlayer(player).getProfile().setSkillXpLevel(getNonChildSkillType(skillType), newValue);
|
||||
UserManager.getPlayer(player).setSkillXpLevel(getNonChildSkillType(skillType), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -557,7 +557,7 @@ public final class ExperienceAPI {
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static void removeXP(Player player, String skillType, int xp) {
|
||||
UserManager.getPlayer(player).getProfile().removeXp(getNonChildSkillType(skillType), xp);
|
||||
UserManager.getPlayer(player).removeXp(getNonChildSkillType(skillType), xp);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -582,7 +582,7 @@ public final class ExperienceAPI {
|
||||
private static void addOfflineXP(String playerName, SkillType skill, int XP) {
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
profile.addExperience(skill, XP);
|
||||
profile.addXp(skill, XP);
|
||||
profile.save();
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class McrefreshCommand extends ToggleCommand {
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
mcMMOPlayer.setRecentlyHurt(0);
|
||||
mcMMOPlayer.getProfile().resetCooldowns();
|
||||
mcMMOPlayer.resetCooldowns();
|
||||
mcMMOPlayer.resetToolPrepMode();
|
||||
mcMMOPlayer.resetAbilityMode();
|
||||
|
||||
|
@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@ -39,11 +38,9 @@ public class MobhealthCommand implements TabExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
PlayerProfile playerProfile = UserManager.getPlayer((Player) sender).getProfile();
|
||||
|
||||
try {
|
||||
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
|
||||
playerProfile.setMobHealthbarType(type);
|
||||
UserManager.getPlayer((Player) sender).getProfile().setMobHealthbarType(type);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Changed." + type.name()));
|
||||
return true;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class AddxpCommand extends ExperienceCommand {
|
||||
mcMMOPlayer.applyXpGain(skill, value);
|
||||
}
|
||||
else {
|
||||
profile.addExperience(skill, value);
|
||||
profile.addXp(skill, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
@ -31,7 +30,6 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
protected String skillName;
|
||||
|
||||
protected Player player;
|
||||
protected PlayerProfile profile;
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
|
||||
protected float skillValue;
|
||||
@ -60,9 +58,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
skillValue = profile.getSkillLevel(skill);
|
||||
skillValue = mcMMOPlayer.getSkillLevel(skill);
|
||||
isLucky = Permissions.lucky(sender, skill);
|
||||
hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
|
||||
|
||||
@ -76,7 +72,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
if (!skill.isChildSkill()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
|
||||
@ -87,7 +83,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
Set<SkillType> parents = FamilyTree.getParents(skill);
|
||||
|
||||
for (SkillType parent : parents) {
|
||||
player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
|
||||
player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,7 @@ public class McMMOPlayer {
|
||||
|
||||
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
powerLevel += getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -536,16 +536,16 @@ public class McMMOPlayer {
|
||||
* @param skillType The skill to check
|
||||
*/
|
||||
private void checkXp(SkillType skillType) {
|
||||
if (profile.getSkillXpLevelRaw(skillType) < profile.getXpToLevel(skillType)) {
|
||||
if (getSkillXpLevelRaw(skillType) < getXpToLevel(skillType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int levelsGained = 0;
|
||||
float xpRemoved = 0;
|
||||
|
||||
while (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
|
||||
while (getSkillXpLevelRaw(skillType) >= getXpToLevel(skillType)) {
|
||||
if (hasReachedLevelCap(skillType)) {
|
||||
profile.setSkillXpLevel(skillType, 0);
|
||||
setSkillXpLevel(skillType, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -558,7 +558,7 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
||||
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, profile.getSkillLevel(skillType)));
|
||||
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, getSkillLevel(skillType)));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -669,7 +669,7 @@ public class McMMOPlayer {
|
||||
* @return Modified experience
|
||||
*/
|
||||
private float modifyXpGain(SkillType skillType, float xp) {
|
||||
if (player.getGameMode() == GameMode.CREATIVE || (skillType.getMaxLevel() <= profile.getSkillLevel(skillType)) || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) {
|
||||
if (player.getGameMode() == GameMode.CREATIVE || (skillType.getMaxLevel() <= getSkillLevel(skillType)) || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -733,7 +733,7 @@ public class McMMOPlayer {
|
||||
return;
|
||||
}
|
||||
|
||||
int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxLength());
|
||||
int ticks = PerksUtils.handleActivationPerks(player, 2 + (getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxLength());
|
||||
|
||||
// Notify people that ability has been activated
|
||||
ParticleEffectUtils.playAbilityEnabledEffect(player);
|
||||
@ -816,6 +816,53 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
private boolean hasReachedLevelCap(SkillType skill) {
|
||||
return (skill.getMaxLevel() < profile.getSkillLevel(skill) + 1) || (Config.getInstance().getPowerLevelCap() < getPowerLevel() + 1);
|
||||
return (skill.getMaxLevel() < getSkillLevel(skill) + 1) || (Config.getInstance().getPowerLevelCap() < getPowerLevel() + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* These functions are wrapped from PlayerProfile so that we don't always have to store it alongside the McMMOPlayer object.
|
||||
*/
|
||||
public int getSkillLevel(SkillType skill) {
|
||||
return profile.getSkillLevel(skill);
|
||||
}
|
||||
|
||||
public float getSkillXpLevelRaw(SkillType skill) {
|
||||
return profile.getSkillXpLevelRaw(skill);
|
||||
}
|
||||
|
||||
public int getSkillXpLevel(SkillType skill) {
|
||||
return profile.getSkillXpLevel(skill);
|
||||
}
|
||||
|
||||
public void setSkillXpLevel(SkillType skill, float xpLevel) {
|
||||
profile.setSkillXpLevel(skill, xpLevel);
|
||||
}
|
||||
|
||||
public int getXpToLevel(SkillType skill) {
|
||||
return profile.getXpToLevel(skill);
|
||||
}
|
||||
|
||||
public void removeXp(SkillType skill, int xp) {
|
||||
profile.removeXp(skill, xp);
|
||||
}
|
||||
|
||||
public void modifySkill(SkillType skill, int level) {
|
||||
profile.modifySkill(skill, level);
|
||||
}
|
||||
|
||||
public void addLevels(SkillType skill, int levels) {
|
||||
profile.addLevels(skill, levels);
|
||||
}
|
||||
|
||||
public void addXp(SkillType skill, float xp) {
|
||||
profile.addXp(skill, xp);
|
||||
}
|
||||
|
||||
public void setAbilityDATS(AbilityType ability, long DATS) {
|
||||
profile.setAbilityDATS(ability, DATS);
|
||||
}
|
||||
|
||||
public void resetCooldowns() {
|
||||
profile.resetCooldowns();
|
||||
}
|
||||
}
|
||||
|
@ -47,16 +47,13 @@ public class PlayerProfile {
|
||||
this.loaded = isLoaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calling this constructor is considered loading the profile.
|
||||
*/
|
||||
public PlayerProfile(String playerName, Map<SkillType, Integer> argSkills, Map<SkillType, Float> argSkillsXp, Map<AbilityType, Integer> argSkillsDats, MobHealthbarType mobHealthbarType) {
|
||||
public PlayerProfile(String playerName, Map<SkillType, Integer> levelData, Map<SkillType, Float> xpData, Map<AbilityType, Integer> cooldownData, MobHealthbarType mobHealthbarType) {
|
||||
this.playerName = playerName;
|
||||
this.mobHealthbarType = mobHealthbarType;
|
||||
|
||||
skills.putAll(argSkills);
|
||||
skillsXp.putAll(argSkillsXp);
|
||||
abilityDATS.putAll(argSkillsDats);
|
||||
skills.putAll(levelData);
|
||||
skillsXp.putAll(xpData);
|
||||
abilityDATS.putAll(cooldownData);
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
@ -113,7 +110,7 @@ public class PlayerProfile {
|
||||
* @param ability The {@link AbilityType} to set the DATS for
|
||||
* @param DATS the DATS of the ability
|
||||
*/
|
||||
public void setAbilityDATS(AbilityType ability, long DATS) {
|
||||
protected void setAbilityDATS(AbilityType ability, long DATS) {
|
||||
changed = true;
|
||||
|
||||
abilityDATS.put(ability, (int) (DATS * .001D));
|
||||
@ -122,7 +119,7 @@ public class PlayerProfile {
|
||||
/**
|
||||
* Reset all ability cooldowns.
|
||||
*/
|
||||
public void resetCooldowns() {
|
||||
protected void resetCooldowns() {
|
||||
changed = true;
|
||||
|
||||
for (AbilityType ability : abilityDATS.keySet()) {
|
||||
@ -156,7 +153,7 @@ public class PlayerProfile {
|
||||
skillsXp.put(skill, xpLevel);
|
||||
}
|
||||
|
||||
public float levelUp(SkillType skill) {
|
||||
protected float levelUp(SkillType skill) {
|
||||
float xpRemoved = getXpToLevel(skill);
|
||||
|
||||
changed = true;
|
||||
@ -214,21 +211,21 @@ public class PlayerProfile {
|
||||
* Add Experience to a skill.
|
||||
*
|
||||
* @param skill Type of skill to add experience to
|
||||
* @param experience Number of experience to add
|
||||
* @param xp Number of experience to add
|
||||
*/
|
||||
public void addExperience(SkillType skill, float experience) {
|
||||
public void addXp(SkillType skill, float xp) {
|
||||
changed = true;
|
||||
|
||||
if (skill.isChildSkill()) {
|
||||
Set<SkillType> parentSkills = FamilyTree.getParents(skill);
|
||||
float dividedXP = (experience / parentSkills.size());
|
||||
float dividedXP = (xp / parentSkills.size());
|
||||
|
||||
for (SkillType parentSkill : parentSkills) {
|
||||
skillsXp.put(parentSkill, skillsXp.get(parentSkill) + dividedXP);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skillsXp.put(skill, skillsXp.get(skill) + experience);
|
||||
skillsXp.put(skill, skillsXp.get(skill) + xp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
|
||||
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
||||
super(player);
|
||||
this.skill = skill;
|
||||
this.skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
|
||||
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@ public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
|
||||
protected McMMOPlayerSkillEvent(Player player, SkillType skill) {
|
||||
super(player);
|
||||
this.skill = skill;
|
||||
this.skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
|
||||
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.skills;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
|
||||
@ -26,12 +25,8 @@ public abstract class SkillManager {
|
||||
return mcMMOPlayer.getPlayer();
|
||||
}
|
||||
|
||||
public PlayerProfile getProfile() {
|
||||
return mcMMOPlayer.getProfile();
|
||||
}
|
||||
|
||||
public int getSkillLevel() {
|
||||
return mcMMOPlayer.getProfile().getSkillLevel(skill);
|
||||
return mcMMOPlayer.getSkillLevel(skill);
|
||||
}
|
||||
|
||||
public int getActivationChance() {
|
||||
|
@ -396,6 +396,6 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
|
||||
private byte getGreenThumbStage() {
|
||||
return (byte) Math.min(Math.min(getProfile().getSkillLevel(skill), Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4);
|
||||
return (byte) Math.min(Math.min(getSkillLevel(), Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4);
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class MiningManager extends SkillManager {
|
||||
tnt.setFuseTicks(0);
|
||||
targetBlock.setType(Material.AIR);
|
||||
|
||||
getProfile().setAbilityDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
|
||||
mcMMOPlayer.setAbilityDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
|
||||
mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false);
|
||||
new AbilityCooldownTask(mcMMOPlayer, AbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, AbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class EventUtils {
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
|
||||
profile.modifySkill(skill, profile.getSkillLevel(skill) - (isLevelUp ? levelsChanged : -levelsChanged));
|
||||
profile.addExperience(skill, xpRemoved);
|
||||
profile.addXp(skill, xpRemoved);
|
||||
}
|
||||
|
||||
return !isCancelled;
|
||||
@ -115,7 +115,7 @@ public class EventUtils {
|
||||
boolean isCancelled = event.isCancelled();
|
||||
|
||||
if (!isCancelled) {
|
||||
UserManager.getPlayer(player).getProfile().addExperience(skill, event.getRawXpGained());
|
||||
UserManager.getPlayer(player).addXp(skill, event.getRawXpGained());
|
||||
}
|
||||
|
||||
return !isCancelled;
|
||||
|
@ -70,7 +70,7 @@ public final class HardcoreManager {
|
||||
totalLevelsStolen += levelsStolen;
|
||||
|
||||
killerProfile.modifySkill(skillType, killerSkillLevel + levelsStolen);
|
||||
killerProfile.addExperience(skillType, xpStolen);
|
||||
killerProfile.addXp(skillType, xpStolen);
|
||||
|
||||
victimProfile.modifySkill(skillType, victimSkillLevel - levelsStolen);
|
||||
victimProfile.removeXp(skillType, xpStolen);
|
||||
|
@ -396,7 +396,6 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
switch (sidebarType) {
|
||||
case NONE:
|
||||
@ -406,18 +405,18 @@ public class ScoreboardWrapper {
|
||||
Validate.notNull(targetSkill);
|
||||
|
||||
if (!targetSkill.isChildSkill()) {
|
||||
int currentXP = profile.getSkillXpLevel(targetSkill);
|
||||
int currentXP = mcMMOPlayer.getSkillXpLevel(targetSkill);
|
||||
|
||||
sidebarObjective.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
|
||||
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(profile.getXpToLevel(targetSkill) - currentXP);
|
||||
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(mcMMOPlayer.getXpToLevel(targetSkill) - currentXP);
|
||||
}
|
||||
else {
|
||||
for (SkillType parentSkill : FamilyTree.getParents(targetSkill)) {
|
||||
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(profile.getSkillLevel(parentSkill));
|
||||
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(mcMMOPlayer.getSkillLevel(parentSkill));
|
||||
}
|
||||
}
|
||||
|
||||
sidebarObjective.getScore(ScoreboardManager.LABEL_LEVEL).setScore(profile.getSkillLevel(targetSkill));
|
||||
sidebarObjective.getScore(ScoreboardManager.LABEL_LEVEL).setScore(mcMMOPlayer.getSkillLevel(targetSkill));
|
||||
|
||||
if (targetSkill.getAbility() != null) {
|
||||
boolean stopUpdating;
|
||||
@ -482,7 +481,7 @@ public class ScoreboardWrapper {
|
||||
newProfile = targetProfile; // offline
|
||||
}
|
||||
else if (targetPlayer == null) {
|
||||
newProfile = profile; // self
|
||||
newProfile = mcMMOPlayer.getProfile(); // self
|
||||
}
|
||||
else {
|
||||
newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online
|
||||
|
@ -26,7 +26,7 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class SkillUtils {
|
||||
public static int handleFoodSkills(Player player, SkillType skill, int eventFoodLevel, int baseLevel, int maxLevel, int rankChange) {
|
||||
int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
|
||||
int skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
|
||||
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int foodChange = eventFoodLevel - currentFoodLevel;
|
||||
@ -124,7 +124,7 @@ public class SkillUtils {
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
SkillType skill = mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER) ? SkillType.MINING : SkillType.EXCAVATION;
|
||||
int ticks = PerksUtils.handleActivationPerks(player, 2 + (mcMMOPlayer.getProfile().getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), skill.getAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR;
|
||||
int ticks = PerksUtils.handleActivationPerks(player, 2 + (mcMMOPlayer.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), skill.getAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR;
|
||||
|
||||
PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10);
|
||||
player.addPotionEffect(abilityBuff, true);
|
||||
@ -178,7 +178,7 @@ public class SkillUtils {
|
||||
}
|
||||
|
||||
public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) {
|
||||
return activationSuccessful(UserManager.getPlayer(player).getProfile().getSkillLevel(skill), PerksUtils.handleLuckyPerks(player, skill), maxChance, maxLevel);
|
||||
return activationSuccessful(UserManager.getPlayer(player).getSkillLevel(skill), PerksUtils.handleLuckyPerks(player, skill), maxChance, maxLevel);
|
||||
}
|
||||
|
||||
public static boolean activationSuccessful(int skillLevel, int activationChance, double maxChance, int maxLevel) {
|
||||
|
Loading…
Reference in New Issue
Block a user