The Settings interface provides access to plugin configuration and methods for managing the maintenance whitelist.
Obtaining the Settings Instance
Get the Settings instance from the main Maintenance API:
import eu.kennytv.maintenance.api.Maintenance;
import eu.kennytv.maintenance.api.MaintenanceProvider;
import eu.kennytv.maintenance.api.Settings;
Maintenance api = MaintenanceProvider.get();
Settings settings = api.getSettings();
Methods
isMaintenance
Returns whether maintenance is currently enabled.
true if maintenance is currently enabled, false otherwise
if (settings.isMaintenance()) {
System.out.println("Maintenance mode is active");
}
isEnablePingMessages
Checks if custom ping messages during maintenance should be displayed.
true if custom ping messages are enabled, false otherwise
if (settings.isEnablePingMessages()) {
System.out.println("Custom ping messages are enabled");
}
isJoinNotifications
Checks if join notifications are enabled.
Value of the send-join-notification config field
if (settings.isJoinNotifications()) {
// Send notification when permitted player joins during maintenance
}
hasCustomIcon
Checks if a custom maintenance server icon is configured.
Value of the custom-maintenance-icon config field
if (settings.hasCustomIcon()) {
System.out.println("Custom maintenance icon is configured");
}
getWhitelistedPlayers
Returns a map of all maintenance-whitelisted players.
Map of player UUIDs to their saved names
import java.util.Map;
import java.util.UUID;
Map<UUID, String> whitelist = settings.getWhitelistedPlayers();
System.out.println("Whitelisted players: " + whitelist.size());
for (Map.Entry<UUID, String> entry : whitelist.entrySet()) {
System.out.println(entry.getValue() + " (" + entry.getKey() + ")");
}
The player names in the returned map might be outdated if a player has changed their name.
isWhitelisted
Checks if a player UUID is on the maintenance whitelist.
The UUID of the player to check
true if the UUID is whitelisted, false otherwise
import java.util.UUID;
UUID playerUuid = UUID.fromString("069a79f4-44e9-4726-a5be-fca90e38aaf5");
if (settings.isWhitelisted(playerUuid)) {
System.out.println("Player is whitelisted for maintenance mode");
} else {
System.out.println("Player is not whitelisted");
}
addWhitelistedPlayer
Adds a player to the maintenance whitelist.
The UUID of the player to add
The name of the player to add
true if the player was successfully added, false if already on the whitelist
import java.util.UUID;
UUID playerUuid = UUID.fromString("069a79f4-44e9-4726-a5be-fca90e38aaf5");
String playerName = "Notch";
if (settings.addWhitelistedPlayer(playerUuid, playerName)) {
System.out.println(playerName + " added to maintenance whitelist");
} else {
System.out.println(playerName + " is already whitelisted");
}
removeWhitelistedPlayer (UUID)
Removes a player from the maintenance whitelist by UUID.
The UUID of the player to remove
true if the player was successfully removed, false otherwise
import java.util.UUID;
UUID playerUuid = UUID.fromString("069a79f4-44e9-4726-a5be-fca90e38aaf5");
if (settings.removeWhitelistedPlayer(playerUuid)) {
System.out.println("Player removed from maintenance whitelist");
} else {
System.out.println("Player was not on the whitelist");
}
removeWhitelistedPlayer (String)
This method is deprecated. Use removeWhitelistedPlayer(UUID) instead. If a player changes their name, the list will still contain the old name.
Removes a player from the maintenance whitelist by name.
The name of the player to remove (with original case)
true if the player was successfully removed, false otherwise
// Deprecated - prefer using UUID method
if (settings.removeWhitelistedPlayer("Notch")) {
System.out.println("Player removed from whitelist");
}
reloadConfigs
Reloads all configuration files including maintenance icon, config, language file, and whitelisted players.
This method does not return a value
// Reload all configurations
settings.reloadConfigs();
System.out.println("Configuration files reloaded");
debugEnabled
Checks if debug mode is enabled in the configuration.
true if the debug config value is set to true, false otherwise
if (settings.debugEnabled()) {
System.out.println("Debug mode is enabled in config");
}
Complete Example
Here’s a complete example showing whitelist management:
import eu.kennytv.maintenance.api.Maintenance;
import eu.kennytv.maintenance.api.MaintenanceProvider;
import eu.kennytv.maintenance.api.Settings;
import java.util.Map;
import java.util.UUID;
public class WhitelistManager {
private final Settings settings;
public WhitelistManager() {
Maintenance api = MaintenanceProvider.get();
if (api == null) {
throw new IllegalStateException("Maintenance API not available");
}
this.settings = api.getSettings();
}
public void addPlayer(UUID uuid, String name) {
if (settings.isWhitelisted(uuid)) {
System.out.println(name + " is already whitelisted");
return;
}
if (settings.addWhitelistedPlayer(uuid, name)) {
System.out.println("Added " + name + " to maintenance whitelist");
} else {
System.err.println("Failed to add " + name + " to whitelist");
}
}
public void removePlayer(UUID uuid) {
if (settings.removeWhitelistedPlayer(uuid)) {
System.out.println("Player removed from maintenance whitelist");
} else {
System.out.println("Player was not on the whitelist");
}
}
public void listWhitelistedPlayers() {
Map<UUID, String> whitelist = settings.getWhitelistedPlayers();
if (whitelist.isEmpty()) {
System.out.println("No players are whitelisted for maintenance mode");
return;
}
System.out.println("=== Maintenance Whitelist ===");
System.out.println("Total players: " + whitelist.size());
for (Map.Entry<UUID, String> entry : whitelist.entrySet()) {
System.out.println("- " + entry.getValue() + " (" + entry.getKey() + ")");
}
}
public void displaySettings() {
System.out.println("=== Maintenance Settings ===");
System.out.println("Maintenance Active: " + settings.isMaintenance());
System.out.println("Ping Messages: " + settings.isEnablePingMessages());
System.out.println("Join Notifications: " + settings.isJoinNotifications());
System.out.println("Custom Icon: " + settings.hasCustomIcon());
System.out.println("Debug Mode: " + settings.debugEnabled());
System.out.println("Whitelisted Players: " + settings.getWhitelistedPlayers().size());
}
public void reloadConfiguration() {
settings.reloadConfigs();
System.out.println("Maintenance configuration reloaded");
}
}