Class PluginSettings

java.lang.Object
eu.mrapik.minecraftservermcp.config.PluginSettings

public final class PluginSettings extends Object
Immutable snapshot of the MCP plugin's config.yml: HTTP listen options, global limits, and the mapping from secret tokens to access profiles.

Load with load(JavaPlugin) after the default config has been saved or updated. The MCP HTTP server and MinecraftServerMcp.reloadConfiguration() both replace the active settings by reloading the file and constructing a new instance.

  • Method Details

    • load

      public static PluginSettings load(JavaPlugin plugin)
      Reads top-level keys (bindAddress, port, mcpPath, maxReadBytes) and the access tree. Each profile under access must define a non-blank token; profiles without a token are skipped with a warning. Duplicate token strings cause the later profile in the file to override the earlier one (warning logged).
      Parameters:
      plugin - MCP plugin whose JavaPlugin.getConfig() is used
      Returns:
      new immutable settings
    • profileByToken

      @Nullable public @Nullable TokenAccessProfile profileByToken(String token)
      Looks up the profile for a token string exactly as sent in the Authorization or X-MCP-Token header.
      Parameters:
      token - raw secret; may be null
      Returns:
      the profile, or null if the token is unknown
    • bindAddress

      public String bindAddress()
      Address Jetty binds to for MCP HTTP.
      Returns:
      listen address for the embedded HTTP server (e.g. 0.0.0.0)
    • port

      public int port()
      TCP listen port for MCP HTTP.
      Returns:
      TCP port for the embedded HTTP server
    • mcpPath

      public String mcpPath()
      Servlet path for the MCP endpoint (always starts with /).
      Returns:
      context path segment, e.g. /mcp
    • maxReadBytes

      public long maxReadBytes()
      Maximum number of bytes fs_read may return for one call (global cap; profiles can still tighten paths).
      Returns:
      max read size in bytes
    • ssl

      public SslSettings ssl()
      Optional TLS listener; when SslSettings.enabled() is true, clients may use https on SslSettings.port().
      Returns:
      SSL settings from the last loaded config (never null; may be SslSettings.disabled())
    • tokenToProfile

      public Map<String,TokenAccessProfile> tokenToProfile()
      All configured token-to-profile mappings. Keys are the secret token strings.
      Returns:
      immutable map from token to profile