Class InMemoryNotificationService
java.lang.Object
com.ultikits.ultitools.services.impl.InMemoryNotificationService
- All Implemented Interfaces:
BaseService, NotificationService
Per-player notifications rendered by the text engine and owned by the framework scheduler.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final record -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentHashMap<UUID, InMemoryNotificationService.ActiveBar> private final Messagesprivate final Schedulerprivate static final DurationFields inherited from interface NotificationService
DEFAULT_BOSS_BAR_DURATION, DEFAULT_TITLE_TIMES -
Constructor Summary
ConstructorsConstructorDescriptionInMemoryNotificationService(Messages messages, Scheduler scheduler) Creates a notification service using the framework's root services. -
Method Summary
Modifier and TypeMethodDescription(package private) intgetName()Get service name, this name will appear in the console or in the game.intVersion number, used to compare the version number of the registered service, currently not in use.private voidplaySound(org.bukkit.entity.Player player, @Nullable net.kyori.adventure.sound.Sound sound) private net.kyori.adventure.bossbar.BossBarreplaceBar(org.bukkit.entity.Player player, @Nullable InMemoryNotificationService.ActiveBar previous, net.kyori.adventure.text.Component name, net.kyori.adventure.bossbar.BossBar.Color color, net.kyori.adventure.bossbar.BossBar.Overlay overlay) voidsendActionBarNotification(org.bukkit.entity.Player player, Text message) Shows text above the hotbar.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.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.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.private voidshowBossBar(org.bukkit.entity.Player player, net.kyori.adventure.text.Component name, net.kyori.adventure.bossbar.BossBar.Color color, net.kyori.adventure.bossbar.BossBar.Overlay overlay, @Nullable net.kyori.adventure.sound.Sound sound, float decrement) private voidtick(org.bukkit.entity.Player player, net.kyori.adventure.bossbar.BossBar bar, TaskHandle handle, float decrement) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BaseService
getResourceFolderName
-
Field Details
-
STEP
-
messages
-
scheduler
-
bars
-
-
Constructor Details
-
InMemoryNotificationService
-
-
Method Details
-
getName
Description copied from interface:BaseServiceGet service name, this name will appear in the console or in the game.- Specified by:
getNamein interfaceBaseService- Returns:
- Service name
-
getAuthor
- Specified by:
getAuthorin interfaceBaseService- Returns:
- Author name
-
getVersion
public int getVersion()Description copied from interface:BaseServiceVersion number, used to compare the version number of the registered service, currently not in use.- Specified by:
getVersionin interfaceBaseService- Returns:
- service version
-
sendMessageNotification
public void sendMessageNotification(org.bukkit.entity.Player player, Text message, @Nullable @Nullable net.kyori.adventure.sound.Sound sound) Description copied from interface:NotificationServiceSends a chat message and optionally plays a sound to the player.- Specified by:
sendMessageNotificationin interfaceNotificationService- Parameters:
player- recipientmessage- deferred textsound- optional sound
-
sendTitleNotification
public 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) Description copied from interface:NotificationServiceShows a title and subtitle with the given times and optionally plays a sound.- Specified by:
sendTitleNotificationin interfaceNotificationService- Parameters:
player- recipienttitle- deferred titlesubtitle- deferred subtitlesound- optional soundtimes- fade-in, stay and fade-out durations
-
sendActionBarNotification
Description copied from interface:NotificationServiceShows text above the hotbar.- Specified by:
sendActionBarNotificationin interfaceNotificationService- Parameters:
player- recipientmessage- deferred text
-
sendBossBarNotification
public 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) Description copied from interface:NotificationServiceShows 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.- Specified by:
sendBossBarNotificationin interfaceNotificationService- Parameters:
player- recipientmessage- deferred textduration- positive lifetime, rounded to the next 250 ms countdown stepcolor- bar colouroverlay- bar overlaysound- optional sound
-
showBossBar
private void showBossBar(org.bukkit.entity.Player player, net.kyori.adventure.text.Component name, net.kyori.adventure.bossbar.BossBar.Color color, net.kyori.adventure.bossbar.BossBar.Overlay overlay, @Nullable @Nullable net.kyori.adventure.sound.Sound sound, float decrement) -
replaceBar
private net.kyori.adventure.bossbar.BossBar replaceBar(org.bukkit.entity.Player player, @Nullable @Nullable InMemoryNotificationService.ActiveBar previous, net.kyori.adventure.text.Component name, net.kyori.adventure.bossbar.BossBar.Color color, net.kyori.adventure.bossbar.BossBar.Overlay overlay) -
tick
private void tick(org.bukkit.entity.Player player, net.kyori.adventure.bossbar.BossBar bar, TaskHandle handle, float decrement) -
playSound
private void playSound(org.bukkit.entity.Player player, @Nullable @Nullable net.kyori.adventure.sound.Sound sound) -
activeBarCount
int activeBarCount()
-