Add configuration interface to expose certain config values (#12273)

This commit is contained in:
David
2025-05-03 22:33:25 +02:00
committed by GitHub
parent 53d1d04ec5
commit c98cd65802
5 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,24 @@
package io.papermc.paper.configuration;
/**
* Represents the configuration settings for a server.
* <p>
* This interface doesn't aim to cover every possible server configuration
* option but focuses on selected critical settings and behaviors.
*/
public interface ServerConfiguration {
/**
* Gets whether the server is in online mode.
* <p>
* This method returns true if:
* <ul>
* <li>The server is in {@link org.bukkit.Server#getOnlineMode online mode},</li>
* <li>Velocity is enabled and configured to be in online mode, or</li>
* <li>BungeeCord is enabled and configured to be in online mode.</li>
* </ul>
*
* @return whether the server is in online mode or behind a proxy configured for online mode
*/
boolean isProxyOnlineMode();
}

View File

@ -14,6 +14,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.logging.Logger;
import io.papermc.paper.configuration.ServerConfiguration;
import net.kyori.adventure.text.Component;
import org.bukkit.Warning.WarningState;
import org.bukkit.advancement.Advancement;
@ -1435,6 +1436,15 @@ public final class Bukkit {
return server.getOnlineMode();
}
/**
* Retrieves the server configuration.
*
* @return the instance of ServerConfiguration containing the server's configuration details
*/
public static @NotNull ServerConfiguration getServerConfig() {
return server.getServerConfig();
}
/**
* Gets whether this server allows flying or not.
*

View File

@ -14,6 +14,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.logging.Logger;
import io.papermc.paper.configuration.ServerConfiguration;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
@ -1267,6 +1268,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
public boolean getOnlineMode();
/**
* Retrieves the server configuration.
*
* @return the instance of ServerConfiguration containing the server's configuration details
*/
@NotNull ServerConfiguration getServerConfig();
/**
* Gets whether this server allows flying or not.
*
@ -2319,6 +2327,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @deprecated Server config options may be renamed or removed without notice. Prefer using existing API
* wherever possible, rather than directly reading from a server config.
*
* @see #getServerConfig()
* @return The server's spigot config.
*/
@Deprecated(since = "1.21.4", forRemoval = true)
@ -2331,6 +2340,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @deprecated Server config options may be renamed or removed without notice. Prefer using existing API
* wherever possible, rather than directly reading from a server config.
*
* @see #getServerConfig()
* @return The server's bukkit config.
*/
// Paper start
@ -2345,6 +2355,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @deprecated Server config options may be renamed or removed without notice. Prefer using existing API
* wherever possible, rather than directly reading from a server config.
*
* @see #getServerConfig()
* @return The server's spigot config.
*/
@Deprecated(since = "1.21.4", forRemoval = true)
@ -2358,6 +2369,7 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @deprecated Server config options may be renamed or removed without notice. Prefer using existing API
* wherever possible, rather than directly reading from a server config.
*
* @see #getServerConfig()
* @return The server's paper config.
*/
@Deprecated(since = "1.21.4", forRemoval = true)