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
Notification
Builder
private final Notification notification = Notification.builder()
.title("UHC Announcement")
.description("UHC starts in 5 minutes...")
.resourceLocation("icons/golden_apple.png") // This field is optional
.displayTime(Duration.ofSeconds(5))
.build();
Notification
Options
⚠️
There are character limits for the title
and description
options.
.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. Char limit: 15
.description("UHC starts in 5 minutes...")
.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.
Displaying a Notification for a specific player
public void displayNotificationExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.notificationModule.displayNotification(apolloPlayer, this.uhcAnnouncement));
}
Resetting all notifications for a player
public void resetNotificationsExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(this.notificationModule::resetNotifications);
}