Skip to main content
The MaintenanceProvider class is the entry point for obtaining the Maintenance API instance. This is the first step in using the Maintenance API.

Overview

MaintenanceProvider is a singleton provider that gives you access to the main Maintenance API interface. You should always check if the API is available before using it.

Method

get

Returns the Maintenance API instance.
Maintenance
The Maintenance API instance, or null if the plugin is not loaded yet

Usage Examples

Basic Usage

The most common pattern is to obtain the API instance when you need it:

Caching the API Instance

If you need to use the API frequently, you can cache the instance:

Checking API Availability with Soft Dependency

If Maintenance is an optional dependency, check for availability:

Using in Commands

Example of using the API in a command:

Plugin Dependencies

To use the Maintenance API, add it as a dependency in your plugin.yml:

Hard Dependency

If your plugin requires Maintenance to function:

Soft Dependency

If Maintenance is optional:

Maven Dependency

Add the Maintenance API to your pom.xml:

Gradle Dependency

Add the Maintenance API to your build.gradle:

Next Steps

Once you have obtained the API instance, you can:
  • Use the Maintenance API to control maintenance mode
  • Access the Settings API to manage configuration and whitelists
  • Register event listeners using the EventManager