Wrap these inside McMMOPlayer for easier access.

This commit is contained in:
GJ 2013-10-29 11:02:57 -04:00
parent a8d1376533
commit 97b9214d6e
17 changed files with 105 additions and 74 deletions

View File

@ -50,34 +50,34 @@ public final class AbilityAPI {
} }
public static void resetCooldowns(Player player) { public static void resetCooldowns(Player player) {
UserManager.getPlayer(player).getProfile().resetCooldowns(); UserManager.getPlayer(player).resetCooldowns();
} }
public static void setBerserkCooldown(Player player, long cooldown) { 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) { 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) { 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) { 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) { 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) { 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) { 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);
} }
} }

View File

@ -184,7 +184,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getXP(Player player, String skillType) { 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 * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static float getXPRaw(Player player, String skillType) { 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 * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getXPToNextLevel(Player player, String skillType) { 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 * @throws InvalidSkillException if the given skill is not valid
*/ */
public static void addLevel(Player player, String skillType, int levels) { 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 * @throws InvalidSkillException if the given skill is not valid
*/ */
public static int getLevel(Player player, String skillType) { 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 * @throws InvalidSkillException if the given skill is not valid
*/ */
public static void setLevel(Player player, String skillType, int skillLevel) { 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 * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static void setXP(Player player, String skillType, int newValue) { 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 * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static void removeXP(Player player, String skillType, int xp) { 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) { private static void addOfflineXP(String playerName, SkillType skill, int XP) {
PlayerProfile profile = getOfflineProfile(playerName); PlayerProfile profile = getOfflineProfile(playerName);
profile.addExperience(skill, XP); profile.addXp(skill, XP);
profile.save(); profile.save();
} }

View File

@ -19,7 +19,7 @@ public class McrefreshCommand extends ToggleCommand {
@Override @Override
protected void applyCommandAction() { protected void applyCommandAction() {
mcMMOPlayer.setRecentlyHurt(0); mcMMOPlayer.setRecentlyHurt(0);
mcMMOPlayer.getProfile().resetCooldowns(); mcMMOPlayer.resetCooldowns();
mcMMOPlayer.resetToolPrepMode(); mcMMOPlayer.resetToolPrepMode();
mcMMOPlayer.resetAbilityMode(); mcMMOPlayer.resetAbilityMode();

View File

@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@ -39,11 +38,9 @@ public class MobhealthCommand implements TabExecutor {
switch (args.length) { switch (args.length) {
case 1: case 1:
PlayerProfile playerProfile = UserManager.getPlayer((Player) sender).getProfile();
try { try {
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim()); 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())); sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Changed." + type.name()));
return true; return true;
} }

View File

@ -23,7 +23,7 @@ public class AddxpCommand extends ExperienceCommand {
mcMMOPlayer.applyXpGain(skill, value); mcMMOPlayer.applyXpGain(skill, value);
} }
else { else {
profile.addExperience(skill, value); profile.addXp(skill, value);
} }
} }

View File

@ -13,7 +13,6 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; 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.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.child.FamilyTree;
@ -31,7 +30,6 @@ public abstract class SkillCommand implements TabExecutor {
protected String skillName; protected String skillName;
protected Player player; protected Player player;
protected PlayerProfile profile;
protected McMMOPlayer mcMMOPlayer; protected McMMOPlayer mcMMOPlayer;
protected float skillValue; protected float skillValue;
@ -60,9 +58,7 @@ public abstract class SkillCommand implements TabExecutor {
switch (args.length) { switch (args.length) {
case 0: case 0:
profile = mcMMOPlayer.getProfile(); skillValue = mcMMOPlayer.getSkillLevel(skill);
skillValue = profile.getSkillLevel(skill);
isLucky = Permissions.lucky(sender, skill); isLucky = Permissions.lucky(sender, skill);
hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0); hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
@ -76,7 +72,7 @@ public abstract class SkillCommand implements TabExecutor {
if (!skill.isChildSkill()) { if (!skill.isChildSkill()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName)); 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("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 { else {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child"))); 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); Set<SkillType> parents = FamilyTree.getParents(skill);
for (SkillType parent : parents) { 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)));
} }
} }

View File

@ -454,7 +454,7 @@ public class McMMOPlayer {
for (SkillType type : SkillType.NON_CHILD_SKILLS) { for (SkillType type : SkillType.NON_CHILD_SKILLS) {
if (type.getPermissions(player)) { if (type.getPermissions(player)) {
powerLevel += profile.getSkillLevel(type); powerLevel += getSkillLevel(type);
} }
} }
@ -536,16 +536,16 @@ public class McMMOPlayer {
* @param skillType The skill to check * @param skillType The skill to check
*/ */
private void checkXp(SkillType skillType) { private void checkXp(SkillType skillType) {
if (profile.getSkillXpLevelRaw(skillType) < profile.getXpToLevel(skillType)) { if (getSkillXpLevelRaw(skillType) < getXpToLevel(skillType)) {
return; return;
} }
int levelsGained = 0; int levelsGained = 0;
float xpRemoved = 0; float xpRemoved = 0;
while (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) { while (getSkillXpLevelRaw(skillType) >= getXpToLevel(skillType)) {
if (hasReachedLevelCap(skillType)) { if (hasReachedLevelCap(skillType)) {
profile.setSkillXpLevel(skillType, 0); setSkillXpLevel(skillType, 0);
break; break;
} }
@ -558,7 +558,7 @@ public class McMMOPlayer {
} }
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH); 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 * @return Modified experience
*/ */
private float modifyXpGain(SkillType skillType, float xp) { 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; return 0;
} }
@ -733,7 +733,7 @@ public class McMMOPlayer {
return; 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 // Notify people that ability has been activated
ParticleEffectUtils.playAbilityEnabledEffect(player); ParticleEffectUtils.playAbilityEnabledEffect(player);
@ -816,6 +816,53 @@ public class McMMOPlayer {
} }
private boolean hasReachedLevelCap(SkillType skill) { 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();
} }
} }

View File

@ -47,16 +47,13 @@ public class PlayerProfile {
this.loaded = isLoaded; this.loaded = isLoaded;
} }
/** public PlayerProfile(String playerName, Map<SkillType, Integer> levelData, Map<SkillType, Float> xpData, Map<AbilityType, Integer> cooldownData, MobHealthbarType mobHealthbarType) {
* 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) {
this.playerName = playerName; this.playerName = playerName;
this.mobHealthbarType = mobHealthbarType; this.mobHealthbarType = mobHealthbarType;
skills.putAll(argSkills); skills.putAll(levelData);
skillsXp.putAll(argSkillsXp); skillsXp.putAll(xpData);
abilityDATS.putAll(argSkillsDats); abilityDATS.putAll(cooldownData);
loaded = true; loaded = true;
} }
@ -113,7 +110,7 @@ public class PlayerProfile {
* @param ability The {@link AbilityType} to set the DATS for * @param ability The {@link AbilityType} to set the DATS for
* @param DATS the DATS of the ability * @param DATS the DATS of the ability
*/ */
public void setAbilityDATS(AbilityType ability, long DATS) { protected void setAbilityDATS(AbilityType ability, long DATS) {
changed = true; changed = true;
abilityDATS.put(ability, (int) (DATS * .001D)); abilityDATS.put(ability, (int) (DATS * .001D));
@ -122,7 +119,7 @@ public class PlayerProfile {
/** /**
* Reset all ability cooldowns. * Reset all ability cooldowns.
*/ */
public void resetCooldowns() { protected void resetCooldowns() {
changed = true; changed = true;
for (AbilityType ability : abilityDATS.keySet()) { for (AbilityType ability : abilityDATS.keySet()) {
@ -156,7 +153,7 @@ public class PlayerProfile {
skillsXp.put(skill, xpLevel); skillsXp.put(skill, xpLevel);
} }
public float levelUp(SkillType skill) { protected float levelUp(SkillType skill) {
float xpRemoved = getXpToLevel(skill); float xpRemoved = getXpToLevel(skill);
changed = true; changed = true;
@ -214,21 +211,21 @@ public class PlayerProfile {
* Add Experience to a skill. * Add Experience to a skill.
* *
* @param skill Type of skill to add experience to * @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; changed = true;
if (skill.isChildSkill()) { if (skill.isChildSkill()) {
Set<SkillType> parentSkills = FamilyTree.getParents(skill); Set<SkillType> parentSkills = FamilyTree.getParents(skill);
float dividedXP = (experience / parentSkills.size()); float dividedXP = (xp / parentSkills.size());
for (SkillType parentSkill : parentSkills) { for (SkillType parentSkill : parentSkills) {
skillsXp.put(parentSkill, skillsXp.get(parentSkill) + dividedXP); skillsXp.put(parentSkill, skillsXp.get(parentSkill) + dividedXP);
} }
} }
else { else {
skillsXp.put(skill, skillsXp.get(skill) + experience); skillsXp.put(skill, skillsXp.get(skill) + xp);
} }
} }

View File

@ -19,7 +19,7 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) { protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
super(player); super(player);
this.skill = skill; this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill); this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
} }
/** /**

View File

@ -17,7 +17,7 @@ public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
protected McMMOPlayerSkillEvent(Player player, SkillType skill) { protected McMMOPlayerSkillEvent(Player player, SkillType skill) {
super(player); super(player);
this.skill = skill; this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill); this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
} }
/** /**

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.skills;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; 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.datatypes.skills.SkillType;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
@ -26,12 +25,8 @@ public abstract class SkillManager {
return mcMMOPlayer.getPlayer(); return mcMMOPlayer.getPlayer();
} }
public PlayerProfile getProfile() {
return mcMMOPlayer.getProfile();
}
public int getSkillLevel() { public int getSkillLevel() {
return mcMMOPlayer.getProfile().getSkillLevel(skill); return mcMMOPlayer.getSkillLevel(skill);
} }
public int getActivationChance() { public int getActivationChance() {

View File

@ -396,6 +396,6 @@ public class HerbalismManager extends SkillManager {
} }
private byte getGreenThumbStage() { 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);
} }
} }

View File

@ -108,7 +108,7 @@ public class MiningManager extends SkillManager {
tnt.setFuseTicks(0); tnt.setFuseTicks(0);
targetBlock.setType(Material.AIR); targetBlock.setType(Material.AIR);
getProfile().setAbilityDATS(AbilityType.BLAST_MINING, System.currentTimeMillis()); mcMMOPlayer.setAbilityDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false); mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false);
new AbilityCooldownTask(mcMMOPlayer, AbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, AbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR); new AbilityCooldownTask(mcMMOPlayer, AbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, AbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
} }

View File

@ -59,7 +59,7 @@ public class EventUtils {
PlayerProfile profile = UserManager.getPlayer(player).getProfile(); PlayerProfile profile = UserManager.getPlayer(player).getProfile();
profile.modifySkill(skill, profile.getSkillLevel(skill) - (isLevelUp ? levelsChanged : -levelsChanged)); profile.modifySkill(skill, profile.getSkillLevel(skill) - (isLevelUp ? levelsChanged : -levelsChanged));
profile.addExperience(skill, xpRemoved); profile.addXp(skill, xpRemoved);
} }
return !isCancelled; return !isCancelled;
@ -115,7 +115,7 @@ public class EventUtils {
boolean isCancelled = event.isCancelled(); boolean isCancelled = event.isCancelled();
if (!isCancelled) { if (!isCancelled) {
UserManager.getPlayer(player).getProfile().addExperience(skill, event.getRawXpGained()); UserManager.getPlayer(player).addXp(skill, event.getRawXpGained());
} }
return !isCancelled; return !isCancelled;

View File

@ -70,7 +70,7 @@ public final class HardcoreManager {
totalLevelsStolen += levelsStolen; totalLevelsStolen += levelsStolen;
killerProfile.modifySkill(skillType, killerSkillLevel + levelsStolen); killerProfile.modifySkill(skillType, killerSkillLevel + levelsStolen);
killerProfile.addExperience(skillType, xpStolen); killerProfile.addXp(skillType, xpStolen);
victimProfile.modifySkill(skillType, victimSkillLevel - levelsStolen); victimProfile.modifySkill(skillType, victimSkillLevel - levelsStolen);
victimProfile.removeXp(skillType, xpStolen); victimProfile.removeXp(skillType, xpStolen);

View File

@ -396,7 +396,6 @@ public class ScoreboardWrapper {
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
PlayerProfile profile = mcMMOPlayer.getProfile();
switch (sidebarType) { switch (sidebarType) {
case NONE: case NONE:
@ -406,18 +405,18 @@ public class ScoreboardWrapper {
Validate.notNull(targetSkill); Validate.notNull(targetSkill);
if (!targetSkill.isChildSkill()) { 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_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 { else {
for (SkillType parentSkill : FamilyTree.getParents(targetSkill)) { 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) { if (targetSkill.getAbility() != null) {
boolean stopUpdating; boolean stopUpdating;
@ -482,7 +481,7 @@ public class ScoreboardWrapper {
newProfile = targetProfile; // offline newProfile = targetProfile; // offline
} }
else if (targetPlayer == null) { else if (targetPlayer == null) {
newProfile = profile; // self newProfile = mcMMOPlayer.getProfile(); // self
} }
else { else {
newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online

View File

@ -26,7 +26,7 @@ import com.gmail.nossr50.util.player.UserManager;
public class SkillUtils { public class SkillUtils {
public static int handleFoodSkills(Player player, SkillType skill, int eventFoodLevel, int baseLevel, int maxLevel, int rankChange) { 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 currentFoodLevel = player.getFoodLevel();
int foodChange = eventFoodLevel - currentFoodLevel; int foodChange = eventFoodLevel - currentFoodLevel;
@ -124,7 +124,7 @@ public class SkillUtils {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
SkillType skill = mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER) ? SkillType.MINING : SkillType.EXCAVATION; 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); PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10);
player.addPotionEffect(abilityBuff, true); player.addPotionEffect(abilityBuff, true);
@ -178,7 +178,7 @@ public class SkillUtils {
} }
public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) { 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) { public static boolean activationSuccessful(int skillLevel, int activationChance, double maxChance, int maxLevel) {