Interface NotificationService
- All Superinterfaces:
BaseService
- All Known Implementing Classes:
InMemoryNotificationService
Sends short-lived notifications to one player: chat, title, action bar and a
self-expiring boss bar. Text is rendered in the player's resolved locale.
Methods may be called from any thread.
Required arguments reject null with a NullPointerException
naming the parameter; an optional sound may be null.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DurationDefault boss bar lifetime used by the short overloads.static final net.kyori.adventure.title.Title.TimesDefault title times, equivalent to the former 10/50/20 tick defaults. -
Method Summary
Modifier and TypeMethodDescriptionvoidsendActionBarNotification(org.bukkit.entity.Player player, Text message) Shows text above the hotbar.default voidsendBossBarNotification(org.bukkit.entity.Player player, Text message) Shows a green, continuous boss bar for the default lifetime without a sound.default voidsendBossBarNotification(org.bukkit.entity.Player player, Text message, Duration duration) Shows a green, continuous boss bar for the given lifetime without a sound.voidsendBossBarNotification(org.bukkit.entity.Player player, Text message, Duration duration, net.kyori.adventure.bossbar.BossBar.Color color, net.kyori.adventure.bossbar.BossBar.Overlay overlay, @Nullable net.kyori.adventure.sound.Sound sound) Shows a boss bar that empties overdurationand then disappears.default voidsendBossBarNotification(org.bukkit.entity.Player player, Text message, Duration duration, @Nullable net.kyori.adventure.sound.Sound sound) Shows a green, continuous boss bar with an optional sound.default voidsendMessageNotification(org.bukkit.entity.Player player, Text message) Sends a chat message without a sound.voidsendMessageNotification(org.bukkit.entity.Player player, Text message, @Nullable net.kyori.adventure.sound.Sound sound) Sends a chat message and optionally plays a sound to the player.default voidsendSubTitleNotification(org.bukkit.entity.Player player, Text subtitle) Shows a subtitle and an empty title, without a sound.default voidsendSubTitleNotification(org.bukkit.entity.Player player, Text subtitle, @Nullable net.kyori.adventure.sound.Sound sound) Shows a subtitle and an empty title with an optional sound.default voidsendTitleNotification(org.bukkit.entity.Player player, Text title, Text subtitle) Shows a title and subtitle with the default times, without a sound.default voidsendTitleNotification(org.bukkit.entity.Player player, Text title, Text subtitle, @Nullable net.kyori.adventure.sound.Sound sound) Shows a title and subtitle with the default times and an optional sound.voidsendTitleNotification(org.bukkit.entity.Player player, Text title, Text subtitle, @Nullable net.kyori.adventure.sound.Sound sound, net.kyori.adventure.title.Title.Times times) Shows a title and subtitle with the given times and optionally plays a sound.Methods inherited from interface BaseService
getAuthor, getName, getResourceFolderName, getVersion
-
Field Details
-
DEFAULT_BOSS_BAR_DURATION
Default boss bar lifetime used by the short overloads. -
DEFAULT_TITLE_TIMES
static final net.kyori.adventure.title.Title.Times DEFAULT_TITLE_TIMESDefault title times, equivalent to the former 10/50/20 tick defaults.
-
-
Method Details
-
sendMessageNotification
void sendMessageNotification(org.bukkit.entity.Player player, Text message, @Nullable @Nullable net.kyori.adventure.sound.Sound sound) Sends a chat message and optionally plays a sound to the player.- Parameters:
player- recipientmessage- deferred textsound- optional sound
-
sendMessageNotification
Sends a chat message without a sound.- Parameters:
player- recipientmessage- deferred text
-
sendTitleNotification
void sendTitleNotification(org.bukkit.entity.Player player, Text title, Text subtitle, @Nullable @Nullable net.kyori.adventure.sound.Sound sound, net.kyori.adventure.title.Title.Times times) Shows a title and subtitle with the given times and optionally plays a sound.- Parameters:
player- recipienttitle- deferred titlesubtitle- deferred subtitlesound- optional soundtimes- fade-in, stay and fade-out durations
-
sendTitleNotification
-
sendTitleNotification
default void sendTitleNotification(org.bukkit.entity.Player player, Text title, Text subtitle, @Nullable @Nullable net.kyori.adventure.sound.Sound sound) Shows a title and subtitle with the default times and an optional sound.- Parameters:
player- recipienttitle- deferred titlesubtitle- deferred subtitlesound- optional sound
-
sendSubTitleNotification
Shows a subtitle and an empty title, without a sound.- Parameters:
player- recipientsubtitle- deferred subtitle
-
sendSubTitleNotification
default void sendSubTitleNotification(org.bukkit.entity.Player player, Text subtitle, @Nullable @Nullable net.kyori.adventure.sound.Sound sound) Shows a subtitle and an empty title with an optional sound.- Parameters:
player- recipientsubtitle- deferred subtitlesound- optional sound
-
sendActionBarNotification
Shows text above the hotbar.- Parameters:
player- recipientmessage- deferred text
-
sendBossBarNotification
void sendBossBarNotification(org.bukkit.entity.Player player, Text message, Duration duration, net.kyori.adventure.bossbar.BossBar.Color color, net.kyori.adventure.bossbar.BossBar.Overlay overlay, @Nullable @Nullable net.kyori.adventure.sound.Sound sound) Shows a boss bar that empties overdurationand then disappears. A player has at most one such bar: a new call replaces its text, colour and overlay and restarts the countdown. The bar also disappears when the player leaves.- Parameters:
player- recipientmessage- deferred textduration- positive lifetime, rounded to the next 250 ms countdown stepcolor- bar colouroverlay- bar overlaysound- optional sound- Throws:
IllegalArgumentException- ifdurationis zero or negative
-
sendBossBarNotification
Shows a green, continuous boss bar for the default lifetime without a sound.- Parameters:
player- recipientmessage- deferred text
-
sendBossBarNotification
-
sendBossBarNotification
default void sendBossBarNotification(org.bukkit.entity.Player player, Text message, Duration duration, @Nullable @Nullable net.kyori.adventure.sound.Sound sound) Shows a green, continuous boss bar with an optional sound.- Parameters:
player- recipientmessage- deferred textduration- positive lifetimesound- optional sound
-