Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class MessagesSettings extends OkaeriConfig {
@Comment({
" ",
"# Configure the combat log notification displayed to players.",
"# You can use the {TIME} variable to display the remaining combat time.",
"# Placeholders: {SECONDS} - displays numeric value of seconds left in combat e.g. \"10\"",
"# {TIME} - displays formatted value with metric e.g \"10s\" or \"150ms\"",
" ",
})
public Notice combatNotification = BukkitNotice.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void run() {
.player(player.getUniqueId())
.notice(this.config.messagesSettings.combatNotification)
.placeholder("{TIME}", DurationUtil.format(remaining, this.config.messagesSettings.withoutMillis))
.placeholder("{SECONDS}", String.valueOf(remaining.toSeconds()))
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The use of remaining.toSeconds() truncates the duration, which can be inconsistent with the {TIME} placeholder that appears to round up. For example, a remaining time of 19.9 seconds would result in {SECONDS} being "19" while {TIME} could be "20s". This can be confusing.

To ensure consistency, it's better to round up the seconds for the {SECONDS} placeholder as well.

Suggested change
.placeholder("{SECONDS}", String.valueOf(remaining.toSeconds()))
.placeholder("{SECONDS}", String.valueOf((remaining.toMillis() + 999) / 1000))

Copy link
Member Author

Choose a reason for hiding this comment

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

image The value stays consistent between each implementation. Using `withoutMillies: false` only gives visible change to the user

.send();

}
Expand Down