diff --git a/Changelog.txt b/Changelog.txt index 52c603706..e203f2f92 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -156,6 +156,21 @@ Version 2.2.0 Added API method to check if a skill was being level capped Added 'UndefinedSkillBehaviour' for trying to use a method that has no behaviour defined for the provided skill +Version 2.1.67 + The XP bar now reflects whether or not the player is receiving the early game boost + Players who are receiving an early game boost will be shown "Learning a skill..." as the title of the XP bar while gaining XP + New locale string 'XPBar.Template.EarlyGameBoost' + + NOTES: + You can turn off this system in experience.yml 'EarlyGameBoost.Enabled' + The Early Game Boost is a system in which players receive drastically increased XP gains for the first few levels (until the first set of skills are unlocked) + With default settings, this means players will be receiving boosted XP for the first 5 levels (50 for Retro) + The Early Game Boost ends when players get the first skill in each ability under default settings + The main purpose of this system is to alleviate progression issues with a few skills where the first set of unlocked abilities drastically increase how fun it is to level the skill + The secondary purpose of this system is to alleviate any psychological issues when grinding towards the first set of unlocks by making the first set of unlocks happen quickly + This system has been in place for a few versions now, but without an in game indicator of what was going on. + If you have XP bars off there is still no indicator that this system is in place, I'll address that at some point. + Version 2.1.66 Fixed a bug that could happen if a player was removed from the DB when using MySQL/MariaDB when the user was offline Fixed a minor memory leak for MySQL diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index 51528e02b..21408d1c8 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -8,6 +8,7 @@ import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent; import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent; import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.util.player.PlayerLevelUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.skills.RankUtils; @@ -92,7 +93,8 @@ public class SelfListener implements Listener { int earlyGameBonusXP = 0; //Give some bonus XP for low levels - if (mcMMOPlayer.getSkillLevel(primarySkillType) <= mcMMO.getPlayerLevelUtils().getEarlyGameCutoff(primarySkillType)) { + if(PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) + { earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05); event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP); } @@ -144,4 +146,6 @@ public class SelfListener implements Listener { } } + + } diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java index b86ea25ba..96f9391d7 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java @@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.player.PlayerLevelUtils; import org.bukkit.Server; import org.bukkit.boss.BarColor; import org.bukkit.boss.BarStyle; @@ -20,7 +21,14 @@ public class ExperienceBarWrapper { protected final McMMOPlayer mcMMOPlayer; private final PrimarySkillType primarySkillType; //Primary Skill +<<<<<<< HEAD private final Server server; +======= + private BossBar bossBar; + protected final McMMOPlayer mcMMOPlayer; + private int lastLevelUpdated; + +>>>>>>> 9111590dc2a9bb6a1c12fefc13167a1d88470cd4 /* * This is stored to help optimize updating the title */ @@ -31,7 +39,6 @@ public class ExperienceBarWrapper { public ExperienceBarWrapper(PrimarySkillType primarySkillType, McMMOPlayer mcMMOPlayer) { this.mcMMOPlayer = mcMMOPlayer; - this.server = mcMMOPlayer.getPlayer().getServer(); //Might not be good for bungee to do this this.primarySkillType = primarySkillType; title = ""; lastLevelUpdated = 0; @@ -55,8 +62,10 @@ public class ExperienceBarWrapper { private String getTitleTemplate() { //If they are using extra details - if (mcMMO.getConfigManager().getConfigLeveling().isMoreDetailedXPBars()) - return LocaleLoader.getString("XPBar.Complex.Template", LocaleLoader.getString("XPBar." + niceSkillName, getLevel()), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel()); + if(mcMMO.getConfigManager().getConfigLeveling().getEarlyGameBoost().isEnableEarlyGameBoost() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) { + return LocaleLoader.getString("XPBar.Template.EarlyGameBoost"); + } else if(mcMMO.getConfigManager().getConfigLeveling().getConfigExperienceBars().isMoreDetailedXPBars()) + return LocaleLoader.getString("XPBar.Complex.Template", LocaleLoader.getString("XPBar."+niceSkillName, getLevel()), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel()); return LocaleLoader.getString("XPBar." + niceSkillName, getLevel(), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel()); } @@ -119,6 +128,13 @@ public class ExperienceBarWrapper { else bossBar.setProgress(v); + //Check player level + if(ExperienceConfig.getInstance().isEarlyGameBoostEnabled() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) { + setColor(BarColor.YELLOW); + } else { + setColor(ExperienceConfig.getInstance().getExperienceBarColor(primarySkillType)); + } + //Every time progress updates we need to check for a title update if (getLevel() != lastLevelUpdated || mcMMO.getConfigManager().getConfigLeveling().isMoreDetailedXPBars()) { updateTitle(); 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 f0f87a905..e63afcfb4 100644 --- a/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java +++ b/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.util.player; import com.gmail.nossr50.datatypes.experience.CustomXPPerk; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; @@ -131,4 +132,14 @@ public class PlayerLevelUtils { } + /** + * Check if a player is currently qualifying for the early game boosted XP + * Will return false only if a player is above the boost level cutoff, it does not check config settings to see if the early game boost is on + * @param mcMMOPlayer target player + * @param primarySkillType target skill + * @return if the player would qualify for the XP boost if its enabled + */ + public static boolean qualifiesForEarlyGameBoost(McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType) { + return mcMMOPlayer.getSkillLevel(primarySkillType) < mcMMO.getPlayerLevelUtils().getEarlyGameCutoff(primarySkillType); + } } diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 340ad5a18..f41620c2f 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -98,6 +98,8 @@ Commands.Party.Header=[[RED]]-----[][[GREEN]]PARTY[[RED]][]----- Commands.Party.Features.Header=[[RED]]-----[][[GREEN]]FEATURES[[RED]][]----- # XP BAR Allows for the following variables -- {0} = Skill Level, {1} Current XP, {2} XP Needed for next level, {3} Power Level, {4} Percentage of Level # Make sure you turn on Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained if you want the XP bar title to update every time a player gains XP! +XPBar.Template={0} +XPBar.Template.EarlyGameBoost=[[GOLD]]Learning a new skill... XPBar.Acrobatics=Acrobatics Lv.[[GOLD]]{0} XPBar.Alchemy=Alchemy Lv.[[GOLD]]{0} XPBar.Archery=Archery Lv.[[GOLD]]{0}