GH-357 Add configurable duration formatter with plural support#358
GH-357 Add configurable duration formatter with plural support#358
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the plugin's ability to display time-related information in a user-friendly and customizable manner. By introducing a new, configurable duration formatting service, it allows administrators to tailor how combat timers, cooldowns, and other time values are presented, improving clarity and localization without altering core logic. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a configurable duration formatter with plural support, which is a great enhancement. The implementation is mostly solid, but I've found a couple of issues. There's a bug in the new duration formatter's parsing logic that makes part of the code unreachable and prevents certain formats. Additionally, there's a potential compatibility issue with the use of a Java 21-specific method. My review includes suggestions to address these points.
...mbat-plugin/src/main/java/com/eternalcode/combat/bridge/placeholder/FightTagPlaceholder.java
Show resolved
Hide resolved
eternalcombat-plugin/src/main/java/com/eternalcode/combat/time/DurationFormatter.java
Outdated
Show resolved
Hide resolved
eternalcombat-plugin/src/main/java/com/eternalcode/combat/time/DurationFormatter.java
Show resolved
Hide resolved
eternalcombat-plugin/src/main/java/com/eternalcode/combat/time/DurationFormatter.java
Outdated
Show resolved
Hide resolved
eternalcombat-plugin/src/main/java/com/eternalcode/combat/time/DurationFormatter.java
Outdated
Show resolved
Hide resolved
eternalcombat-plugin/src/main/java/com/eternalcode/combat/time/DurationFormatter.java
Outdated
Show resolved
Hide resolved
eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/tagout/FightTagOutCommand.java
Outdated
Show resolved
Hide resolved
eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/tagout/FightTagOutCommand.java
Outdated
Show resolved
Hide resolved
eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/tagout/FightTagOutCommand.java
Outdated
Show resolved
Hide resolved
…t/tagout/FightTagOutCommand.java Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>
…t/tagout/FightTagOutCommand.java Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>
…t/tagout/FightTagOutCommand.java Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
|
|
||
| import java.time.Duration; | ||
|
|
||
| public final class DurationService { |
There was a problem hiding this comment.
do wywalenia klasa nic to nie robi
| this.symbol = symbol; | ||
| } | ||
|
|
||
| abstract long extract(Duration duration); |
There was a problem hiding this comment.
trochę nazwa nie jasnsa, to daje part z Duration
|
|
||
| enum DurationUnit { | ||
|
|
||
| DAYS("d") { |
There was a problem hiding this comment.
zróbmy to bez @OverRide, można po prostu zrobić Funcation<Duration, Long> duration -> duration.toDaysPart() i do fileda zapisać
| "# Example:", | ||
| "# %d{day|days} %h{hour|hours} %m{minute|minutes} %s{second|seconds} %ms{millisecond|milliseconds}" | ||
| }) | ||
| public String pattern = "%d {day|days} %h {hour|hours} %m {minute|minutes} %s {second|seconds} %ms {millisecond|milliseconds}"; |
There was a problem hiding this comment.
nie możemy tego rozłożyć może na filedy typu:
days: "{x} day|{x} days"
etc etc a spacje można dać samemu tak jak tu ^
to jest troszkę lepsze bo uwzględnia lepiej jakieś dziwne cases gdzie ktoś chce mieć inne separatory albo inne głupoty
w ogóle w językach typu Polski jest problem z
1 godzina, 2 godziny, 5 godzin :/ no ale trudno będą musieli używać godz.
| import com.eternalcode.combat.fight.FightTask; | ||
| import com.eternalcode.combat.fight.controller.*; | ||
| import com.eternalcode.combat.fight.death.DeathEffectController; | ||
| import com.eternalcode.combat.fight.drop.*; | ||
| import com.eternalcode.combat.fight.drop.impl.PercentDropModifier; | ||
| import com.eternalcode.combat.fight.drop.impl.PlayersHealthDropModifier; | ||
| import com.eternalcode.combat.fight.effect.FightEffectController; | ||
| import com.eternalcode.combat.fight.effect.FightEffectService; | ||
| import com.eternalcode.combat.fight.effect.FightEffectServiceImpl; | ||
| import com.eternalcode.combat.fight.firework.FireworkController; |
| private String handleRemainingSeconds(OfflinePlayer player) { | ||
| return this.getFightTag(player) | ||
| .map(tag -> DurationUtil.format(tag.getRemainingDuration())) | ||
| .map(tag -> durationService.format(tag.getRemainingDuration())) |
There was a problem hiding this comment.
ja już tu zmieniamy to przydało by się wywalić remaining_millis i remaining_seconds bo w tym kontekście te placeholdery wdają się być bez sensu
Closes #357
Duration formatter
Introduces a configurable duration formatter with plural support and customizable separators.
Tested on localhost server.
Preview
Video
Nagranie.z.ekranu.2026-03-6.o.00.16.56.mov