Class Services

java.lang.Object
dev.demeng.pluginbase.Services

public final class Services extends Object
Utility class for interacting with the Bukkit ServicesManager.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> @NotNull Optional<T>
    get(@NotNull Class<T> clazz)
    Loads a service instance
    static <T> T
    load(@NotNull Class<T> clazz)
    Loads a service instance, throwing a IllegalStateException if no registration is present.
    static <T> T
    provide(@NotNull Class<T> clazz, T instance)
    Provides a service.
    static <T> T
    provide(@NotNull Class<T> clazz, T instance, @NotNull org.bukkit.plugin.Plugin plugin, @NotNull org.bukkit.plugin.ServicePriority priority)
    Provides a service.
    static <T> T
    provide(@NotNull Class<T> clazz, T instance, @NotNull org.bukkit.plugin.ServicePriority priority)
    Provides a service.

    Methods inherited from class java.lang.Object

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

    • Services

      public Services()
  • Method Details

    • load

      @NotNull public static <T> T load(@NotNull @NotNull Class<T> clazz)
      Loads a service instance, throwing a IllegalStateException if no registration is present.
      Type Parameters:
      T - the service class type
      Parameters:
      clazz - the service class
      Returns:
      the service instance
    • get

      @NotNull public static <T> @NotNull Optional<T> get(@NotNull @NotNull Class<T> clazz)
      Loads a service instance
      Type Parameters:
      T - the service class type
      Parameters:
      clazz - the service class
      Returns:
      the service instance, as an optional
    • provide

      @NotNull public static <T> T provide(@NotNull @NotNull Class<T> clazz, @NotNull T instance, @NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.plugin.ServicePriority priority)
      Provides a service.
      Type Parameters:
      T - the service class type
      Parameters:
      clazz - the service class
      instance - the service instance
      plugin - the plugin to register the service to
      priority - the priority to register the service instance at
      Returns:
      the same service instance
    • provide

      @NotNull public static <T> T provide(@NotNull @NotNull Class<T> clazz, @NotNull T instance, @NotNull @NotNull org.bukkit.plugin.ServicePriority priority)
      Provides a service.
      Type Parameters:
      T - the service class type
      Parameters:
      clazz - the service class
      instance - the service instance
      priority - the priority to register the service instance at
      Returns:
      the same service instance
    • provide

      @NotNull public static <T> T provide(@NotNull @NotNull Class<T> clazz, @NotNull T instance)
      Provides a service.
      Type Parameters:
      T - the service class type
      Parameters:
      clazz - the service class
      instance - the service instance
      Returns:
      the same service instance