Changed experience storage from integers to floats

This will make sure no experience is lost when the server has high
skill modifiers configured, or when low amounts of experience are being
shared.
This commit is contained in:
TfT_02
2013-04-24 19:30:46 +02:00
committed by GJ
parent eea5784527
commit 17a0382283
9 changed files with 126 additions and 64 deletions

View File

@ -208,6 +208,49 @@ public final class ExperienceAPI {
return getOfflineProfile(playerName).getSkillXpLevel(skill);
}
/**
* Get the raw amount of XP a player has in a specific skill.
* </br>
* This function is designed for API usage.
*
* @param player The player to get XP for
* @param skillType The skill to get XP for
* @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid
*/
public static float getXPRaw(Player player, String skillType) {
SkillType skill = SkillType.getSkill(skillType);
if (skill == null) {
throw new InvalidSkillException();
}
return UserManager.getPlayer(player).getProfile().getSkillXpLevelRaw(skill);
}
/**
* Get the raw amount of XP an offline player has in a specific skill.
* </br>
* This function is designed for API usage.
*
* @param playerName The player to get XP for
* @param skillType The skill to get XP for
* @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
*/
public static float getOfflineXPRaw(String playerName, String skillType) {
SkillType skill = SkillType.getSkill(skillType);
if (skill == null) {
throw new InvalidSkillException();
}
return getOfflineProfile(playerName).getSkillXpLevelRaw(skill);
}
/**
* Get the amount of XP left before leveling up.
* </br>