Certain operations do not work with child skills

This commit is contained in:
T00thpick1 2013-05-14 19:31:40 -04:00
parent 1867a3e040
commit e5f43462c8

View File

@ -175,6 +175,7 @@ public final class ExperienceAPI {
* @return the amount of XP in a given skill * @return the amount of XP in a given skill
* *
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @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) {
SkillType skill = SkillType.getSkill(skillType); SkillType skill = SkillType.getSkill(skillType);
@ -183,6 +184,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException(); throw new InvalidSkillException();
} }
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
return UserManager.getPlayer(player).getProfile().getSkillXpLevel(skill); return UserManager.getPlayer(player).getProfile().getSkillXpLevel(skill);
} }
@ -197,6 +202,7 @@ public final class ExperienceAPI {
* *
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getOfflineXP(String playerName, String skillType) { public static int getOfflineXP(String playerName, String skillType) {
SkillType skill = SkillType.getSkill(skillType); SkillType skill = SkillType.getSkill(skillType);
@ -205,6 +211,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException(); throw new InvalidSkillException();
} }
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
return getOfflineProfile(playerName).getSkillXpLevel(skill); return getOfflineProfile(playerName).getSkillXpLevel(skill);
} }
@ -218,6 +228,7 @@ public final class ExperienceAPI {
* @return the amount of XP in a given skill * @return the amount of XP in a given skill
* *
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @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) {
SkillType skill = SkillType.getSkill(skillType); SkillType skill = SkillType.getSkill(skillType);
@ -226,6 +237,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException(); throw new InvalidSkillException();
} }
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
return UserManager.getPlayer(player).getProfile().getSkillXpLevelRaw(skill); return UserManager.getPlayer(player).getProfile().getSkillXpLevelRaw(skill);
} }
@ -240,6 +255,7 @@ public final class ExperienceAPI {
* *
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static float getOfflineXPRaw(String playerName, String skillType) { public static float getOfflineXPRaw(String playerName, String skillType) {
SkillType skill = SkillType.getSkill(skillType); SkillType skill = SkillType.getSkill(skillType);
@ -248,6 +264,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException(); throw new InvalidSkillException();
} }
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
return getOfflineProfile(playerName).getSkillXpLevelRaw(skill); return getOfflineProfile(playerName).getSkillXpLevelRaw(skill);
} }
@ -261,6 +281,7 @@ public final class ExperienceAPI {
* @return the amount of XP left before leveling up a specifc skill * @return the amount of XP left before leveling up a specifc skill
* *
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @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) {
SkillType skill = SkillType.getSkill(skillType); SkillType skill = SkillType.getSkill(skillType);
@ -269,6 +290,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException(); throw new InvalidSkillException();
} }
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
return UserManager.getPlayer(player).getProfile().getXpToLevel(skill); return UserManager.getPlayer(player).getProfile().getXpToLevel(skill);
} }
@ -283,6 +308,7 @@ public final class ExperienceAPI {
* *
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getOfflineXPToNextLevel(String playerName, String skillType) { public static int getOfflineXPToNextLevel(String playerName, String skillType) {
SkillType skill = SkillType.getSkill(skillType); SkillType skill = SkillType.getSkill(skillType);
@ -291,6 +317,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException(); throw new InvalidSkillException();
} }
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
return getOfflineProfile(playerName).getXpToLevel(skill); return getOfflineProfile(playerName).getXpToLevel(skill);
} }
@ -514,6 +544,7 @@ public final class ExperienceAPI {
* @param newValue The value to set the XP to * @param newValue The value to set the XP to
* *
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @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) {
SkillType skill = SkillType.getSkill(skillType); SkillType skill = SkillType.getSkill(skillType);
@ -522,6 +553,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException(); throw new InvalidSkillException();
} }
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
UserManager.getPlayer(player).getProfile().setSkillXpLevel(skill, newValue); UserManager.getPlayer(player).getProfile().setSkillXpLevel(skill, newValue);
} }
@ -536,6 +571,7 @@ public final class ExperienceAPI {
* *
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static void setXPOffline(String playerName, String skillType, int newValue) { public static void setXPOffline(String playerName, String skillType, int newValue) {
SkillType skill = SkillType.getSkill(skillType); SkillType skill = SkillType.getSkill(skillType);
@ -544,6 +580,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException(); throw new InvalidSkillException();
} }
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
getOfflineProfile(playerName).setSkillXpLevel(skill, newValue); getOfflineProfile(playerName).setSkillXpLevel(skill, newValue);
} }
@ -557,6 +597,7 @@ public final class ExperienceAPI {
* @param xp The amount of XP to remove * @param xp The amount of XP to remove
* *
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @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) {
SkillType skill = SkillType.getSkill(skillType); SkillType skill = SkillType.getSkill(skillType);
@ -565,6 +606,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException(); throw new InvalidSkillException();
} }
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
UserManager.getPlayer(player).getProfile().removeXp(skill, xp); UserManager.getPlayer(player).getProfile().removeXp(skill, xp);
} }
@ -579,6 +624,7 @@ public final class ExperienceAPI {
* *
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static void removeXPOffline(String playerName, String skillType, int xp) { public static void removeXPOffline(String playerName, String skillType, int xp) {
SkillType skill = SkillType.getSkill(skillType); SkillType skill = SkillType.getSkill(skillType);
@ -587,6 +633,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException(); throw new InvalidSkillException();
} }
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
getOfflineProfile(playerName).removeXp(skill, xp); getOfflineProfile(playerName).removeXp(skill, xp);
} }