Skip to content

Commit

Permalink
Add boss_bar.level_xp_format option to change level XP display
Browse files Browse the repository at this point in the history
  • Loading branch information
Archy-X committed Sep 3, 2024
1 parent f71a0ec commit 0abe4c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class BossBarManager implements Listener {
private Map<Skill, BossBar.Color> colors;
private Map<Skill, BossBar.Overlay> overlays;
private NumberFormat xpFormat;
private NumberFormat levelXpFormat;
private NumberFormat percentFormat;
private NumberFormat moneyFormat;
private final AuraSkills plugin;
Expand Down Expand Up @@ -75,13 +76,15 @@ public NumberFormat getMoneyFormat() {
private void loadNumberFormats() {
try {
this.xpFormat = new DecimalFormat(plugin.configString(Option.BOSS_BAR_XP_FORMAT));
this.levelXpFormat = new DecimalFormat(plugin.configString(Option.BOSS_BAR_LEVEL_XP_FORMAT));
this.percentFormat = new DecimalFormat(plugin.configString(Option.BOSS_BAR_PERCENT_FORMAT));
this.moneyFormat = new DecimalFormat(plugin.configString(Option.BOSS_BAR_MONEY_FORMAT));
} catch (IllegalArgumentException e) {
this.xpFormat = new DecimalFormat("#.#");
this.levelXpFormat = new DecimalFormat("0");
this.percentFormat = new DecimalFormat("#.##");
this.moneyFormat = new DecimalFormat("#.00");
plugin.logger().warn("Invalid boss_bar.xp_format or percent_format: " + e.getMessage());
plugin.logger().warn("Invalid boss_bar format: " + e.getMessage());
}
}

Expand Down Expand Up @@ -252,7 +255,7 @@ private String getLevelXpText(long levelXp) {
if (plugin.configBoolean(Option.BOSS_BAR_USE_SUFFIX)) {
return BigNumber.withSuffix(levelXp);
} else {
return String.valueOf(levelXp);
return levelXpFormat.format(levelXp);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public enum Option {
BOSS_BAR_USE_SUFFIX("boss_bar.use_suffix", OptionType.BOOLEAN),
BOSS_BAR_FORMAT("boss_bar.format", OptionType.LIST),
BOSS_BAR_XP_FORMAT("boss_bar.xp_format", OptionType.STRING),
BOSS_BAR_LEVEL_XP_FORMAT("boss_bar.level_xp_format", OptionType.STRING),
BOSS_BAR_PERCENT_FORMAT("boss_bar.percent_format", OptionType.STRING),
BOSS_BAR_MONEY_FORMAT("boss_bar.money_format", OptionType.STRING),
BOSS_BAR_ANIMATE_PROGRESS("boss_bar.animate_progress", OptionType.BOOLEAN),
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ boss_bar:
- 'HEALING WHITE PROGRESS'
- 'FORGING YELLOW PROGRESS'
xp_format: '#.#'
level_xp_format: '0'
percent_format: '#.##'
money_format: '0.00'
animate_progress: true
Expand Down

0 comments on commit 0abe4c8

Please sign in to comment.