Class ColdLib

java.lang.Object
net.orbyfied.coldlib.ColdLib

public class ColdLib extends Object
The library instance.
  • Constructor Details

  • Method Details

    • get

      public static ColdLib get()
      Get the ColdLib instance from the provider.
      Returns:
      The ColdLib instance or null if unset.
      Throws:
      IllegalStateException - If there is no provider set.
      See Also:
    • provider

      public ColdLibProvider provider()
      Get the library provider that instantiated this library.
      Returns:
      The provider instance.
    • getServices

      public List<ColdLibService> getServices()
      Get the list of registered services.
      Returns:
      The immutable list of registered services.
    • referenceService

      public <S extends ColdLibService> Container<S> referenceService(Class<S> sClass, String instanceName)
      Get or create a future reference to the specified service instance. This allows you to get, set, or await the service instance in the future.
      Type Parameters:
      S - The service type.
      Parameters:
      sClass - The service class.
      instanceName - The instance name (can be null).
      Returns:
      The service reference.
    • referenceService

      public <S extends ColdLibService> Container<S> referenceService(Class<S> sClass)
      Get or create a future reference to the specified service instance. This allows you to get, set, or await the service instance in the future.
      Type Parameters:
      S - The service type.
      Parameters:
      sClass - The service class.
      Returns:
      The service reference.
      See Also:
    • getService

      public <S extends ColdLibService> S getService(Class<S> sClass, String instanceName)
      Get a registered service.
      Type Parameters:
      S - The service type.
      Parameters:
      sClass - The service class.
      instanceName - The name (optional).
      Returns:
      The service or null if absent.
    • getService

      public <S extends ColdLibService> S getService(Class<S> sClass)
      Get a registered service by only class. The instanceName argument will be set to null.
      Returns:
      The service or null if absent.
      See Also:
    • withService

      public <S extends ColdLibService> S withService(S service)
      Registers the provided service to this ColdLib instance. It use the class of the service object for the service class and the instance name from the service object (can be null)
      Type Parameters:
      S - The service type.
      Parameters:
      service - The service instance.
      Returns:
      The service (now registered).
    • createService

      public <S extends ColdLibService> S createService(Class<S> sClass, String instanceName)
      Creates and registers a new service instance of type sClass with the provided (optional) instance name.
      Type Parameters:
      S - The service type.
      Parameters:
      sClass - The service class.
      instanceName - The instance name. (can be null)
      Returns:
      The service instance (registered).