Package net.glowstone.util.config
Class ServerConfig
java.lang.Object
net.glowstone.util.config.ServerConfig
- All Implemented Interfaces:
DynamicallyTypedMap<ServerConfig.Key>
Utilities for handling the server configuration files.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
An enum containing configuration keys used by the server. -
Field Summary
-
Constructor Summary
ConstructorDescriptionServerConfig
(File directory, File configFile, Map<ServerConfig.Key, Object> parameters) Initialize a new ServerConfig and associated settings. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Retrieves an entry as aboolean
.org.bukkit.configuration.file.YamlConfiguration
org.bukkit.configuration.ConfigurationSection
Returns the file that contains a given setting.The directory configurations are stored in.int
getInt
(ServerConfig.Key key) Retrieves an entry as anint
.Retrieves a section as a list of maps.Retrieves an entry as aString
.org.bukkit.configuration.ConfigurationSection
void
load()
Loads the server config from disk.void
save()
Save the configuration back to file.void
set
(ServerConfig.Key key, Object value) Change a configuration value at runtime.
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORT- See Also:
-
-
Constructor Details
-
ServerConfig
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
Change a configuration value at runtime.- Parameters:
key
- the config key to write the value tovalue
- value to write to config key- See Also:
-
getString
Description copied from interface:DynamicallyTypedMap
Retrieves an entry as aString
.- Specified by:
getString
in interfaceDynamicallyTypedMap<ServerConfig.Key>
- Parameters:
key
- the key to look up- Returns:
- the value as a String
-
getInt
Description copied from interface:DynamicallyTypedMap
Retrieves an entry as anint
.- Specified by:
getInt
in interfaceDynamicallyTypedMap<ServerConfig.Key>
- Parameters:
key
- the key to look up- Returns:
- the value as an int
-
getBoolean
Description copied from interface:DynamicallyTypedMap
Retrieves an entry as aboolean
.- Specified by:
getBoolean
in interfaceDynamicallyTypedMap<ServerConfig.Key>
- Parameters:
key
- the key to look up- Returns:
- the value as a boolean
-
getMapList
Retrieves a section as a list of maps.- Parameters:
key
- the key to look up- Returns:
- the value as a list of maps
-
getConfigFile
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
-
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
The directory configurations are stored in.
-