Package me.totalfreedom.service
Class SubscriptionProvider
java.lang.Object
me.totalfreedom.service.SubscriptionProvider
Provides static methods for creating
ServiceSubscription and TaskSubscription objects.-
Method Summary
Modifier and TypeMethodDescriptionstatic final <S extends Service>
@NotNull ServiceSubscription<S>asyncService(@NotNull org.bukkit.plugin.java.JavaPlugin plugin, long interval, S service) Creates a newServiceSubscriptionobject that will run the givenServiceobject on the given interval.static final <S extends Service>
@NotNull ServiceSubscription<S>asyncService(@NotNull org.bukkit.plugin.java.JavaPlugin plugin, S service) Creates a newServiceSubscriptionobject that will run the givenServiceobject on the default tick interval, which is a single tick.static final <T extends Task>
@NotNull TaskSubscription<T>runAsyncTask(@NotNull org.bukkit.plugin.java.JavaPlugin plugin, T task) Creates a newTaskSubscriptionobject that will run the givenTaskobject asynchronously on the main thread.static final <T extends Task>
@NotNull TaskSubscription<T>runSyncTask(@NotNull org.bukkit.plugin.java.JavaPlugin plugin, T task) Creates a newTaskSubscriptionobject that will run the givenTaskobject synchronously on the main thread.static final <S extends Service>
@NotNull ServiceSubscription<S>syncService(@NotNull org.bukkit.plugin.java.JavaPlugin plugin, long interval, S service) Creates a newServiceSubscriptionobject that will run the givenServiceobject on the main thread at the given interval.static final <S extends Service>
@NotNull ServiceSubscription<S>syncService(@NotNull org.bukkit.plugin.java.JavaPlugin plugin, S service) Creates a newServiceSubscriptionobject that will run the givenServiceobject on the main thread a single time.
-
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 newServiceSubscriptionobject that will run the givenServiceobject 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
ServiceSubscriptionobject.
-
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 newServiceSubscriptionobject that will run the givenServiceobject 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
ServiceSubscriptionobject.
-
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 newServiceSubscriptionobject that will run the givenServiceobject 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
ServiceSubscriptionobject.
-
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 newServiceSubscriptionobject that will run the givenServiceobject 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
ServiceSubscriptionobject.
-
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 newTaskSubscriptionobject that will run the givenTaskobject 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
TaskSubscriptionobject.
-
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 newTaskSubscriptionobject that will run the givenTaskobject 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
TaskSubscriptionobject.
-