From c968b9f94a3e8e63950fd38dfa5ce899ec083ff0 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 7 May 2019 00:09:31 -0700 Subject: [PATCH] Add and wire up Early Game Boost settings --- .../com/gmail/nossr50/api/ExperienceAPI.java | 1 - .../gmail/nossr50/commands/XprateCommand.java | 1 - .../config/experience/ExperienceConfig.java | 3 -- .../ConfigLevelEarlyGameBoost.java | 29 +++++++++++++++++++ .../hocon/playerleveling/ConfigLeveling.java | 16 ++++++++++ .../datatypes/player/PlayerProfile.java | 1 - .../gmail/nossr50/listeners/SelfListener.java | 2 +- .../gmail/nossr50/locale/LocaleLoader.java | 7 +---- .../database/UUIDUpdateAsyncTask.java | 4 +-- .../nossr50/skills/excavation/Excavation.java | 2 -- .../gmail/nossr50/skills/mining/Mining.java | 2 -- .../skills/woodcutting/Woodcutting.java | 2 -- .../nossr50/util/player/PlayerLevelUtils.java | 8 ++--- 13 files changed, 52 insertions(+), 26 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLevelEarlyGameBoost.java diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index 73f9a6e7c..558c17c39 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.api; import com.gmail.nossr50.api.exceptions.*; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainSource; diff --git a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java index 59b0182ef..0c788a39d 100644 --- a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands; import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; diff --git a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java index 71a477be2..4a0912be0 100644 --- a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java +++ b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java @@ -118,9 +118,6 @@ public class ExperienceConfig extends ConfigValidated { return reason; } - public boolean isEarlyGameBoostEnabled() { return config.getBoolean("EarlyGameBoost.Enabled", true); } - public double getEarlyGameBoostMultiplier() { return config.getDouble("EarlyGameBoost.MaxLevelMultiplier", 0.05D); } - /* * FORMULA SETTINGS */ diff --git a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLevelEarlyGameBoost.java b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLevelEarlyGameBoost.java new file mode 100644 index 000000000..51af9d43a --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLevelEarlyGameBoost.java @@ -0,0 +1,29 @@ +package com.gmail.nossr50.config.hocon.playerleveling; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigLevelEarlyGameBoost { + + public static final boolean EARLY_GAME_BOOST_DEFAULT = true; + public static final double BOOST_MULTIPLIER_DEFAULT = 0.05D; + + @Setting(value = "Enabled", comment = "If set to true, the early game XP boost will be applied." + + "\nDefault value: "+EARLY_GAME_BOOST_DEFAULT) + private boolean enableEarlyGameBoost = EARLY_GAME_BOOST_DEFAULT; + + @Setting(value = "Max-Level-Percentage", comment = "This value is multiplied by a skills level cap to see determine when to stop giving a boost." + + "\nLevels in mcMMO are not capped by default, so if the skill has no set level cap it will instead use the value 100 or 1000 (if in RetroMode)" + + "\nWith default settings, this will result in the first 5 levels (or 50 in Retro) being boosted" + + "\nDefault value: "+BOOST_MULTIPLIER_DEFAULT) + private double earlyGameBoostMultiplier = BOOST_MULTIPLIER_DEFAULT; + + public double getEarlyGameBoostMultiplier() { + return earlyGameBoostMultiplier; + } + + public boolean isEnableEarlyGameBoost() { + return enableEarlyGameBoost; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java index 6811821c3..4894b94ea 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java @@ -20,6 +20,10 @@ public class ConfigLeveling { @Setting(value = "General", comment = "Settings for player leveling that don't fall into other categories") private ConfigSectionLevelingGeneral configSectionLevelingGeneral = new ConfigSectionLevelingGeneral(); + @Setting(value = "Early-Game-Boost", comment = "mcMMO incorporates an early game XP boost to get players to the first abilities in each skill faster." + + "\nUsing default settings, players will reach level 5 (or 50 in RetroMode) much faster than they normally would.") + private ConfigLevelEarlyGameBoost earlyGameBoost = new ConfigLevelEarlyGameBoost(); + @Setting(value = "Experience-Formula") private ConfigExperienceFormula configExperienceFormula = new ConfigExperienceFormula(); @@ -27,6 +31,18 @@ public class ConfigLeveling { * GETTER BOILERPLATE */ + public double getEarlyGameBoostMultiplier() { + return earlyGameBoost.getEarlyGameBoostMultiplier(); + } + + public boolean isEnableEarlyGameBoost() { + return earlyGameBoost.isEnableEarlyGameBoost(); + } + + public ConfigLevelEarlyGameBoost getEarlyGameBoost() { + return earlyGameBoost; + } + public ConfigSectionLevelCaps getConfigSectionLevelCaps() { return configSectionLevelCaps; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index 87a86cbce..c73c20d0c 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.datatypes.player; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.datatypes.experience.SkillXpGain; diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index ab229d9d2..e0f10d254 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -88,7 +88,7 @@ public class SelfListener implements Listener { return; } - if(ExperienceConfig.getInstance().isEarlyGameBoostEnabled()) + if(mcMMO.getConfigManager().getConfigLeveling().isEnableEarlyGameBoost()) { int earlyGameBonusXP = 0; diff --git a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java index 04b9ef54b..fa626670e 100644 --- a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java +++ b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java @@ -9,12 +9,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.text.MessageFormat; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; +import java.util.*; import java.util.logging.Level; public final class LocaleLoader { diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java index 269e90af3..195b6927c 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.runnables.database; -import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.database.DatabaseManager; -import com.gmail.nossr50.datatypes.database.UpgradeType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.uuid.UUIDFetcher; @@ -98,7 +96,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { } if (fetchedUUIDs.size() == 0 || mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs)) { - mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS); + //mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS); plugin.getLogger().info("UUID upgrade completed!"); } } diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java index f5992dd82..e693b238c 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.skills.excavation; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig; -import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; diff --git a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java index f7c96f73a..abd491565 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.skills.mining; -import com.gmail.nossr50.config.experience.ExperienceConfig; -import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index 59f8c923a..cb8f7428c 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.skills.woodcutting; import com.gmail.nossr50.config.MainConfig; -import com.gmail.nossr50.config.experience.ExperienceConfig; -import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.Misc; diff --git a/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java b/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java index ec022c424..782779643 100644 --- a/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java +++ b/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java @@ -1,8 +1,8 @@ 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 com.gmail.nossr50.mcMMO; import java.util.HashMap; @@ -19,14 +19,14 @@ public class PlayerLevelUtils { { for(PrimarySkillType primarySkillType : PrimarySkillType.values()) { - int levelCap = Config.getInstance().getLevelCap(primarySkillType); + int levelCap = mcMMO.getConfigManager().getConfigLeveling().getLevelCap(primarySkillType); int cap; if(levelCap == Integer.MAX_VALUE || levelCap <= 0) { - cap = Config.getInstance().getIsRetroMode() ? 50 : 5; + cap = mcMMO.isRetroModeEnabled() ? 50 : 5; } else { - cap = (int) (levelCap * ExperienceConfig.getInstance().getEarlyGameBoostMultiplier()); + cap = (int) (levelCap * mcMMO.getConfigManager().getConfigLeveling().getEarlyGameBoostMultiplier()); } earlyGameBoostCutoffs.put(primarySkillType, cap);