Overview | EssentialsC | SchedulesApi
net.godlycow.org.essc.api

Interface SchedulesApi

public interface SchedulesApi

API interface for interacting with EssentialsC's schedule system. Schedules are loaded from schedules.yml and support both time-based (cron-like) and interval-based triggering. All schedule state changes are synchronous and must be called on the main thread.

Retrieve an instance via EssentialsCAPI.getSchedulesApi().

SchedulesApi schedules = APIProvider.getAPI().getSchedulesApi();

schedules.getSchedule("announcement").ifPresent(s -> {
    if (s.isActive()) {
        schedules.runNow("announcement");
    }
});

The ScheduleEntry record lives in the net.godlycow.org.essc.api.schedule sub-package.

Method Summary

List<String> getScheduleNames()
Returns a list of all configured schedule names.
Optional<ScheduleEntry> getSchedule(String name)
Returns the schedule entry with the given name, if it exists.
List<ScheduleEntry> getAllSchedules()
Returns all configured schedules as a list.
boolean isMasterEnabled()
Returns whether the schedule system master switch is enabled.
void setMasterEnabled(boolean enabled)
Sets the master enable state for the schedule system.
boolean runNow(String name)
Immediately executes the schedule with the given name.
boolean pause(String name)
Pauses the schedule with the given name.
boolean resume(String name)
Resumes the schedule with the given name.
void reload()
Reloads all schedules from disk.
Method Detail
public List<String> getScheduleNames()

Returns a list of all configured schedule names.

Returns:
List<String>an unmodifiable list of schedule names; never null
public Optional<ScheduleEntry> getSchedule(String name)

Returns the schedule entry with the given name, if it exists.

Parameters:
namethe schedule name to look up; must not be null
Returns:
Optional<ScheduleEntry>an Optional containing the schedule, or empty if not found
public List<ScheduleEntry> getAllSchedules()

Returns all configured schedules as a list.

Returns:
List<ScheduleEntry>an unmodifiable list of all schedules; never null
public boolean isMasterEnabled()

Returns whether the schedule system master switch is enabled.

Returns:
booleantrue if schedules are globally enabled
public void setMasterEnabled(boolean enabled)

Sets the master enable state for the schedule system.

When disabled, all scheduled tasks are stopped. When enabled, tasks are restarted according to their individual configurations. This change is persisted to schedules.yml.

Warning: Must be called on the main thread.
Parameters:
enabledtrue to enable schedules globally
public boolean runNow(String name)

Immediately executes the schedule with the given name.

Runs all actions for the schedule's current target players, regardless of trigger conditions or cooldowns.

Warning: Must be called on the main thread.
Parameters:
namethe schedule to run; must not be null
Returns:
booleantrue if the schedule was found and executed
public boolean pause(String name)

Pauses the schedule with the given name.

Paused schedules will not trigger automatically, but can still be executed manually via runNow(String).

Warning: Must be called on the main thread.
Parameters:
namethe schedule to pause; must not be null
Returns:
booleantrue if the schedule was found and is now paused
public boolean resume(String name)

Resumes the schedule with the given name.

Unpauses a previously paused schedule, allowing it to trigger automatically again.

Warning: Must be called on the main thread.
Parameters:
namethe schedule to resume; must not be null
Returns:
booleantrue if the schedule was found and is now resumed
public void reload()

Reloads all schedules from disk.

Re-reads schedules.yml, stops all current tasks, and restarts them with the new configuration. This is equivalent to /schedules reload.

Warning: Must be called on the main thread.