Class SubscriptionProvider

java.lang.Object
me.totalfreedom.service.SubscriptionProvider

public final class SubscriptionProvider extends Object
Provides static methods for creating ServiceSubscription and TaskSubscription objects.
  • Method Details

    • syncService

      @NotNull @Contract(value="_, _ -> new", pure=false) public static final <S extends Service> @NotNull ServiceSubscription<S> syncService(@NotNull @NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull S service)
      Creates a new ServiceSubscription object that will run the given Service object on the main thread a single time.
      Type Parameters:
      S - Type inference to maintain the service type.
      Parameters:
      plugin - The plugin that owns the service.
      service - The service to run.
      Returns:
      The new ServiceSubscription object.
    • syncService

      @NotNull @Contract(value="_,_,_ -> new", pure=false) public static final <S extends Service> @NotNull ServiceSubscription<S> syncService(@NotNull @NotNull org.bukkit.plugin.java.JavaPlugin plugin, long interval, @NotNull S service)
      Creates a new ServiceSubscription object that will run the given Service object on the main thread at the given interval.
      Type Parameters:
      S - Type inference to maintain the service type.
      Parameters:
      plugin - The plugin that owns the service.
      interval - The interval to run the service at.
      service - The service to run.
      Returns:
      The new ServiceSubscription object.
    • asyncService

      @NotNull @Contract(value="_, _ -> new", pure=false) public static final <S extends Service> @NotNull ServiceSubscription<S> asyncService(@NotNull @NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull S service)
      Creates a new ServiceSubscription object that will run the given Service object on the default tick interval, which is a single tick. This method will create an asynchronous service.
      Type Parameters:
      S - Type inference to maintain the service type.
      Parameters:
      plugin - The plugin that owns the service.
      service - The service to run.
      Returns:
      The new ServiceSubscription object.
    • asyncService

      @NotNull @Contract(value="_,_,_ -> new", pure=false) public static final <S extends Service> @NotNull ServiceSubscription<S> asyncService(@NotNull @NotNull org.bukkit.plugin.java.JavaPlugin plugin, long interval, @NotNull S service)
      Creates a new ServiceSubscription object that will run the given Service object on the given interval. This method will create an asynchronous service.
      Type Parameters:
      S - Type inference to maintain the service type.
      Parameters:
      plugin - The plugin that owns the service.
      interval - The interval to run the service at.
      service - The service to run.
      Returns:
      The new ServiceSubscription object.
    • runSyncTask

      @NotNull @Contract(value="_, _ -> new", pure=false) public static final <T extends Task> @NotNull TaskSubscription<T> runSyncTask(@NotNull @NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull T task)
      Creates a new TaskSubscription object that will run the given Task object synchronously on the main thread.
      Type Parameters:
      T - Type inference to maintain the task type.
      Parameters:
      plugin - The plugin that owns the task.
      task - The task to run.
      Returns:
      The new TaskSubscription object.
    • runAsyncTask

      @NotNull @Contract(value="_, _ -> new", pure=false) public static final <T extends Task> @NotNull TaskSubscription<T> runAsyncTask(@NotNull @NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull T task)
      Creates a new TaskSubscription object that will run the given Task object asynchronously on the main thread.
      Type Parameters:
      T - Type inference to maintain the task type.
      Parameters:
      plugin - The plugin that owns the task.
      task - The task to run.
      Returns:
      The new TaskSubscription object.