Skip to content

GH-357 Add configurable duration formatter with plural support#358

Open
imDMK wants to merge 2 commits intomasterfrom
feature/duration-formatter
Open

GH-357 Add configurable duration formatter with plural support#358
imDMK wants to merge 2 commits intomasterfrom
feature/duration-formatter

Conversation

@imDMK
Copy link
Contributor

@imDMK imDMK commented Mar 5, 2026

Closes #357

Duration formatter

Introduces a configurable duration formatter with plural support and customizable separators.
Tested on localhost server.

Preview

Zrzut ekranu 2026-03-6 o 00 34 48 Duration formatter preview

Video

Nagranie.z.ekranu.2026-03-6.o.00.16.56.mov

@imDMK imDMK added the 🆕 feature New feature or request label Mar 5, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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

  • Configurable Duration Formatting: Introduced a new DurationService and DurationFormatter to provide highly configurable duration formatting with support for pluralization and custom separators, replacing the previous static utility.
  • New Configuration Options: Added DurationFormatSettings to the PluginConfig, allowing users to define custom patterns, separators, and zero-duration text for time displays throughout the plugin.
  • Integration Across Plugin Components: The new duration formatting system has been integrated into core plugin components such as CombatPlugin initialization, PlaceholderAPI integration, combat task updates, pearl cooldown messages, and tag-out commands.
  • Refactored Time Utility: The old DurationUtil class has been removed, streamlining the codebase and centralizing duration formatting logic within the new DurationService.

🧠 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
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/CombatPlugin.java
    • Reordered import statements for better organization
    • Instantiated DurationService based on plugin configuration
    • Injected DurationService into BridgeService, FightTagOutCommand, FightTask, and FightPearlController constructors
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/bridge/BridgeService.java
    • Reordered import statements
    • Added DurationService to the constructor and initialized it
    • Passed durationService to the FightTagPlaceholder constructor
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/bridge/placeholder/FightTagPlaceholder.java
    • Reordered import statements
    • Added DurationService to the constructor and initialized it
    • Replaced calls to DurationUtil.format with durationService.format
    • Updated getAuthors().get(0) to getAuthors().getFirst() for modern Java collection access
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/CrystalPvpSettings.java
    • Corrected comment formatting for consistency
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/DurationFormatSettings.java
    • Added a new configuration class to define duration formatting patterns, separators, and zero-duration text
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/MessagesSettings.java
    • Removed the withoutMillis boolean configuration, as formatting is now handled by DurationFormatSettings
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/PlaceholderSettings.java
    • Corrected comment formatting for consistency
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/PluginConfig.java
    • Added a new durationFormat field to include DurationFormatSettings in the main plugin configuration
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/FightTask.java
    • Replaced DurationUtil import with DurationService import
    • Added DurationService to the constructor and initialized it
    • Updated combat notification placeholder formatting to use durationService.format
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlController.java
    • Replaced DurationUtil import with DurationService import
    • Added DurationService to the constructor and initialized it
    • Updated pearl cooldown message formatting to use durationService.format
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/tagout/FightTagOutCommand.java
    • Replaced DurationUtil import with DurationService import
    • Added DurationService to the constructor and initialized it
    • Updated tag-out command messages to use durationService.format for time display
    • Renamed untagout methods to unTagout for improved naming consistency
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/time/DurationFormatter.java
    • Added a new class responsible for parsing duration patterns and formatting Duration objects into human-readable strings with plural support and custom separators
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/time/DurationService.java
    • Added a new service class that acts as an entry point for duration formatting, utilizing DurationFormatter and DurationFormatSettings
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/time/DurationUnit.java
    • Added a new enum defining different time units (days, hours, minutes, seconds) and their extraction logic from a Duration object
  • eternalcombat-plugin/src/main/java/com/eternalcode/combat/util/DurationUtil.java
    • Removed the DurationUtil class entirely, as its functionality is now superseded by the new DurationService
Activity
  • The pull request addresses issue [Feature]: Add extender placeholders to be used in combatNotification #357 by implementing a configurable duration formatter.
  • The author, imDMK, has introduced new classes (DurationFormatter, DurationService, DurationUnit, DurationFormatSettings) to handle flexible time formatting.
  • Existing classes have been updated to integrate the new DurationService for consistent time display.
  • Preview images and a video demonstrating the new duration formatter have been provided in the PR description.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add extender placeholders to be used in combatNotification

1 participant