Skip to content

Commit

Permalink
Move action_bar messages to global.yml and fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Archy-X committed Dec 10, 2023
1 parent 6560214 commit 1d7711c
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public void run() {
}
}
};
plugin.getScheduler().timerSync(task, 50, 500, TimeUnit.MILLISECONDS);
plugin.getScheduler().timerSync(task, 50, 10 * 50, TimeUnit.MILLISECONDS);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ private String getBossBarText(Player player, Skill skill, double currentXp, long
"{current_xp}", currentXpText,
"{level_xp}", getLevelXpText(levelXp),
"{percent}", NumberUtil.format2(currentXp / (double) levelXp * 100),
"{xp_gained}", NumberUtil.format1(xpGained)));
"{xp_gained}", xpGained > 0 ? "+" + NumberUtil.format1(xpGained) : NumberUtil.format1(xpGained)));
} else {
bossBarText = setPlaceholders(player, TextUtil.replace(plugin.getMsg(ActionBarMessage.BOSS_BAR_MAXED, locale),
"{skill}", skill.getDisplayName(locale),
"{level}", RomanNumber.toRoman(level, plugin),
"{current_xp}", currentXpText,
"{xp_gained}", NumberUtil.format1(xpGained)));
"{xp_gained}", xpGained > 0 ? "+" + NumberUtil.format1(xpGained) : NumberUtil.format1(xpGained)));
}
return bossBarText;
}
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {
api("co.aikar:acf-core:0.5.1-SNAPSHOT")
api("net.kyori:adventure-text-serializer-legacy:4.13.1")
api("net.kyori:adventure-text-serializer-gson:4.13.1")
api("com.github.Archy-X:Polyglot:f8fd242fc1")
api("com.github.Archy-X:Polyglot:6c05ba05b1")
api("org.spongepowered:configurate-yaml:4.1.2")
implementation("com.zaxxer:HikariCP:5.0.1")
implementation("com.ezylang:EvalEx:3.0.4")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ public enum ActionBarMessage implements MessageKey {

IDLE,
XP,
XP_REMOVED,
MAXED,
MAXED_REMOVED,
ABILITY,
BOSS_BAR_XP,
BOSS_BAR_MAXED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void startTimerCountdown() {
var task = new TaskRunnable() {
@Override
public void run() {
if (plugin.configBoolean(Option.ACTION_BAR_ENABLED)) {
if (!plugin.configBoolean(Option.ACTION_BAR_ENABLED)) {
return;
}

Expand All @@ -55,7 +55,7 @@ public void run() {
}
}
};
plugin.getScheduler().timerSync(task, 0, 2, TimeUnit.MILLISECONDS);
plugin.getScheduler().timerSync(task, 0, 2 * 50L, TimeUnit.MILLISECONDS);
}

public void startUpdatingIdleActionBar() {
Expand Down Expand Up @@ -91,7 +91,7 @@ public void run() {
}
}
};
plugin.getScheduler().timerSync(task, 0, plugin.configInt(Option.ACTION_BAR_UPDATE_PERIOD), TimeUnit.MILLISECONDS);
plugin.getScheduler().timerSync(task, 0, plugin.configInt(Option.ACTION_BAR_UPDATE_PERIOD) * 50L, TimeUnit.MILLISECONDS);
}

public void sendXpActionBar(User user, Skill skill, double currentXp, double levelXp, double xpGained, int level, boolean maxed) {
Expand Down Expand Up @@ -140,16 +140,17 @@ public void run() {
String message = getXpActionBarMessage(user, skill, currentXp, levelXp, xpGained, level, maxed);
uiProvider.sendActionBar(user, message);
}
}, 0, plugin.configInt(Option.ACTION_BAR_UPDATE_PERIOD), TimeUnit.MILLISECONDS);
}, 0, plugin.configInt(Option.ACTION_BAR_UPDATE_PERIOD) * 50L, TimeUnit.MILLISECONDS);
// Schedule task to stop updating action bar
plugin.getScheduler().scheduleSync(() -> {
Integer timerNum = timer.get(uuid);
if (timerNum != null) {
plugin.logger().debug("Timer is " + (int) timerNum);
if (timerNum.equals(0)) {
isGainingXp.remove(uuid);
}
}
}, 41, TimeUnit.MILLISECONDS);
}, 41 * 50L, TimeUnit.MILLISECONDS);
}

