Skip to content
ID

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.

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.

boolean isRestartActive();
Optional<Integer> getSecondsRemaining();
ZonedDateTime getNextScheduledRestart();
boolean startRestart(int seconds, boolean manual);
boolean cancelRestart();

Returns true while the restart phase is COUNTDOWN or COMMITTED.

Returns an Optional<Integer> only while COUNTDOWN is active. It is empty while idle or committed.

Returns the next scheduled countdown start as ZonedDateTime, or null when no schedule exists.

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.

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.

All restart mutation paths are primary-thread guarded, so these lifecycle events are fired from the server primary thread.

Class: id.funix.mFAutoRestart.api.event.AutoRestartStartEvent
Cancellable: Yes
When: Immediately before a countdown is activated

Values:

  • getDurationSeconds()
  • isManual()

Cancelling the event rejects the countdown start.

Class: id.funix.mFAutoRestart.api.event.AutoRestartPreShutdownEvent
Cancellable: Yes
When: At the terminal 0-second boundary before the restart becomes COMMITTED

Cancelling the event aborts the current countdown and returns the restart state to idle.

Class: id.funix.mFAutoRestart.api.event.AutoRestartCancelEvent
Cancellable: No
When: After an active countdown has been cancelled successfully

Value:

  • getCancelledBy()
@EventHandler
public void onRestartStart(AutoRestartStartEvent event) {
if (event.isManual() && event.getDurationSeconds() < 10) {
event.setCancelled(true);
}
}

The example uses only methods present in the delivered event class.