Merge 2.1.53

This commit is contained in:
nossr50 2019-05-03 23:31:08 -07:00
commit 8a312da0f5
4 changed files with 54 additions and 3 deletions

View File

@ -164,6 +164,9 @@ Version 2.2.0
Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition
Added API method to check if a skill was being level capped Added API method to check if a skill was being level capped
Version 2.1.53
Fixed a critical bug where players earned too much XP
Version 2.1.52 Version 2.1.52
Updated Japanese locale (thanks snake0053) Updated Japanese locale (thanks snake0053)
Added a toggle for the early game XP boost to experience.yml 'EarlyGameBoost.Enabled' Added a toggle for the early game XP boost to experience.yml 'EarlyGameBoost.Enabled'

View File

@ -90,19 +90,17 @@ public class SelfListener implements Listener {
if(ExperienceConfig.getInstance().isEarlyGameBoostEnabled()) if(ExperienceConfig.getInstance().isEarlyGameBoostEnabled())
{ {
int earlyLevelBonusXPCap = (int) (ExperienceConfig.getInstance().getEarlyGameBoostMultiplier() * Config.getInstance().getLevelCap(event.getSkill()));
int earlyGameBonusXP = 0; int earlyGameBonusXP = 0;
//Give some bonus XP for low levels //Give some bonus XP for low levels
if(mcMMOPlayer.getSkillLevel(primarySkillType) < earlyLevelBonusXPCap) if(mcMMOPlayer.getSkillLevel(primarySkillType) <= mcMMO.getPlayerLevelUtils().getEarlyGameCutoff(primarySkillType))
{ {
earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05); earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05);
event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP); event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP);
} }
} }
int threshold = ExperienceConfig.getInstance().getDiminishedReturnsThreshold(primarySkillType); int threshold = ExperienceConfig.getInstance().getDiminishedReturnsThreshold(primarySkillType);
if (threshold <= 0 || !ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) { if (threshold <= 0 || !ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {

View File

@ -33,6 +33,7 @@ import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory; import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
import com.gmail.nossr50.util.commands.CommandRegistrationManager; import com.gmail.nossr50.util.commands.CommandRegistrationManager;
import com.gmail.nossr50.util.experience.FormulaManager; import com.gmail.nossr50.util.experience.FormulaManager;
import com.gmail.nossr50.util.player.PlayerLevelUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
@ -88,6 +89,8 @@ public class mcMMO extends JavaPlugin {
private static DatabaseManager databaseManager; private static DatabaseManager databaseManager;
private static FormulaManager formulaManager; private static FormulaManager formulaManager;
private static MaterialMapStore materialMapStore; private static MaterialMapStore materialMapStore;
private static PlayerLevelUtils playerLevelUtils;
/* File Paths */ /* File Paths */
private static String mainDirectory; private static String mainDirectory;
private static String localesDirectory; private static String localesDirectory;
@ -337,6 +340,13 @@ public class mcMMO extends JavaPlugin {
//Init Material Maps //Init Material Maps
materialMapStore = new MaterialMapStore(); materialMapStore = new MaterialMapStore();
//Init player level values
playerLevelUtils = new PlayerLevelUtils();
}
public static PlayerLevelUtils getPlayerLevelUtils() {
return playerLevelUtils;
} }
private void checkForOutdatedAPI() { private void checkForOutdatedAPI() {

View File

@ -0,0 +1,40 @@
package com.gmail.nossr50.util.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import java.util.HashMap;
public class PlayerLevelUtils {
HashMap<PrimarySkillType, Integer> earlyGameBoostCutoffs;
public PlayerLevelUtils()
{
earlyGameBoostCutoffs = new HashMap<>();
calculateEarlyGameBoostCutoffs();
}
private void calculateEarlyGameBoostCutoffs()
{
for(PrimarySkillType primarySkillType : PrimarySkillType.values())
{
int levelCap = Config.getInstance().getLevelCap(primarySkillType);
int cap;
if(levelCap == Integer.MAX_VALUE || levelCap <= 0)
{
cap = Config.getInstance().getIsRetroMode() ? 50 : 5;
} else {
cap = (int) (levelCap * ExperienceConfig.getInstance().getEarlyGameBoostMultiplier());
}
earlyGameBoostCutoffs.put(primarySkillType, cap);
}
}
public int getEarlyGameCutoff(PrimarySkillType primarySkillType)
{
return earlyGameBoostCutoffs.get(primarySkillType);
}
}