How to Access Configuration Files in Pumpkin-MC/Pumpkin: A Complete Guide

Pumpkin-MC stores runtime settings in a single TOML file named pumpkin.toml located in the server’s working directory, loaded through the PumpkinConfig struct in the pumpkin-config crate which merges user values with defaults and validates the final configuration.

The Pumpkin-MC Minecraft server implementation uses a robust configuration system centered around the pumpkin-config crate. Understanding how to access configuration files in Pumpkin-MC/Pumpkin is essential for server administrators and plugin developers who need to read or modify runtime settings programmatically. The system revolves around the PumpkinConfig struct and its implementation of the LoadConfiguration trait.

Configuration Architecture Overview

The pumpkin.toml File Structure

Pumpkin-MC uses a single TOML configuration file named pumpkin.toml stored in the server’s working directory. This file aggregates all runtime settings into two main categories managed by separate structs.

Core Configuration Structs

The configuration system is built around three primary structures:

  • PumpkinConfig: The top-level container that implements the loading logic.
  • BasicConfiguration: Contains core server settings including world seed, game mode, and dimensions.
  • AdvancedConfiguration: Houses optional feature-specific settings such as logging, networking, and plugin configurations.

Loading Configuration Files Programmatically

The configuration loading process is handled by the LoadConfiguration trait implemented for PumpkinConfig. When the server starts, it invokes PumpkinConfig::load(config_dir), where config_dir represents the folder containing pumpkin.toml.

The loading process follows four distinct steps:

  1. Directory creation: Creates the configuration directory if it does not exist.
  2. File initialization: Reads the existing pumpkin.toml or generates a default file if missing.
  3. Value merging: Combines user-provided values with default implementations, filling any missing entries.
  4. Validation: Ensures final values meet requirements such as view-distance bounds and encryption settings.

The default configuration is automatically generated from the Default trait implementations of BasicConfiguration and AdvancedConfiguration.

use pumpkin_config::PumpkinConfig;
use std::path::Path;

/// Load the configuration from the current working directory.
fn load_server_config() -> PumpkinConfig {
    let config_dir = Path::new(".");
    PumpkinConfig::load(config_dir)
}

fn main() {
    // Load and inspect the config
    let cfg = load_server_config();

    // Access basic settings
    println!("World seed: {}", cfg.basic.seed);
    println!("Default gamemode: {:?}", cfg.basic.default_gamemode);

    // Access advanced networking settings
    println!(
        "Java view distance: {}",
        cfg.advanced.networking.java.view_distance
    );
}

Accessing Specific Configuration Values

Once loaded, the PumpkinConfig instance provides direct access to all server settings through its basic and advanced fields.

Retrieving the World Folder Path

The BasicConfiguration struct includes the get_world_path() method for retrieving the default world storage location. In pumpkin-config/src/lib.rs, lines 13-18 implement this functionality.

use pumpkin_config::PumpkinConfig;
use std::path::Path;

let cfg = PumpkinConfig::load(Path::new("."));
let world_path = cfg.basic.get_world_path();
println!("World data will be stored in: {}", world_path.display());

Advanced configuration options are organized into sub-structures. Accessing networking parameters requires traversing the advanced field to reach protocol-specific settings.

Configuration Source Files and Implementation Details

The configuration system spans several files within the pumpkin-config crate:

  • pumpkin-config/src/lib.rs: Contains the central PumpkinConfig definition and loading logic (lines 51-98), along with BasicConfiguration::get_world_path (lines 13-18).
  • pumpkin-config/src/world.rs: Defines LevelConfig for world-level advanced settings.
  • pumpkin-config/src/networking.rs: Implements networking sub-configuration including Java and Bedrock protocol settings, compression thresholds, and view distances.
  • README.md: Provides high-level project overview and configuration enablement instructions.

Summary

  • Pumpkin-MC uses a single pumpkin.toml file in the working directory for all runtime configuration.
  • The PumpkinConfig struct aggregates BasicConfiguration and AdvancedConfiguration to organize settings hierarchically.
  • Use PumpkinConfig::load(config_dir) to initialize the configuration, which automatically creates defaults and validates input.
  • Access specific values through the basic and advanced fields, or retrieve the world path via BasicConfiguration::get_world_path().
  • The implementation resides in the pumpkin-config crate, with core logic in pumpkin-config/src/lib.rs.

Frequently Asked Questions

Where is the configuration file located?

Pumpkin-MC expects the pumpkin.toml file to reside in the server’s working directory (the path passed to PumpkinConfig::load). If the file is missing, the server automatically generates a default configuration with sensible values based on the Default trait implementations.

What format does Pumpkin-MC use for configuration?

The server uses TOML (Tom's Obvious, Minimal Language) format for its configuration files. This format supports nested structures, which Pumpkin-MC utilizes to separate basic server settings from advanced feature configurations like networking and logging.

How do I access the world folder path programmatically?

Call the get_world_path() method on the BasicConfiguration instance. This method is defined at lines 13-18 of pumpkin-config/src/lib.rs and returns a PathBuf pointing to the world storage directory configured for the server instance.

What happens if pumpkin.toml contains invalid values?

The configuration loader validates settings after merging user values with defaults. Invalid configurations (such as view distances outside acceptable bounds or incompatible encryption settings) will trigger validation errors during the load process, preventing the server from starting with malformed settings.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →