Class ServerConfig

java.lang.Object
net.glowstone.util.config.ServerConfig
All Implemented Interfaces:
DynamicallyTypedMap<ServerConfig.Key>

public class ServerConfig extends Object implements DynamicallyTypedMap<ServerConfig.Key>
Utilities for handling the server configuration files.
  • Field Details

  • Constructor Details

    • ServerConfig

      public ServerConfig(File directory, File configFile, Map<ServerConfig.Key,Object> parameters)
      Initialize a new ServerConfig and associated settings.
      Parameters:
      directory - The config directory, or null for default.
      configFile - The config file, or null for default.
      parameters - The command-line parameters used as overrides.
  • Method Details

    • save

      public void save()
      Save the configuration back to file.
    • set

      public void set(ServerConfig.Key key, Object value)
      Change a configuration value at runtime.
      Parameters:
      key - the config key to write the value to
      value - value to write to config key
      See Also:
    • getString

      public String getString(ServerConfig.Key key)
      Description copied from interface: DynamicallyTypedMap
      Retrieves an entry as a String.
      Specified by:
      getString in interface DynamicallyTypedMap<ServerConfig.Key>
      Parameters:
      key - the key to look up
      Returns:
      the value as a String
    • getInt

      public int getInt(ServerConfig.Key key)
      Description copied from interface: DynamicallyTypedMap
      Retrieves an entry as an int.
      Specified by:
      getInt in interface DynamicallyTypedMap<ServerConfig.Key>
      Parameters:
      key - the key to look up
      Returns:
      the value as an int
    • getBoolean

      public boolean getBoolean(ServerConfig.Key key)
      Description copied from interface: DynamicallyTypedMap
      Retrieves an entry as a boolean.
      Specified by:
      getBoolean in interface DynamicallyTypedMap<ServerConfig.Key>
      Parameters:
      key - the key to look up
      Returns:
      the value as a boolean
    • getMapList

      public List<Map<?,?>> getMapList(ServerConfig.Key key)
      Retrieves a section as a list of maps.
      Parameters:
      key - the key to look up
      Returns:
      the value as a list of maps
    • getConfigFile

      public org.bukkit.configuration.ConfigurationSection getConfigFile(ServerConfig.Key key)
      Returns the file that contains a given setting. If it doesn't exist, it is created and populated with defaults.
      Parameters:
      key - the configuration setting
      Returns:
      the file containing that setting
    • getWorlds

      public org.bukkit.configuration.ConfigurationSection getWorlds()
    • getFile

      public File getFile(@NonNls @NonNls String filename)
    • load

      public void load()
      Loads the server config from disk. If it doesn't exist, the default config is written, creating the folder if necessary. If it's in the old bukkit.yml format and/or incomplete, it is converted to canonical form and saved.
    • getConfig

      public org.bukkit.configuration.file.YamlConfiguration getConfig()
    • getDirectory

      public File getDirectory()
      The directory configurations are stored in.