Class GestaltLoader

java.lang.Object
ovh.mythmc.gestalt.loader.GestaltLoader
Direct Known Subclasses:
BukkitGestaltLoader, PaperGestaltLoader

public abstract class GestaltLoader extends Object
Abstract base class responsible for downloading, verifying, and loading the Gestalt JAR on the target platform.

Subclasses must implement the platform-specific methods:

  • getDataDirectory() - the directory in which the libs/ folder is created
  • getLogger() - the logger wrapper for status messages
  • isAvailable() - whether Gestalt is already loaded on this platform
  • load() - the platform-specific routine to load the downloaded JAR

The full initialization flow is driven by initialize(), which handles directory setup, version checking, downloading, and finally delegating to load().

Download URLs and checksum endpoints are read from a gestalt.properties resource bundled in the plugin JAR.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract Path
    Returns the root data directory of the plugin.
    protected String
    Deprecated.
    Use getJarPath() instead.
    protected Path
    Returns the path where the Gestalt JAR is stored on disk.
    protected abstract GestaltLoggerWrapper
    Returns the logger wrapper used to emit status messages during loading.
    Runs the full Gestalt initialization flow: Checks if Gestalt is already available and returns early if so. Ensures the libs/ directory exists. Compares the local JAR checksum against the remote checksum and deletes an outdated JAR if found. Downloads the JAR if it is not present on disk. Calls load() to load the JAR into the server.
    protected abstract boolean
    Returns whether Gestalt is already available and loaded on this platform.
    protected abstract void
    Performs the platform-specific routine to load the Gestalt JAR into the server.
    void
    Called when the loader should shut down.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GestaltLoader

      public GestaltLoader()
  • Method Details

    • getDataDirectory

      protected abstract Path getDataDirectory()
      Returns the root data directory of the plugin. The Gestalt JAR will be placed at <dataDirectory>/libs/gestalt.jar.
      Returns:
      the plugin data directory
    • getLogger

      protected abstract GestaltLoggerWrapper getLogger()
      Returns the logger wrapper used to emit status messages during loading.
      Returns:
      the logger wrapper
    • isAvailable

      protected abstract boolean isAvailable()
      Returns whether Gestalt is already available and loaded on this platform.

      If true, initialize() will return early without downloading or loading.

      Returns:
      true if Gestalt is already loaded
    • load

      protected abstract void load()
      Performs the platform-specific routine to load the Gestalt JAR into the server. Called by initialize() after the JAR has been verified to exist on disk.
    • initialize

      Runs the full Gestalt initialization flow:
      1. Checks if Gestalt is already available and returns early if so.
      2. Ensures the libs/ directory exists.
      3. Compares the local JAR checksum against the remote checksum and deletes an outdated JAR if found.
      4. Downloads the JAR if it is not present on disk.
      5. Calls load() to load the JAR into the server.
      Returns:
      a GestaltLoaderInitializationResponse describing the outcome of the initialization
    • terminate

      public void terminate()
      Called when the loader should shut down.
    • getJarPath

      protected Path getJarPath()
      Returns the path where the Gestalt JAR is stored on disk. Defaults to <dataDirectory>/libs/gestalt.jar.
      Returns:
      the path to the Gestalt JAR
    • getGestaltPath

      @Deprecated protected String getGestaltPath()
      Deprecated.
      Use getJarPath() instead.
      Returns the string representation of the Gestalt JAR path.
      Returns:
      the Gestalt JAR path as a string