Package io.github.simplex.api
Class ExecutableService
java.lang.Object
io.github.simplex.api.ExecutableService
- Direct Known Subclasses:
ServiceImpl
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
private final long
private final boolean
private final long
private final boolean
private final org.bukkit.NamespacedKey
-
Constructor Summary
ConstructorDescriptionExecutableService
(@NotNull org.bukkit.NamespacedKey service_name, @Nullable Long delay, @Nullable Long period, @NotNull Boolean repeating, @NotNull Boolean mayInterruptWhenRunning) Creates a new instance of an executable service. -
Method Summary
Modifier and TypeMethodDescription(package private) reactor.core.publisher.Mono<Void>
cancel()
Actual stop call, to ensure that the service actually #isCancelled().long
getDelay()
org.bukkit.NamespacedKey
long
boolean
Cancels the execution of this service.boolean
reactor.core.publisher.Mono<Void>
setCancelled
(boolean cancel) Cancels the execution of this service.
-
Field Details
-
service_name
private final org.bukkit.NamespacedKey service_name -
delay
private final long delay -
period
private final long period -
repeating
private final boolean repeating -
mayInterruptWhenRunning
private final boolean mayInterruptWhenRunning -
cancelled
private boolean cancelled
-
-
Constructor Details
-
ExecutableService
public ExecutableService(@NotNull @NotNull org.bukkit.NamespacedKey service_name, @Nullable @Nullable Long delay, @Nullable @Nullable Long period, @NotNull @NotNull Boolean repeating, @NotNull @NotNull Boolean mayInterruptWhenRunning) Creates a new instance of an executable service. The timings are measured in ticks (20 ticks per second). You do not need to explicitly define a delay or a period, however if you have flaggedrepeating
as true, and the period is null, then the period will automatically be set to 20 minutes. Each service is registered with aNamespacedKey
, to allow for easy identification within the associatedServicePool
.- Parameters:
service_name
- A namespaced key which can be used to identify the service.delay
- A specified amount of time (in ticks) to wait before the service runs.period
- How long the service should wait between service executions (in ticks).repeating
- If the service should be scheduled for repeated executions or not.mayInterruptWhenRunning
- If the service can be cancelled during execution.
-
-
Method Details
-
getNamespacedKey
public org.bukkit.NamespacedKey getNamespacedKey()- Specified by:
getNamespacedKey
in interfaceIService
- Returns:
- The NamespacedKey of this service.
-
getDelay
public long getDelay() -
getPeriod
public long getPeriod() -
isPeriodic
public boolean isPeriodic()- Specified by:
isPeriodic
in interfaceIService
- Returns:
- If the service should be scheduled for repeated executions or not.
-
isCancelled
public boolean isCancelled()Cancels the execution of this service.- Returns:
- true if the service was cancelled, false if not.
-
setCancelled
Cancels the execution of this service.- Parameters:
cancel
- Whether the service should be cancelled or not.
-
cancel
Actual stop call, to ensure that the service actually #isCancelled().
-