Notification Module
Overview
The notification module allows you to send Lunar Client notifications to players actively on your server. Lunar Client notifications appear in the upper right of the user's screen.
- Send custom notifications to Lunar Client players.
- Custom notification color can be provided.
- Custom icons can be provided.
Integration
Sample Code
Explore each integration by cycling through each tab, to find the best fit for your requirements and needs.
Displaying a Notification
public void displayNotificationExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> {
this.notificationModule.displayNotification(apolloPlayer, Notification.builder()
.titleComponent(Component.text("UHC Announcement", NamedTextColor.GREEN))
.descriptionComponent(Component.text("UHC starts in 5 minutes...", NamedTextColor.RED)
.append(Component.newline())
.append(Component.text("Get ready!", NamedTextColor.WHITE))
.append(Component.newline())
.append(Component.text("Good luck!", NamedTextColor.GOLD))
)
.resourceLocation("icons/golden_apple.png") // This field is optional
.displayTime(Duration.ofSeconds(5))
.build());
});
}
Resetting all Notifications
public void resetNotificationsExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(this.notificationModule::resetNotifications);
}
Notification
Options
There are character limits for the titleComponent
option.
.titleComponent(Component)
is the title of the notification box. Char limit: 15
. See the chat components (opens in a new tab) page for more.
.titleComponent(Component.text("UHC Announcement", NamedTextColor.GREEN))
.descriptionComponent(Component)
is the description displayed inside the notification box. See the chat components (opens in a new tab) page for more.
.descriptionComponent(Component.text("UHC starts in 5 minutes...", NamedTextColor.RED))
.resourceLocation(String)
is the resource location of the shown icon.
.resourceLocation("icons/golden_apple.png")
.displayTime(java.time.Duration)
is the duration you want to keep the notification on screen. See the java.time.Duration Javadocs (opens in a new tab) for more.
.displayTime(Duration.ofSeconds(5))
If this field is left empty (null) it'll display a generic info icon, as displayed here.
The fields title
and description
are deprecated since 1.0.6, use 'titleComponent' and 'descriptionComponent' instead.
.title(String)
is the title of the notification box. Char limit: 15
.title("UHC Announcement")
.description(String)
is the description displayed inside the notification box.
.description("UHC starts in 5 minutes...")