Skip to content

Conversation

@ChudziudgiToJa
Copy link

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @ChudziudgiToJa, 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 focuses on enhancing the BossBar functionality by improving the accuracy of its progress calculation and increasing the frequency of its updates. The changes ensure that BossBars display progress with higher precision and animate more smoothly, leading to a more polished and reliable user interface element.

Highlights

  • Progress Calculation Refinement: The BossBar progress is now calculated using milliseconds for greater precision, providing a more granular representation of the remaining duration compared to the previous second-based calculation.
  • Progress Clamping: Implemented clamping for the BossBar progress value, ensuring it always remains within the valid range of 0.0f to 1.0f, preventing potential out-of-bounds display issues.
  • Smoother Updates: The BossBar update interval has been significantly reduced from 500 milliseconds to 100 milliseconds, resulting in a much smoother visual progression and a more responsive user experience.
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

@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

The pull request focuses on improving the progress calculation and reducing the update interval for the BossBar in the Multification plugin. The changes involve adjusting the progress calculation to use milliseconds for better precision and reducing the scheduler update interval from 500ms to 100ms. The review focuses on correctness and efficiency.

Comment on lines 47 to 48
float progress = (float) (remainingMillis / totalMillis);
progress = Math.max(0.0f, Math.min(1.0f, progress));

Choose a reason for hiding this comment

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

critical

The progress value is clamped between 0.0 and 1.0, which is good for preventing out-of-bounds values. However, the logic is flawed. The progress should represent the percentage of time that has elapsed, not the time remaining. The current calculation shows the remaining time. This should be inverted to represent elapsed time.

Consider inverting the progress calculation to reflect elapsed time instead of remaining time.

Suggested change
float progress = (float) (remainingMillis / totalMillis);
progress = Math.max(0.0f, Math.min(1.0f, progress));
double totalMillis = duration.toMillis();
double remainingMillis = Math.max(0, remaining.toMillis());
float progress = (float) (1.0 - (remainingMillis / totalMillis)); // Invert the progress calculation
progress = Math.max(0.0f, Math.min(1.0f, progress));

Comment on lines 45 to 47
double totalMillis = duration.toMillis();
double remainingMillis = Math.max(0, remaining.toMillis());
float progress = (float) (remainingMillis / totalMillis);

Choose a reason for hiding this comment

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

high

The current progress calculation might lead to unexpected behavior due to integer division. Specifically, remainingMillis / totalMillis could result in 0 if remainingMillis is less than totalMillis but still greater than 0, causing the boss bar to appear empty prematurely. To fix this, ensure that the division is performed with double precision before casting to float.

Consider swapping the order of the cast and the division to ensure floating point division is performed.

Suggested change
double totalMillis = duration.toMillis();
double remainingMillis = Math.max(0, remaining.toMillis());
float progress = (float) (remainingMillis / totalMillis);
double totalMillis = duration.toMillis();
double remainingMillis = Math.max(0, remaining.toMillis());
float progress = (float) remainingMillis / (float) totalMillis; // Explicitly cast both operands to float before division

bossBar.progress(progress);

this.scheduler.schedule(() -> updateProgress(expiration, duration, bossBar, viewer), 500L, TimeUnit.MILLISECONDS);
this.scheduler.schedule(() -> updateProgress(expiration, duration, bossBar, viewer), 100L, TimeUnit.MILLISECONDS);

Choose a reason for hiding this comment

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

medium

Reducing the scheduler interval to 100ms can lead to increased CPU usage, especially if there are many boss bars being updated simultaneously. While this provides a smoother visual update, it's important to consider the performance implications. Make sure this value is configurable or that performance is carefully monitored.

Consider making the update interval configurable to allow administrators to tune performance.

        long updateInterval = 100L; // Make this configurable
        this.scheduler.schedule(() -> updateProgress(expiration, duration, bossBar, viewer), updateInterval, TimeUnit.MILLISECONDS);

@ChudziudgiToJa
Copy link
Author

2025-10-17.14-22-59.mp4

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant