Interface Platform


public interface Platform
Abstraction over runtime platform (Bukkit, Fabric, NeoForge, etc.).
  • Method Details

    • configDir

      Path configDir()
      Base directory for configs/lang files.
      Returns:
      config path
    • logger

      PlatformLogger logger()
      Primary logger for platform.
      Returns:
      platform logger
    • console

      Audience console()
      Audience representing console/server.
      Returns:
      console audience
    • onlinePlayers

      Collection<Audience> onlinePlayers()
      Snapshot of online player audiences, if applicable.
      Returns:
      online audiences collection (may be empty)
    • playerByName

      @Nullable default @Nullable Audience playerByName(String name)
      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 null if no such player is online
    • playerById

      @Nullable default @Nullable Audience playerById(UUID id)
      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 null if no such player is online
    • runOnMain

      void runOnMain(Runnable task)
      Executes a task on the main thread.
      Parameters:
      task - work to run
    • isMainThread

      boolean isMainThread()
      Determine if the current thread is the platform main thread.
      Returns:
      true if current thread is main/platform thread.
    • runForAudience

      default void runForAudience(Audience audience, Runnable task)
      Executes a task in the context of a specific audience (e.g., entity region on Folia). On platforms without regional threading, this delegates to runOnMain(Runnable).
      Parameters:
      audience - target audience for region resolution
      task - work to run
    • threadContext

      default ThreadContext threadContext()
      Returns the current execution context for thread-sensitive operations.
      Returns:
      thread context classification
    • scheduler

      default TaskScheduler scheduler()
      Returns the task scheduler for async work.
      Returns:
      task scheduler
    • subscribePlayerMessages

      default ListenerSubscription subscribePlayerMessages(PlayerMessageListener listener)
      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

      default ListenerSubscription subscribePlayerLifecycle(PlayerLifecycleListener listener)
      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

      default ListenerSubscription subscribePlayerLocales(PlayerLocaleListener listener)
      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