diff --git a/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java index 973214a78..0193a0485 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java @@ -16,32 +16,32 @@ public class ConvertExperienceCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 2: - FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType(); - FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase()); - if (newType == FormulaType.UNKNOWN) { - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid")); - return true; - } - - if (previousType == newType) { - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Same", newType.toString())); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString())); - - UserManager.saveAll(); - UserManager.clearAll(); - - new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1); - - for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { - new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + + for(FormulaType formulaType : FormulaType.values()) { + if(formulaType.toString().equalsIgnoreCase(args[1])) { + FormulaType previousType = formulaType; + + sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), mcMMO.getConfigManager().getConfigLeveling().getFormulaType().toString())); + + UserManager.saveAll(); + UserManager.clearAll(); + + new FormulaConversionTask(sender, previousType).runTaskLater(mcMMO.p, 1); + + for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { + new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + } + + return true; + } } + sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid")); return true; + + default: return false; } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyLevel.java b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyLevel.java index d0284b790..d9b85c805 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyLevel.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyLevel.java @@ -28,18 +28,6 @@ public class ConfigSectionPartyLevel { PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.CHAT, PARTY_CHAT_DEFAULT); } - /* - int base = ExperienceConfig.getInstance().getBase(FormulaType.EXPONENTIAL); - double multiplier = ExperienceConfig.getInstance().getMultiplier(FormulaType.EXPONENTIAL); - double exponent = ExperienceConfig.getInstance().getExponent(FormulaType.EXPONENTIAL); - - if (!experienceNeededExponential.containsKey(level)) { - experience = (int) Math.floor((multiplier * Math.pow(level, exponent) + base)); - experience *= mcMMO.getConfigManager().getConfigParty().getPartyXP().getPartyLevel().getPartyXpCurveMultiplier(); - experienceNeededExponential.put(level, experience); - } - */ - @Setting(value = "Party-Leveling-Requires-Nearby-Party-Members", comment = "If leveling your Party requires being near another party member." + "\nDefault value: " + PARTY_LEVELING_NEEDS_NERBY_MEMBERS_DEFAULT) diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 50c5a5dcf..3e178ca06 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -205,8 +205,6 @@ public class mcMMO extends JavaPlugin { if (getScoreboardSettings().getScoreboardsEnabled()) ScoreboardManager.teardownAll(); - formulaManager.saveFormula(); - /*holidayManager.saveAnniversaryFiles();*/ placeStore.saveAll(); // Save our metadata placeStore.cleanUp(); // Cleanup empty metadata stores } catch (Exception e) { diff --git a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java index 5e20c9749..e17f1d715 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java @@ -49,7 +49,7 @@ public class FormulaConversionTask extends BukkitRunnable { Misc.printProgress(convertedUsers, DatabaseManager.progressInterval, startMillis); } - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Finish", previousFormula.toString())); + sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Finish", mcMMO.getConfigManager().getConfigLeveling().getConfigExperienceFormula().toString())); } private void editValues(PlayerProfile profile) { @@ -64,7 +64,7 @@ public class FormulaConversionTask extends BukkitRunnable { continue; } - int[] newExperienceValues = mcMMO.getFormulaManager().calculateNewLevel(primarySkillType, (int) Math.floor(totalOldXP / 1.0), previousFormula); + int[] newExperienceValues = mcMMO.getFormulaManager().calculateNewLevel(primarySkillType, (int) Math.floor(totalOldXP / 1.0)); int newLevel = newExperienceValues[0]; int newXPlevel = newExperienceValues[1]; diff --git a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java index 75ead3b25..ef1993cf3 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java @@ -59,16 +59,15 @@ public class FormulaManager { * * @param primarySkillType skill where new levels and experience are calculated for * @param experience total amount of experience - * @param formulaType The new {@link FormulaType} * @return the amount of levels and experience */ - public int[] calculateNewLevel(PrimarySkillType primarySkillType, int experience, FormulaType formulaType) { + public int[] calculateNewLevel(PrimarySkillType primarySkillType, int experience) { int newLevel = 0; int remainder = 0; int maxLevel = mcMMO.getConfigManager().getConfigLeveling().getLevelCap(primarySkillType); while (experience > 0 && newLevel < maxLevel) { - int experienceToNextLevel = getXPtoNextLevel(newLevel, formulaType); + int experienceToNextLevel = getXPtoNextLevel(newLevel, currentFormula); if (experience - experienceToNextLevel < 0) { remainder = experience; @@ -198,4 +197,8 @@ public class FormulaManager { return calculateXPNeeded(level, FormulaType.LINEAR); } } + + public void setCurrentFormula(FormulaType currentFormula) { + this.currentFormula = currentFormula; + } } \ No newline at end of file diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 0e755adb5..28aa9c2ef 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -605,8 +605,8 @@ Commands.mcconvert.Database.Finish=[[GRAY]]Database migration complete; the {1} Commands.mmoshowdb=The currently used database is [[GREEN]]{0} Commands.mcconvert.Experience.Invalid=Unknown formula type! Valid types are: [[GREEN]]LINEAR [[RED]]and [[GREEN]]EXPONENTIAL. Commands.mcconvert.Experience.Same=Already using formula type {0} -Commands.mcconvert.Experience.Start=[[GRAY]]Starting conversion from {0} to {1} curve -Commands.mcconvert.Experience.Finish=[[GRAY]]Formula conversion complete; now using {0} XP curve. +Commands.mcconvert.Experience.Start=[[GRAY]]Starting conversion from {0} to {1} experience formula +Commands.mcconvert.Experience.Finish=[[GRAY]]Formula conversion complete; now using {0} XP exp Commands.ModDescription=[[GREEN]]- Read brief mod description Commands.NoConsole=This command does not support console usage. Commands.Notifications.Off=Ability notifications toggled [[RED]]off