mirror of
https://github.com/PaperMC/Paper.git
synced 2025-05-19 05:30:23 -07:00
Add configuration interface to expose certain config values (#12273)
This commit is contained in:
parent
53d1d04ec5
commit
c98cd65802
@ -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();
|
||||||
|
}
|
@ -14,6 +14,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import io.papermc.paper.configuration.ServerConfiguration;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Warning.WarningState;
|
import org.bukkit.Warning.WarningState;
|
||||||
import org.bukkit.advancement.Advancement;
|
import org.bukkit.advancement.Advancement;
|
||||||
@ -1435,6 +1436,15 @@ public final class Bukkit {
|
|||||||
return server.getOnlineMode();
|
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.
|
* Gets whether this server allows flying or not.
|
||||||
*
|
*
|
||||||
|
@ -14,6 +14,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import io.papermc.paper.configuration.ServerConfiguration;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
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();
|
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.
|
* 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
|
* @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.
|
* wherever possible, rather than directly reading from a server config.
|
||||||
*
|
*
|
||||||
|
* @see #getServerConfig()
|
||||||
* @return The server's spigot config.
|
* @return The server's spigot config.
|
||||||
*/
|
*/
|
||||||
@Deprecated(since = "1.21.4", forRemoval = true)
|
@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
|
* @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.
|
* wherever possible, rather than directly reading from a server config.
|
||||||
*
|
*
|
||||||
|
* @see #getServerConfig()
|
||||||
* @return The server's bukkit config.
|
* @return The server's bukkit config.
|
||||||
*/
|
*/
|
||||||
// Paper start
|
// 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
|
* @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.
|
* wherever possible, rather than directly reading from a server config.
|
||||||
*
|
*
|
||||||
|
* @see #getServerConfig()
|
||||||
* @return The server's spigot config.
|
* @return The server's spigot config.
|
||||||
*/
|
*/
|
||||||
@Deprecated(since = "1.21.4", forRemoval = true)
|
@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
|
* @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.
|
* wherever possible, rather than directly reading from a server config.
|
||||||
*
|
*
|
||||||
|
* @see #getServerConfig()
|
||||||
* @return The server's paper config.
|
* @return The server's paper config.
|
||||||
*/
|
*/
|
||||||
@Deprecated(since = "1.21.4", forRemoval = true)
|
@Deprecated(since = "1.21.4", forRemoval = true)
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package io.papermc.paper.configuration;
|
||||||
|
|
||||||
|
public class PaperServerConfiguration implements ServerConfiguration {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isProxyOnlineMode() {
|
||||||
|
return GlobalConfiguration.get().proxies.isProxyOnlineMode();
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,8 @@ import com.mojang.brigadier.StringReader;
|
|||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import com.mojang.serialization.Dynamic;
|
import com.mojang.serialization.Dynamic;
|
||||||
import com.mojang.serialization.Lifecycle;
|
import com.mojang.serialization.Lifecycle;
|
||||||
|
import io.papermc.paper.configuration.PaperServerConfiguration;
|
||||||
|
import io.papermc.paper.configuration.ServerConfiguration;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -313,6 +315,7 @@ public final class CraftServer implements Server {
|
|||||||
private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher();
|
private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher();
|
||||||
private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer;
|
private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer;
|
||||||
public final io.papermc.paper.SparksFly spark;
|
public final io.papermc.paper.SparksFly spark;
|
||||||
|
private final ServerConfiguration serverConfig = new PaperServerConfiguration();
|
||||||
|
|
||||||
// Paper start - Folia region threading API
|
// Paper start - Folia region threading API
|
||||||
private final io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler();
|
private final io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler();
|
||||||
@ -1869,6 +1872,11 @@ public final class CraftServer implements Server {
|
|||||||
return this.console.usesAuthentication();
|
return this.console.usesAuthentication();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull ServerConfiguration getServerConfig() {
|
||||||
|
return serverConfig;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAllowFlight() {
|
public boolean getAllowFlight() {
|
||||||
return this.console.isFlightAllowed();
|
return this.console.isFlightAllowed();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user