Skip to content

Conversation

Pawelusze
Copy link

I simplified the /broadcast command by removing the subtitle argument and changing the title argument to a combined title (TITLE + SUBTITLE).

@Pawelusze Pawelusze requested a review from a team as a code owner October 5, 2025 18:09
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 simplifies the /broadcast command by consolidating the title and subtitle functionalities. My review identifies a potential bug where a format placeholder might be displayed literally to users and also suggests an improvement for code clarity by renaming a parameter. I've provided a single comprehensive code suggestion that addresses both points for a more robust and readable implementation.

Comment on lines 39 to 46
void executeTitle(@Flag("-raw") boolean raw, @Join String subtitle) {

@Execute(name = "subtitle")
@DescriptionDocs(description = "Broadcasts a SUBTITLE message to all players.", arguments = "[-raw] <text>")
void executeSubtitle(@Flag("-raw") boolean raw, @Join String subtitle) {
this.sendBroadcast(formatted -> Notice.title("", formatted, this.settings.titleFadeIn(), this.settings.titleStay(), this.settings.titleFadeOut()), subtitle, raw);
this.noticeService.create()
.notice(translation -> Notice.title(raw ? " " : translation.broadcast().messageFormat(), subtitle,
this.settings.titleFadeIn(), this.settings.titleStay(), this.settings.titleFadeOut()))
.onlinePlayers()
.send();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

I have a couple of suggestions to improve this method:

  1. Parameter Naming: The parameter name subtitle is a bit confusing within executeTitle. For consistency with other command methods in this class (like executeChat) and for better readability, renaming it to text would be more intuitive.
  2. Placeholder Handling: The translation.broadcast().messageFormat() likely contains a {BROADCAST} placeholder, based on its usage in other commands. In the current implementation, this placeholder would be displayed literally as part of the title. The intention seems to be to use the format as a prefix for the title, so the placeholder should be removed.

Here is a suggested implementation that incorporates these points:

Suggested change
void executeTitle(@Flag("-raw") boolean raw, @Join String subtitle) {
@Execute(name = "subtitle")
@DescriptionDocs(description = "Broadcasts a SUBTITLE message to all players.", arguments = "[-raw] <text>")
void executeSubtitle(@Flag("-raw") boolean raw, @Join String subtitle) {
this.sendBroadcast(formatted -> Notice.title("", formatted, this.settings.titleFadeIn(), this.settings.titleStay(), this.settings.titleFadeOut()), subtitle, raw);
this.noticeService.create()
.notice(translation -> Notice.title(raw ? " " : translation.broadcast().messageFormat(), subtitle,
this.settings.titleFadeIn(), this.settings.titleStay(), this.settings.titleFadeOut()))
.onlinePlayers()
.send();
}
void executeTitle(@Flag("-raw") boolean raw, @Join String text) {
this.noticeService.create()
.notice(translation -> {
String title = raw ? " " : translation.broadcast().messageFormat().replace("{BROADCAST}", "").trim();
return Notice.title(title, text,
this.settings.titleFadeIn(), this.settings.titleStay(), this.settings.titleFadeOut());
})
.onlinePlayers()
.send();
}

@Pawelusze Pawelusze changed the title Simplified command (/broadcast) Simplified command (/broadcast) GH-1193 Oct 5, 2025
@Pawelusze Pawelusze changed the title Simplified command (/broadcast) GH-1193 GH-1193 Simplified command (/broadcast) Oct 5, 2025
@Pawelusze Pawelusze changed the title GH-1193 Simplified command (/broadcast) GH-1193 Simplified command (/broadcast) Oct 5, 2025
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.

2 participants