Interface Platform
public interface Platform
Abstraction over runtime platform (Bukkit, Fabric, NeoForge, etc.).
-
Method Summary
Modifier and TypeMethodDescriptionBase directory for configs/lang files.console()Audience representing console/server.booleanDetermine if the current thread is the platform main thread.logger()Primary logger for platform.Snapshot of online player audiences, if applicable.default @Nullable AudienceplayerById(UUID id) Finds an online player audience by UUID.default @Nullable AudienceplayerByName(String name) Finds an online player audience by exact, case-insensitive name.default voidrunForAudience(Audience audience, Runnable task) Executes a task in the context of a specific audience (e.g., entity region on Folia).voidExecutes a task on the main thread.default TaskSchedulerReturns the task scheduler for async work.default ListenerSubscriptionSubscribes to normalized player join/leave events when the platform supports it.default ListenerSubscriptionsubscribePlayerLocales(PlayerLocaleListener listener) Subscribes to normalized player locale updates when the platform supports it.default ListenerSubscriptionsubscribePlayerMessages(PlayerMessageListener listener) Subscribes to normalized player chat/command messages when the platform supports it.default ThreadContextReturns the current execution context for thread-sensitive operations.
-
Method Details
-
configDir
-
logger
-
console
-
onlinePlayers
Collection<Audience> onlinePlayers()Snapshot of online player audiences, if applicable.- Returns:
- online audiences collection (may be empty)
-
playerByName
Finds an online player audience by exact, case-insensitive name.The default implementation scans
onlinePlayers(); platforms with a direct registry lookup may override for efficiency.- Parameters:
name- player name (case-insensitive)- Returns:
- the matching audience, or
nullif no such player is online
-
playerById
Finds an online player audience by UUID.The default implementation scans
onlinePlayers(); platforms with a direct registry lookup may override for efficiency.- Parameters:
id- player UUID- Returns:
- the matching audience, or
nullif no such player is online
-
runOnMain
-
isMainThread
boolean isMainThread()Determine if the current thread is the platform main thread.- Returns:
- true if current thread is main/platform thread.
-
runForAudience
Executes a task in the context of a specific audience (e.g., entity region on Folia). On platforms without regional threading, this delegates torunOnMain(Runnable).- Parameters:
audience- target audience for region resolutiontask- work to run
-
threadContext
Returns the current execution context for thread-sensitive operations.- Returns:
- thread context classification
-
scheduler
Returns the task scheduler for async work.- Returns:
- task scheduler
-
subscribePlayerMessages
Subscribes to normalized player chat/command messages when the platform supports it.- Parameters:
listener- message listener- Returns:
- subscription handle, or a no-op subscription when unsupported
-
subscribePlayerLifecycle
Subscribes to normalized player join/leave events when the platform supports it.- Parameters:
listener- lifecycle listener- Returns:
- subscription handle, or a no-op subscription when unsupported
-
subscribePlayerLocales
Subscribes to normalized player locale updates when the platform supports it.- Parameters:
listener- locale listener- Returns:
- subscription handle, or a no-op subscription when unsupported
-