From 9111590dc2a9bb6a1c12fefc13167a1d88470cd4 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 31 May 2019 19:46:14 -0700 Subject: [PATCH] 2.1.67 --- Changelog.txt | 15 +++++++++++++++ pom.xml | 2 +- .../com/gmail/nossr50/listeners/SelfListener.java | 5 ++++- .../util/experience/ExperienceBarWrapper.java | 15 ++++++++++++--- .../nossr50/util/player/PlayerLevelUtils.java | 13 +++++++++++++ src/main/resources/locale/locale_en_US.properties | 2 ++ 6 files changed, 47 insertions(+), 5 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index f3159210a..bd26807ff 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,18 @@ +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/pom.xml b/pom.xml index 183d97c51..12bb66f14 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.66 + 2.1.67 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index 492bd7cee..bf1c7b461 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -9,6 +9,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; @@ -101,7 +102,7 @@ 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); @@ -156,4 +157,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 9fcad6fbb..88351dc00 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.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.locale.LocaleLoader; 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,6 @@ public class ExperienceBarWrapper { private final PrimarySkillType primarySkillType; //Primary Skill private BossBar bossBar; - private final Server server; protected final McMMOPlayer mcMMOPlayer; private int lastLevelUpdated; @@ -33,7 +33,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; @@ -58,7 +57,10 @@ public class ExperienceBarWrapper { private String getTitleTemplate() { //If they are using extra details - if(ExperienceConfig.getInstance().getAddExtraDetails()) + + if(ExperienceConfig.getInstance().isEarlyGameBoostEnabled() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) { + return LocaleLoader.getString("XPBar.Template.EarlyGameBoost"); + } else if(ExperienceConfig.getInstance().getAddExtraDetails()) 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()); @@ -106,6 +108,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 || ExperienceConfig.getInstance().getDoExperienceBarsAlwaysUpdateTitle()) { 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..a032fcfb0 100644 --- a/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java +++ b/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java @@ -2,7 +2,9 @@ package com.gmail.nossr50.util.player; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.experience.ExperienceConfig; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.mcMMO; import java.util.HashMap; @@ -37,4 +39,15 @@ public class PlayerLevelUtils { { return earlyGameBoostCutoffs.get(primarySkillType); } + + /** + * 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 04a0e5f1f..fbdcb09d9 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -103,6 +103,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}