Skip to content

Commit

Permalink
fix xp multiplier not getting applied
Browse files Browse the repository at this point in the history
  • Loading branch information
nossr50 committed Apr 1, 2024
1 parent a047bca commit e509876
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Changelog.txt
@@ -1,3 +1,6 @@
Version 2.2.004
Fixed bug where values from Experience_Formula.Skill_Multiplier were not being used

Version 2.2.003
(SQLDB) Fixed a bug where lastlogin was using a value that was too large
(SQLDB) Fixed bug where crossbows was not getting added to SQL schema for some users
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.2.003</version>
<version>2.2.004-SNAPSHOT</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>
Expand Down
Expand Up @@ -260,7 +260,7 @@ public double getBredMobXpMultiplier() {

/* Skill modifiers */
public double getFormulaSkillModifier(PrimarySkillType skill) {
return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString()), 1);
return config.getDouble("Experience_Formula.Skill_Multiplier." + StringUtils.getCapitalized(skill.toString()), 1);
}

/* Custom XP perk */
Expand Down
Expand Up @@ -65,6 +65,7 @@
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.VisibleForTesting;

import java.util.EnumMap;
import java.util.Map;
Expand Down Expand Up @@ -840,14 +841,15 @@ public boolean isUsingUnarmed() {
* @param xp Experience amount to process
* @return Modified experience
*/
private float modifyXpGain(PrimarySkillType primarySkillType, float xp) {
@VisibleForTesting
float modifyXpGain(PrimarySkillType primarySkillType, float xp) {
//TODO: A rare situation can occur where the default Power Level cap can prevent a player with one skill edited to something silly like Integer.MAX_VALUE from gaining XP in any skill, we may need to represent power level with another data type
if ((mcMMO.p.getSkillTools().getLevelCap(primarySkillType) <= getSkillLevel(primarySkillType))
|| (mcMMO.p.getGeneralConfig().getPowerLevelCap() <= getPowerLevel())) {
return 0;
}

xp = (float) (xp * ExperienceConfig.getInstance().getFormulaSkillModifier(primarySkillType) * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
xp = (float) ((xp * ExperienceConfig.getInstance().getFormulaSkillModifier(primarySkillType)) * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());

if (mcMMO.p.getGeneralConfig().getToolModsEnabled()) {
CustomTool tool = mcMMO.getModManager().getTool(player.getInventory().getItemInMainHand());
Expand Down
Expand Up @@ -132,12 +132,12 @@ public List<SubSkillType> getSkillAbilities() {
/**
* WARNING: Being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
* @return the max level of this skill
* @see SkillTools#getXpModifier(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @see SkillTools#getXpMultiplier(com.gmail.nossr50.datatypes.skills.PrimarySkillType)
* @deprecated this is being removed in an upcoming update, you should be using mcMMO.getSkillTools() instead
*/
@Deprecated
public double getXpModifier() {
return mcMMO.p.getSkillTools().getXpModifier(this);
return mcMMO.p.getSkillTools().getXpMultiplier(this);
}

/**
Expand Down
Expand Up @@ -331,7 +331,7 @@ public Set<SubSkillType> getSubSkills(PrimarySkillType primarySkillType) {
return primarySkillChildrenMap.get(primarySkillType);
}

public double getXpModifier(PrimarySkillType primarySkillType) {
public double getXpMultiplier(PrimarySkillType primarySkillType) {
return ExperienceConfig.getInstance().getFormulaSkillModifier(primarySkillType);
}

Expand Down
Expand Up @@ -17,6 +17,7 @@
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;

Expand Down

0 comments on commit e509876

Please sign in to comment.