Class InMemoryNotificationService
java.lang.Object
com.ultikits.ultitools.services.impl.InMemoryNotificationService
- All Implemented Interfaces:
BaseService,NotificationService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classResult object for BossBar tick processing. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static booleanTrue once ANY instance of this class has registeredatedPlayer-- a static field shared by every instance -- with the livePlayerCacheManagerfor quit-based sweeping (GEN-08, D-03). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidcacheBossBar(UUID playerUUID, org.bukkit.boss.BossBar bossBar) Put a BossBar into cache.(package private) static voidClear all cached BossBars.private voidAttempts lazy first-use registration of THIS instance -- as the reference-identity handle for the shared staticatedPlayerfield -- with the livePlayerCacheManagersingleton.(package private) static org.bukkit.boss.BossBargetCachedBossBar(UUID playerUUID) Get the cached BossBar for a player.getName()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.(package private) static InMemoryNotificationService.BossBarTickResultprocessBossBarTick(org.bukkit.boss.BossBar bossBar, org.bukkit.entity.Player player, int seconds) Process a single tick of the BossBar progress animation.booleansendActionBarNotification(org.bukkit.entity.Player player, String message) booleansendBossBarNotification(org.bukkit.entity.Player player, String message) Send a boss bar notification to a playerbooleansendBossBarNotification(org.bukkit.entity.Player player, String message, int seconds) Send a boss bar notification to a playerbooleansendBossBarNotification(org.bukkit.entity.Player player, String message, int seconds, org.bukkit.boss.BossBar bossBar) Send a boss bar notification to a playerbooleansendBossBarNotification(org.bukkit.entity.Player player, String message, int seconds, org.bukkit.boss.BossBar bossBar, org.bukkit.Sound sound) Send a boss bar notification to a playerbooleansendBossBarNotification(org.bukkit.entity.Player player, String message, int seconds, org.bukkit.Sound sound) Send a boss bar notification to a playerbooleansendMessageNotification(org.bukkit.entity.Player player, String message) Send a message notification to a playerbooleansendMessageNotification(org.bukkit.entity.Player player, String message, org.bukkit.Sound sound) Send a message notification to a playerbooleansendSubTitleNotification(org.bukkit.entity.Player player, String subtitle) Send a subtitle message notification to a playerbooleansendSubTitleNotification(org.bukkit.entity.Player player, String subtitle, org.bukkit.Sound sound) Send a subtitle message notification to a playerbooleansendTitleNotification(org.bukkit.entity.Player player, String title, String subtitle) Send a title message notification to a playerbooleansendTitleNotification(org.bukkit.entity.Player player, String title, String subtitle, org.bukkit.Sound sound) Send a title message notification to a playerbooleansendTitleNotification(org.bukkit.entity.Player player, String title, String subtitle, org.bukkit.Sound sound, int fadeIn, int stay, int fadeOut) Send a title message notification to a playerbooleansendToastNotification(org.bukkit.entity.Player player, String icon, String message, Toast.Style style) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.ultikits.ultitools.interfaces.BaseService
getResourceFolderName
-
Field Details
-
atedPlayer
-
playerCacheRegistered
private static volatile boolean playerCacheRegisteredTrue once ANY instance of this class has registeredatedPlayer-- a static field shared by every instance -- with the livePlayerCacheManagerfor quit-based sweeping (GEN-08, D-03). Deliberately a STATIC flag, not per-instance: registering the same static field once per constructed instance would track it once per instance too, sweeping it redundantly on every quit (harmless, since#registerBeanremoves the same map reference each time -- but silently relying on that idempotency rather than registering exactly once is worse than being explicit, per this migration's own plan). Set lazily fromsendBossBarNotification(Player, String, int, BossBar, Sound)-- the write path -- rather than the constructor, mirroringCooldownValidator's identical lazy-first-use rationale.
-
-
Constructor Details
-
InMemoryNotificationService
public InMemoryNotificationService()
-
-
Method Details
-
ensurePlayerCacheRegistered
private void ensurePlayerCacheRegistered()Attempts lazy first-use registration of THIS instance -- as the reference-identity handle for the shared staticatedPlayerfield -- with the livePlayerCacheManagersingleton. Guarded by the STATICplayerCacheRegisteredflag so only the first instance to reachsendBossBarNotification(Player, String, int, BossBar, Sound)registers; every later instance's call is a cheap no-op. Safe to call unconditionally on every invocation: also a cheap, safely-no-op-on-failure retry when the core plugin is not yet live (seeplayerCacheRegistered's javadoc). -
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
-
sendBossBarNotification
Description copied from interface:NotificationServiceSend a boss bar notification to a player- Specified by:
sendBossBarNotificationin interfaceNotificationService- Parameters:
player- The player to send the boss bar tomessage- The message to send- Returns:
- Whether the boss bar was sent successfully
-
sendBossBarNotification
public boolean sendBossBarNotification(org.bukkit.entity.Player player, String message, int seconds) Description copied from interface:NotificationServiceSend a boss bar notification to a player- Specified by:
sendBossBarNotificationin interfaceNotificationService- Parameters:
player- The player to send the boss bar tomessage- The message to sendseconds- The duration of the boss bar in seconds- Returns:
- Whether the boss bar was sent successfully
-
sendBossBarNotification
public boolean sendBossBarNotification(org.bukkit.entity.Player player, String message, int seconds, org.bukkit.Sound sound) Description copied from interface:NotificationServiceSend a boss bar notification to a player- Specified by:
sendBossBarNotificationin interfaceNotificationService- Parameters:
player- The player to send the boss bar tomessage- The message to sendseconds- The duration of the boss bar in secondssound- The sound to play when the boss bar is sent- Returns:
- Whether the boss bar was sent successfully
-
sendBossBarNotification
public boolean sendBossBarNotification(org.bukkit.entity.Player player, String message, int seconds, org.bukkit.boss.BossBar bossBar) Description copied from interface:NotificationServiceSend a boss bar notification to a player- Specified by:
sendBossBarNotificationin interfaceNotificationService- Parameters:
player- The player to send the boss bar tomessage- The message to sendseconds- The duration of the boss bar in secondsbossBar- The boss bar to send- Returns:
- Whether the boss bar was sent successfully
-
sendBossBarNotification
public boolean sendBossBarNotification(org.bukkit.entity.Player player, String message, int seconds, org.bukkit.boss.BossBar bossBar, org.bukkit.Sound sound) Description copied from interface:NotificationServiceSend a boss bar notification to a player- Specified by:
sendBossBarNotificationin interfaceNotificationService- Parameters:
player- The player to send the boss bar tomessage- The message to sendseconds- The duration of the boss bar in secondsbossBar- The boss bar to sendsound- The sound to play when the boss bar is sent- Returns:
- Whether the boss bar was sent successfully
-
processBossBarTick
static InMemoryNotificationService.BossBarTickResult processBossBarTick(org.bukkit.boss.BossBar bossBar, org.bukkit.entity.Player player, int seconds) Process a single tick of the BossBar progress animation. This method is extracted from BukkitRunnable for testability.- Parameters:
bossBar- the BossBar to updateplayer- the player viewing the BossBarseconds- the total duration in seconds- Returns:
- the result containing whether to cancel and the new progress
-
getCachedBossBar
Get the cached BossBar for a player. Used for testing. -
cacheBossBar
Put a BossBar into cache. Used for testing. -
clearBossBarCache
static void clearBossBarCache()Clear all cached BossBars. Used for testing. -
sendMessageNotification
Description copied from interface:NotificationServiceSend a message notification to a player- Specified by:
sendMessageNotificationin interfaceNotificationService- Parameters:
player- The player to send the message tomessage- The message to send- Returns:
- Whether the message was sent successfully
-
sendMessageNotification
public boolean sendMessageNotification(org.bukkit.entity.Player player, String message, org.bukkit.Sound sound) Description copied from interface:NotificationServiceSend a message notification to a player- Specified by:
sendMessageNotificationin interfaceNotificationService- Parameters:
player- The player to send the message tomessage- The message to sendsound- The sound to play when the message is sent- Returns:
- Whether the message was sent successfully
-
sendSubTitleNotification
Description copied from interface:NotificationServiceSend a subtitle message notification to a player- Specified by:
sendSubTitleNotificationin interfaceNotificationService- Parameters:
player- The player to send the subtitle tosubtitle- The subtitle to send- Returns:
- Whether the subtitle was sent successfully
-
sendSubTitleNotification
public boolean sendSubTitleNotification(org.bukkit.entity.Player player, String subtitle, org.bukkit.Sound sound) Description copied from interface:NotificationServiceSend a subtitle message notification to a player- Specified by:
sendSubTitleNotificationin interfaceNotificationService- Parameters:
player- The player to send the subtitle tosubtitle- The subtitle to sendsound- The sound to play when the subtitle is sent- Returns:
- Whether the subtitle was sent successfully
-
sendTitleNotification
public boolean sendTitleNotification(org.bukkit.entity.Player player, String title, String subtitle) Description copied from interface:NotificationServiceSend a title message notification to a player- Specified by:
sendTitleNotificationin interfaceNotificationService- Parameters:
player- The player to send the title totitle- The title to sendsubtitle- The subtitle to send- Returns:
- Whether the title was sent successfully
-
sendTitleNotification
public boolean sendTitleNotification(org.bukkit.entity.Player player, String title, String subtitle, org.bukkit.Sound sound) Description copied from interface:NotificationServiceSend a title message notification to a player- Specified by:
sendTitleNotificationin interfaceNotificationService- Parameters:
player- The player to send the title totitle- The title to sendsubtitle- The subtitle to sendsound- The sound to play when the title is sent- Returns:
- Whether the title was sent successfully
-
sendTitleNotification
public boolean sendTitleNotification(org.bukkit.entity.Player player, String title, String subtitle, org.bukkit.Sound sound, int fadeIn, int stay, int fadeOut) Description copied from interface:NotificationServiceSend a title message notification to a player- Specified by:
sendTitleNotificationin interfaceNotificationService- Parameters:
player- The player to send the title totitle- The title to sendsubtitle- The subtitle to sendsound- The sound to play when the title is sentfadeIn- The time in ticks for the title to fade instay- The time in ticks for the title to stayfadeOut- The time in ticks for the title to fade out- Returns:
- Whether the title was sent successfully
-
sendActionBarNotification
- Specified by:
sendActionBarNotificationin interfaceNotificationService
-
sendToastNotification
public boolean sendToastNotification(org.bukkit.entity.Player player, String icon, String message, Toast.Style style) - Specified by:
sendToastNotificationin interfaceNotificationService
-