Fix bug with levels up commands reporting incorrect level

This commit is contained in:
nossr50
2023-08-27 16:19:46 -07:00
parent 2d8bdbded8
commit edab455581
14 changed files with 150 additions and 43 deletions

View File

@@ -263,7 +263,6 @@ public final class EventUtils {
if (isLevelUp) {
NotificationManager.processLevelUpBroadcasting(mmoPlayer, skill, mmoPlayer.getSkillLevel(skill));
NotificationManager.processPowerLevelUpBroadcasting(mmoPlayer, mmoPlayer.getPowerLevel());
}
}

View File

@@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.LogUtils;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.VisibleForTesting;
import java.io.File;
import java.util.HashMap;
@@ -25,7 +26,19 @@ public class FormulaManager {
public FormulaManager() {
/* Setting for Classic Mode (Scales a lot of stuff up by * 10) */
initExperienceNeededMaps();
loadFormula();
if (!formulaFile.exists()) {
previousFormula = FormulaType.UNKNOWN;
return;
}
previousFormula = FormulaType.getFormulaType(YamlConfiguration.loadConfiguration(formulaFile).getString("Previous_Formula", "UNKNOWN"));
}
@VisibleForTesting
public FormulaManager(FormulaType previousFormulaType) {
/* Setting for Classic Mode (Scales a lot of stuff up by * 10) */
initExperienceNeededMaps();
this.previousFormula = previousFormulaType;
}
/**
@@ -122,7 +135,7 @@ public class FormulaManager {
*/
//TODO: When the heck is Unknown used?
if (formulaType == FormulaType.UNKNOWN) {
if (formulaType == null || formulaType == FormulaType.UNKNOWN) {
formulaType = FormulaType.LINEAR;
}
@@ -209,18 +222,6 @@ public class FormulaManager {
}
}
/**
* Load formula file.
*/
public void loadFormula() {
if (!formulaFile.exists()) {
previousFormula = FormulaType.UNKNOWN;
return;
}
previousFormula = FormulaType.getFormulaType(YamlConfiguration.loadConfiguration(formulaFile).getString("Previous_Formula", "UNKNOWN"));
}
/**
* Save formula file.
*/

View File

@@ -139,7 +139,7 @@ public class NotificationManager {
notificationType, message, destination, mcMMO.p.getAdvancedConfig().doesNotificationSendCopyToChat(notificationType));
//Call event
Bukkit.getServer().getPluginManager().callEvent(customEvent);
mcMMO.p.getServer().getPluginManager().callEvent(customEvent);
return customEvent;
}