Skip to content
Open
Changes from 1 commit
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 @@ -35,15 +35,14 @@ void executeChat(@Flag("-raw") boolean raw, @Join String text) {
}

@Execute(name = "title")
@DescriptionDocs(description = "Broadcasts a TITLE message to all players.", arguments = "[-raw] <text>")
void executeTitle(@Flag("-raw") boolean raw, @Join String title) {
this.sendBroadcast(formatted -> Notice.title(formatted, "", this.settings.titleFadeIn(), this.settings.titleStay(), this.settings.titleFadeOut()), title, raw);
}
@DescriptionDocs(description = "Broadcasts a combined title message to all players.", arguments = "[-raw] <text>")
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();
}


@Execute(name = "actionbar")
Expand Down