public void resetActionBars() {
Expand Down Expand Up @@ -202,18 +203,14 @@ public void sendAbilityActionBar(User user, String message) {

private String getXpActionBarMessage(User user, Skill skill, double currentXp, double levelXp, double xpGained, int level, boolean maxed) {
ActionBarMessage messageKey = maxed ? ActionBarMessage.MAXED : ActionBarMessage.XP;
if (xpGained < 0) {
messageKey = maxed ? ActionBarMessage.MAXED_REMOVED : ActionBarMessage.XP_REMOVED;
}
Locale locale = user.getLocale();

String message = plugin.getMsg(messageKey, locale);
// Replace built in placeholders
message = TextUtil.replace(message,
"{hp}", getHp(user),
"{max_hp}", getMaxHp(user),
"{xp_gained}", NumberUtil.format1(xpGained),
"{xp_removed}", NumberUtil.format1(xpGained),
"{xp_gained}", xpGained > 0 ? "+" + NumberUtil.format1(xpGained) : NumberUtil.format1(xpGained),
"{skill}", skill.getDisplayName(locale),
"{current_xp}", NumberUtil.format1(currentXp),
"{level_xp}", NumberUtil.format1(levelXp),
Expand Down
9 changes: 9 additions & 0 deletions common/src/main/resources/messages/global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
# This file defines formats and styles
# common across all languages
# -----------------------------------
action_bar:
idle: "{{action_bar.hp_display}} {{action_bar.mana_display}}"
hp_display: "<red>{hp}/{max_hp}❤"
mana_display: "<aqua>{mana}/{max_mana} {{units.mana}}"
xp: "{{action_bar.hp_display}} <gold>{xp_gained} {skill} {{units.xp}} <gray>({current_xp}/{level_xp} {{units.xp}}) {{action_bar.mana_display}}"
maxed: "{{action_bar.hp_display}} <gold>{xp_gained} {skill} {{units.xp}} <gray>({{ui.maxed}}) {{action_bar.mana_display}}"
ability: "{message}"
boss_bar_xp: "<gold>{xp_gained} {skill} {{units.xp}} <gray>({percent}%)"
boss_bar_maxed: "<gold>{xp_gained} {skill} {{units.xp}} <gray>({{ui.maxed}})"
leveler_format:
title: "<green>{{leveler.level_up}}"
subtitle: "<gold>{old} ➜ {new}"
Expand Down
11 changes: 2 additions & 9 deletions common/src/main/resources/messages/messages_de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,6 @@ acf:
location_please_specify_world: "<red>Fehler: Bitte die Welt angeben. Beispiel: <yellow>world:x,y,z."
location_please_specify_xyz: "<red>Fehler: Bitte die Koordinaten x, y und z angeben. Beispiel: <yellow>world:x,y,z."
location_console_not_relative: "<red>Fehler: Konsole darf keine relativen Koordinaten für den Standort verwenden."
action_bar:
idle: "<red>{hp}/{max_hp}❤ <aqua>{mana}/{max_mana} {mana_unit}"
xp: "<red>{hp}/{max_hp}❤ <gold>+{xp_gained} {skill} {xp_unit} <gray>({current_xp}/{level_xp} {xp_unit}) <aqua>{mana}/{max_mana} {mana_unit}"
xp_removed: "<red>{hp}/{max_hp}❤ <gold>-{xp_removed} {skill} {xp_unit} <gray>({current_xp}/{level_xp} {xp_unit}) <aqua>{mana}/{max_mana} {mana_unit}"
maxed: "<red>{hp}/{max_hp}❤ <gold>+{xp_gained} {skill} {xp_unit} <gray>(MAXED) <aqua>{mana}/{max_mana} {mana_unit}"
maxed_removed: "<red>{hp}/{max_hp}❤ <gold>-{xp_removed} {skill} {xp_unit} <gray>(MAXED) <aqua>{mana}/{max_mana} {mana_unit}"
ability: "{message}"
boss_bar_xp: "<gold>{skill} {level} <gray>({current_xp}/{level_xp} {xp_unit})"
boss_bar_maxed: "<gold>{skill} {level} <gray>(HÖCHSTLEVEL)"
commands:
prefix: "<dark_gray>[<aqua>Fertigkeiten<dark_gray>]<reset> "
armor:
Expand Down Expand Up @@ -1056,6 +1047,8 @@ traits:
name: Kritischer Schaden
movement_speed:
name: Bewegungsgeschwindigkeit
ui:
maxed: MAXED
units:
mana: Mana
hp: LP
Expand Down
11 changes: 2 additions & 9 deletions common/src/main/resources/messages/messages_en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,6 @@ acf:
location_please_specify_world: "<red>Error: Please specify world. Example: <yellow>world:x,y,z."
location_please_specify_xyz: "<red>Error: Please specify the coordinates x, y, and z. Example: <yellow>world:x,y,z."
location_console_not_relative: "<red>Error: Console may not use relative coordinates for location."
action_bar:
idle: "<red>{hp}/{max_hp}❤ <aqua>{mana}/{max_mana} {mana_unit}"
xp: "<red>{hp}/{max_hp}❤ <gold>+{xp_gained} {skill} {xp_unit} <gray>({current_xp}/{level_xp} {xp_unit}) <aqua>{mana}/{max_mana} {mana_unit}"
xp_removed: "<red>{hp}/{max_hp}❤ <gold>-{xp_removed} {skill} {xp_unit} <gray>({current_xp}/{level_xp} {xp_unit}) <aqua>{mana}/{max_mana} {mana_unit}"
maxed: "<red>{hp}/{max_hp}❤ <gold>+{xp_gained} {skill} {xp_unit} <gray>(MAXED) <aqua>{mana}/{max_mana} {mana_unit}"
maxed_removed: "<red>{hp}/{max_hp}❤ <gold>-{xp_removed} {skill} {xp_unit} <gray>(MAXED) <aqua>{mana}/{max_mana} {mana_unit}"
ability: "{message}"
boss_bar_xp: "<gold>+{xp_gained} {skill} XP <gray>({percent}%)"
boss_bar_maxed: "<gold>+{xp_gained} {skill} XP <gray>(MAXED)"
commands:
prefix: "<dark_gray>[<aqua>Skills<dark_gray>]<reset> "
armor:
Expand Down Expand Up @@ -1056,6 +1047,8 @@ traits:
name: Crit Damage
movement_speed:
name: Movement Speed
ui:
maxed: MAXED
units:
mana: Mana
hp: HP
Expand Down
11 changes: 2 additions & 9 deletions common/src/main/resources/messages/messages_es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,6 @@ acf:
location_please_specify_world: "<red>Error: Por favor especifique un mundo. Ejemplo <yellow>world:x,y,z."
location_please_specify_xyz: "<red>Error: Por favor especifica las coordenadas x, y, z. Ejemplo: <yellow>world:x,y,z."
location_console_not_relative: "<red>Error: La consola no puede usar coordenadas relativas para la ubicación."
action_bar:
idle: "<red>{hp}/{max_hp}❤ <aqua>{mana}/{max_mana} {mana_unit}"
xp: "<red>{hp}/{max_hp}❤ <gold>+{xp_gained} {skill} {xp_unit} <gray>({current_xp}/{level_xp} {xp_unit}) <aqua>{mana}/{max_mana} {mana_unit}"
xp_removed: "<red>{hp}/{max_hp}❤ <gold>-{xp_removed} {skill} {xp_unit} <gray>({current_xp}/{level_xp} {xp_unit}) <aqua>{mana}/{max_mana} {mana_unit}"
maxed: "<red>{hp}/{max_hp}❤ <gold>+{xp_gained} {skill} {xp_unit} <gray>(MAXED) <aqua>{mana}/{max_mana} {mana_unit}"
maxed_removed: "<red>{hp}/{max_hp}❤ <gold>-{xp_removed} {skill} {xp_unit} <gray>(MAXED) <aqua>{mana}/{max_mana} {mana_unit}"
ability: "{message}"
boss_bar_xp: "<gold>{skill} {level} <gray>({current_xp}/{level_xp} {xp_unit})"
boss_bar_maxed: "<gold>{skill} {level} <gray>(MAXED)"
commands:
prefix: "<dark_gray>[<aqua>Skills<dark_gray>] "
armor:
Expand Down Expand Up @@ -1056,6 +1047,8 @@ traits:
name: Daño Crítico
movement_speed:
name: Velocidad
ui:
maxed: MAXED
units:
mana: Maná
hp: HP
Expand Down
11 changes: 2 additions & 9 deletions common/src/main/resources/messages/messages_fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,6 @@ acf:
location_please_specify_world: "<red>Erreur: Veuillez spécifier le monde. Exemple: <yellow>world:x,y,z."
location_please_specify_xyz: "<red>Erreur: Veuillez spécifier les coordonnées x, y et z. Exemple: <yellow>world:x,y,z."
location_console_not_relative: "<red>Erreur: La console ne peut pas utiliser de coordonnées relatives pour l'emplacement."
action_bar:
idle: "<red>{hp}/{max_hp}❤ <aqua>{mana}/{max_mana} {mana_unit}"
xp: "<red>{hp}/{max_hp}❤ <gold>+{xp_gained} {skill} {xp_unit} <gray>({current_xp}/{level_xp} {xp_unit}) <aqua>{mana}/{max_mana} {mana_unit}"
xp_removed: "<red>{hp}/{max_hp}❤ <gold>-{xp_removed} {skill} {xp_unit} <gray>({current_xp}/{level_xp} {xp_unit}) <aqua>{mana}/{max_mana} {mana_unit}"
maxed: "<red>{hp}/{max_hp}❤ <gold>+{xp_gained} {skill} {xp_unit} <gray>(MAX) <aqua>{mana}/{max_mana} {mana_unit}"
maxed_removed: "<red>{hp}/{max_hp}❤ <gold>-{xp_removed} {skill} {xp_unit} <gray>(MAX) <aqua>{mana}/{max_mana} {mana_unit}"
ability: "{message}"
boss_bar_xp: "<gold>+{xp_gained} {skill} XP <gray>({percent}%)"
boss_bar_maxed: "<gold>+{xp_gained} {skill} XP <gray>(MAX)"
commands:
prefix: "<dark_gray>[<aqua>Compétences<dark_gray>] "
armor:
Expand Down Expand Up @@ -1056,6 +1047,8 @@ traits:
name: Dégâts critique
movement_speed:
name: Vitesse de mouvement
ui:
maxed: MAX
units:
mana: Mana
hp: PV
Expand Down

0 comments on commit 1d7711c

Please sign in to comment.