Skip to main content

Overview

The Maintenance API provides an event system that allows you to react to changes in maintenance status and configuration reloads. Events are handled through the EventManager interface.

Registering Event Listeners

Event listeners extend the EventListener<T> abstract class and are registered through the EventManager:

Handling MaintenanceChangedEvent

The MaintenanceChangedEvent is fired whenever maintenance mode is enabled or disabled:
The MaintenanceChangedEvent is a record containing a single boolean field isMaintenance() that indicates whether maintenance is now enabled or disabled.

Handling MaintenanceReloadedEvent

The MaintenanceReloadedEvent is fired when the Maintenance plugin’s configuration is reloaded:
The MaintenanceReloadedEvent doesn’t contain any data. Use Maintenance.isMaintenance() to check the current status after a reload.

Multiple Event Listeners

You can register multiple listeners for different events:

Complete Integration Example

Here’s a complete example showing a plugin that integrates with maintenance events:

Best Practices

Always check if MaintenanceProvider.get() returns null before using the API. The Maintenance plugin may not be loaded yet.
Register your event listeners in your plugin’s onEnable() method to ensure they’re active as soon as your plugin loads.
When your plugin enables, check the current maintenance state with maintenance.isMaintenance() and adjust your plugin’s behavior accordingly.
For complex event handling, consider creating separate listener classes instead of anonymous inner classes for better code organization.

Next Steps

Basic Usage

Learn basic API operations and usage

Proxy Integration

Manage per-server maintenance on proxy networks