Class SchedulingSystem<T extends org.bukkit.plugin.java.JavaPlugin>

java.lang.Object
io.github.simplexdevelopment.scheduler.SchedulingSystem<T>
Type Parameters:
T - Your plugin class, which extends JavaPlugin.
All Implemented Interfaces:
ISchedule

public final class SchedulingSystem<T extends org.bukkit.plugin.java.JavaPlugin> extends Object implements ISchedule
This class is used to manage the scheduling of IServices, and the creation of ServicePools through the ServiceManager. The ServiceManager should be used to create new ServicePools on initialization of your plugin, and your IServices should be registered in the JavaPlugin.onEnable() method. You can then use the queue(IService) method to then queue up your services, or call queueAll() to queue up all services in every pool. forceStart(IService) and forceStop(IService) will forcefully start and stop the services, respectively. getMainScheduler() gets the main scheduler for the scheduling system, which is a ReactorBukkitScheduler object.
See Also:
  • Field Details

    • denom

      static int denom
      A denominator to use when registering default service pool names.
    • serviceManager

      private final ServiceManager serviceManager
      The service manager to use for controlling service pools.
    • plugin

      private final T extends org.bukkit.plugin.java.JavaPlugin plugin
      The plugin to use for registering tasks. This should be an instance of your plugin.
    • mainScheduler

      private final ReactorBukkitScheduler mainScheduler
      The main scheduler which this system runs on. This is an abstraction of the BukkitScheduler, and as a result runs on the Main server thread.
  • Constructor Details

    • SchedulingSystem

      public SchedulingSystem(T plugin)
      Creates a new instance of the scheduling system. This is used to manage the scheduling of services.
      Parameters:
      plugin - The plugin to use for this scheduling system. This should be an instance of your plugin.
  • Method Details

    • getServiceManager

      @NotNull public @NotNull reactor.core.publisher.Mono<ServiceManager> getServiceManager()
      Specified by:
      getServiceManager in interface ISchedule
      Returns:
      The service manager which exerts control over the service pools and their associated services.
    • queue

      @NotNull public @NotNull reactor.core.publisher.Mono<reactor.core.Disposable> queue(@NotNull @NotNull IService service)
      Description copied from interface: ISchedule
      Queues a service to be executed in a service pool.
      Specified by:
      queue in interface ISchedule
      Parameters:
      service - The service to use to locate the associated service pool and queue the service for execution.
      Returns:
      A Mono object that can be used to cancel the service.
    • queueAll

      public reactor.core.publisher.Flux<reactor.core.Disposable> queueAll()
    • runOnce

      @NotNull public @NotNull reactor.core.publisher.Mono<Void> runOnce(IService service)
      Specified by:
      runOnce in interface ISchedule
      Parameters:
      service - The service to run once.
      Returns:
      A Mono object which can be used to run the service one time using Mono.subscribe().
    • forceStop

      public reactor.core.publisher.Mono<Void> forceStop(IService service)
      Specified by:
      forceStop in interface ISchedule
      Parameters:
      service - The service to forcefully stop.
      Returns:
      A Mono object which can be used to forcefully stop the service with Mono.subscribe().
    • forceStart

      public reactor.core.publisher.Mono<Void> forceStart(IService service)
      Specified by:
      forceStart in interface ISchedule
      Parameters:
      service - The service to forcefully start.
      Returns:
      A Mono object which can be used to forcefully start the service with Mono.subscribe().
    • getProvidingPlugin

      @NotNull public @NotNull reactor.core.publisher.Mono<T> getProvidingPlugin()
      Returns:
      A Mono object containing your plugin, for non-blocking communication.
    • getMainScheduler

      @Contract(pure=true) public ReactorBukkitScheduler getMainScheduler()
      Returns:
      The main thread which the scheduling system operates on.