Class ServiceSubscription<T extends Service>

java.lang.Object
me.totalfreedom.service.ServiceSubscription<T>
Type Parameters:
T - The type of service this subscription is for.

public final class ServiceSubscription<T extends Service> extends Object
Represents a subscription to a Service.

Subscriptions contain some information about the service itself and it's presence on the scheduler. For example, getServiceId() will return the ID of the task which was returned by the scheduler. Subscriptions also manage the state of the service, using isActive() to determine if the service is currently running.

The subscription itself provides type inference to safely store the actual service instance. This is useful for when we need to access the service itself, without calling to the service directly.

  • Method Details

    • start

      public void start()
      Starts the service.
    • stop

      public void stop()
      Stops the service.
    • getServiceId

      public int getServiceId()
      Returns the ID of the service from the associated BukkitTask which was returned by the Scheduler.
      Returns:
      The ID of the service.
    • getService

      @NotNull public T getService()
      Returns:
      The service this subscription is for.
    • isAsync

      public boolean isAsync()
      Returns:
      Whether this is an asynchronous service.
    • isActive

      public boolean isActive()
      Returns:
      Whether the service is currently running.