mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Add new ExperienceAPI method to specify if XP can be shared
This commit is contained in:
parent
087a0b079f
commit
b61c65636b
@ -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
|
||||
|
@ -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.
|
||||
* </br>
|
||||
* 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.
|
||||
* </br>
|
||||
* 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.
|
||||
* </br>
|
||||
* 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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user