diff --git a/Changelog.txt b/Changelog.txt index 8056f3361..082c80d2b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -21,6 +21,7 @@ Version 1.5.01-dev + Added API to ExperienceAPI to get the amount of XP needed for a level + Added API class SkillAPI used to get a list of valid skill names + Added API events for hardcore features, McMMOPlayerPreDeathPenaltyEvent, McMMOPlayerStatLossEvent and McMMOPlayerVampirismEvent + + Added API to ExperienceAPI to specify if XP can be shared + Added options to tools.yml and armor.yml config files to set a pretty repair material name + Added full support for repairables in tools.yml and armor.yml config files + Added magical mod config file import command, for Cauldron 1.7+. Check wiki for usage diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index 56b9f8563..4e05a0136 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -86,6 +86,29 @@ public final class ExperienceAPI { * @throws InvalidXPGainReasonException if the given xpGainReason is not valid */ public static void addRawXP(Player player, String skillType, float XP, String xpGainReason) { + addRawXP(player, skillType, XP, xpGainReason, false); + } + + /** + * Adds raw XP to the player. + *
+ * This function is designed for API usage. + * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * @param xpGainReason The reason to gain XP + * @param isUnshared true if the XP cannot be shared with party members + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidXPGainReasonException if the given xpGainReason is not valid + */ + public static void addRawXP(Player player, String skillType, float XP, String xpGainReason, boolean isUnshared) { + if (isUnshared) { + UserManager.getPlayer(player).beginUnsharedXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason)); + return; + } + UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason)); } @@ -218,8 +241,31 @@ public final class ExperienceAPI { * @throws InvalidXPGainReasonException if the given xpGainReason is not valid */ public static void addModifiedXP(Player player, String skillType, int XP, String xpGainReason) { + addModifiedXP(player, skillType, XP, xpGainReason, false); + } + + /** + * Adds XP to the player, calculates for XP Rate and skill modifier. + *
+ * This function is designed for API usage. + * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * @param xpGainReason The reason to gain XP + * @param isUnshared true if the XP cannot be shared with party members + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidXPGainReasonException if the given xpGainReason is not valid + */ + public static void addModifiedXP(Player player, String skillType, int XP, String xpGainReason, boolean isUnshared) { SkillType skill = getSkillType(skillType); + if (isUnshared) { + UserManager.getPlayer(player).beginUnsharedXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason)); + return; + } + UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()), getXPGainReason(xpGainReason)); } @@ -274,6 +320,30 @@ public final class ExperienceAPI { * @throws InvalidXPGainReasonException if the given xpGainReason is not valid */ public static void addXP(Player player, String skillType, int XP, String xpGainReason) { + addXP(player, skillType, XP, xpGainReason, false); + } + + /** + * Adds XP to the player, calculates for XP Rate, skill modifiers, perks, child skills, + * and party sharing. + *
+ * This function is designed for API usage. + * + * @param player The player to add XP to + * @param skillType The skill to add XP to + * @param XP The amount of XP to add + * @param xpGainReason The reason to gain XP + * @param isUnshared true if the XP cannot be shared with party members + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidXPGainReasonException if the given xpGainReason is not valid + */ + public static void addXP(Player player, String skillType, int XP, String xpGainReason, boolean isUnshared) { + if (isUnshared) { + UserManager.getPlayer(player).beginUnsharedXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason)); + return; + } + UserManager.getPlayer(player).beginXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason)); }