Developer API
MF-AutoRestart exposes id.funix.mFAutoRestart.api.MFAutoRestartAPI through Bukkit’s ServicesManager after the plugin reaches its ready state. The service is unregistered when the plugin disables.
Obtaining the API
Section titled “Obtaining the API”MFAutoRestartAPI api = Bukkit.getServicesManager().load(MFAutoRestartAPI.class);if (api == null) { // MF-AutoRestart is absent or not ready. return;}An integrating plugin must compile against the actual MF-AutoRestart API classes it uses. This documentation does not define a public Maven repository for MF-AutoRestart.
Methods
Section titled “Methods”boolean isRestartActive();Optional<Integer> getSecondsRemaining();ZonedDateTime getNextScheduledRestart();boolean startRestart(int seconds, boolean manual);boolean cancelRestart();isRestartActive()
Section titled “isRestartActive()”Returns true while the restart phase is COUNTDOWN or COMMITTED.
getSecondsRemaining()
Section titled “getSecondsRemaining()”Returns an Optional<Integer> only while COUNTDOWN is active. It is empty while idle or committed.
getNextScheduledRestart()
Section titled “getNextScheduledRestart()”Returns the next scheduled countdown start as ZonedDateTime, or null when no schedule exists.
startRestart(int seconds, boolean manual)
Section titled “startRestart(int seconds, boolean manual)”Mutation method. It must be called from the server primary thread.
Returns false when the plugin is not ready, the call is off-thread, the duration is not positive, another restart is active, a start event is already being dispatched, or AutoRestartStartEvent cancels the request.
manual = true identifies the request as manual. manual = false identifies it as automatic for event/logging behavior.
cancelRestart()
Section titled “cancelRestart()”Mutation method. It must be called from the server primary thread.
It only succeeds while the phase is COUNTDOWN. It returns false while idle, committed, off-thread, or not ready.
Events
Section titled “Events”All restart mutation paths are primary-thread guarded, so these lifecycle events are fired from the server primary thread.
AutoRestartStartEvent
Section titled “AutoRestartStartEvent”Class: id.funix.mFAutoRestart.api.event.AutoRestartStartEventCancellable: YesWhen: Immediately before a countdown is activatedValues:
getDurationSeconds()isManual()
Cancelling the event rejects the countdown start.
AutoRestartPreShutdownEvent
Section titled “AutoRestartPreShutdownEvent”Class: id.funix.mFAutoRestart.api.event.AutoRestartPreShutdownEventCancellable: YesWhen: At the terminal 0-second boundary before the restart becomes COMMITTEDCancelling the event aborts the current countdown and returns the restart state to idle.
AutoRestartCancelEvent
Section titled “AutoRestartCancelEvent”Class: id.funix.mFAutoRestart.api.event.AutoRestartCancelEventCancellable: NoWhen: After an active countdown has been cancelled successfullyValue:
getCancelledBy()
Listener Example
Section titled “Listener Example”@EventHandlerpublic void onRestartStart(AutoRestartStartEvent event) { if (event.isManual() && event.getDurationSeconds() < 10) { event.setCancelled(true); }}The example uses only methods present in the delivered event class.