fix xp multiplier not getting applied

This commit is contained in:
nossr50 2024-04-01 15:12:24 -07:00
parent a047bca94c
commit e509876658
7 changed files with 13 additions and 7 deletions

View File

@ -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

View File

@ -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>

View File

@ -260,7 +260,7 @@ public class ExperienceConfig extends BukkitConfig {
/* 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 */

View File

@ -65,6 +65,7 @@ import org.bukkit.plugin.Plugin;
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;
@ -840,14 +841,15 @@ public class McMMOPlayer implements Identified {
* @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());

View File

@ -132,12 +132,12 @@ public enum PrimarySkillType {
/**
* 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);
}
/**

View File

@ -331,7 +331,7 @@ public class SkillTools {
return primarySkillChildrenMap.get(primarySkillType);
}
public double getXpModifier(PrimarySkillType primarySkillType) {
public double getXpMultiplier(PrimarySkillType primarySkillType) {
return ExperienceConfig.getInstance().getFormulaSkillModifier(primarySkillType);
}

View File

@ -17,6 +17,7 @@ import org.junit.jupiter.api.BeforeEach;
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;