mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Still some work to do, but now the convert XP command is less clunky
This commit is contained in:
parent
84b9b255aa
commit
1532791c3f
@ -16,32 +16,32 @@ public class ConvertExperienceCommand implements CommandExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
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"));
|
for(FormulaType formulaType : FormulaType.values()) {
|
||||||
return true;
|
if(formulaType.toString().equalsIgnoreCase(args[1])) {
|
||||||
}
|
FormulaType previousType = formulaType;
|
||||||
|
|
||||||
if (previousType == newType) {
|
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), mcMMO.getConfigManager().getConfigLeveling().getFormulaType().toString()));
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Same", newType.toString()));
|
|
||||||
return true;
|
UserManager.saveAll();
|
||||||
}
|
UserManager.clearAll();
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString()));
|
new FormulaConversionTask(sender, previousType).runTaskLater(mcMMO.p, 1);
|
||||||
|
|
||||||
UserManager.saveAll();
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
UserManager.clearAll();
|
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||||
|
}
|
||||||
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
|
|
||||||
|
return true;
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -28,18 +28,6 @@ public class ConfigSectionPartyLevel {
|
|||||||
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.CHAT, PARTY_CHAT_DEFAULT);
|
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",
|
@Setting(value = "Party-Leveling-Requires-Nearby-Party-Members",
|
||||||
comment = "If leveling your Party requires being near another party member." +
|
comment = "If leveling your Party requires being near another party member." +
|
||||||
"\nDefault value: " + PARTY_LEVELING_NEEDS_NERBY_MEMBERS_DEFAULT)
|
"\nDefault value: " + PARTY_LEVELING_NEEDS_NERBY_MEMBERS_DEFAULT)
|
||||||
|
@ -205,8 +205,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
if (getScoreboardSettings().getScoreboardsEnabled())
|
if (getScoreboardSettings().getScoreboardsEnabled())
|
||||||
ScoreboardManager.teardownAll();
|
ScoreboardManager.teardownAll();
|
||||||
|
|
||||||
formulaManager.saveFormula();
|
|
||||||
/*holidayManager.saveAnniversaryFiles();*/
|
|
||||||
placeStore.saveAll(); // Save our metadata
|
placeStore.saveAll(); // Save our metadata
|
||||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -49,7 +49,7 @@ public class FormulaConversionTask extends BukkitRunnable {
|
|||||||
Misc.printProgress(convertedUsers, DatabaseManager.progressInterval, startMillis);
|
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) {
|
private void editValues(PlayerProfile profile) {
|
||||||
@ -64,7 +64,7 @@ public class FormulaConversionTask extends BukkitRunnable {
|
|||||||
continue;
|
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 newLevel = newExperienceValues[0];
|
||||||
int newXPlevel = newExperienceValues[1];
|
int newXPlevel = newExperienceValues[1];
|
||||||
|
|
||||||
|
@ -59,16 +59,15 @@ public class FormulaManager {
|
|||||||
*
|
*
|
||||||
* @param primarySkillType skill where new levels and experience are calculated for
|
* @param primarySkillType skill where new levels and experience are calculated for
|
||||||
* @param experience total amount of experience
|
* @param experience total amount of experience
|
||||||
* @param formulaType The new {@link FormulaType}
|
|
||||||
* @return the amount of levels and experience
|
* @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 newLevel = 0;
|
||||||
int remainder = 0;
|
int remainder = 0;
|
||||||
int maxLevel = mcMMO.getConfigManager().getConfigLeveling().getLevelCap(primarySkillType);
|
int maxLevel = mcMMO.getConfigManager().getConfigLeveling().getLevelCap(primarySkillType);
|
||||||
|
|
||||||
while (experience > 0 && newLevel < maxLevel) {
|
while (experience > 0 && newLevel < maxLevel) {
|
||||||
int experienceToNextLevel = getXPtoNextLevel(newLevel, formulaType);
|
int experienceToNextLevel = getXPtoNextLevel(newLevel, currentFormula);
|
||||||
|
|
||||||
if (experience - experienceToNextLevel < 0) {
|
if (experience - experienceToNextLevel < 0) {
|
||||||
remainder = experience;
|
remainder = experience;
|
||||||
@ -198,4 +197,8 @@ public class FormulaManager {
|
|||||||
return calculateXPNeeded(level, FormulaType.LINEAR);
|
return calculateXPNeeded(level, FormulaType.LINEAR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCurrentFormula(FormulaType currentFormula) {
|
||||||
|
this.currentFormula = currentFormula;
|
||||||
|
}
|
||||||
}
|
}
|
@ -605,8 +605,8 @@ Commands.mcconvert.Database.Finish=[[GRAY]]Database migration complete; the {1}
|
|||||||
Commands.mmoshowdb=The currently used database is [[GREEN]]{0}
|
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.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.Same=Already using formula type {0}
|
||||||
Commands.mcconvert.Experience.Start=[[GRAY]]Starting conversion from {0} to {1} 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 curve.
|
Commands.mcconvert.Experience.Finish=[[GRAY]]Formula conversion complete; now using {0} XP exp
|
||||||
Commands.ModDescription=[[GREEN]]- Read brief mod description
|
Commands.ModDescription=[[GREEN]]- Read brief mod description
|
||||||
Commands.NoConsole=This command does not support console usage.
|
Commands.NoConsole=This command does not support console usage.
|
||||||
Commands.Notifications.Off=Ability notifications toggled [[RED]]off
|
Commands.Notifications.Off=Ability notifications toggled [[RED]]off
|
||||||
|
Loading…
Reference in New Issue
Block a user