Class DefaultConfig
java.lang.Object
io.github.projectunified.faststats.core.DefaultConfig
- All Implemented Interfaces:
Config
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultConfig(Path file, String[] comment, boolean externallyManaged, Properties properties, boolean firstRun, UUID serverId, boolean additionalMetrics, boolean submitMetrics, boolean debug, boolean enabled, int oldConfigVersion) Constructs a newDefaultConfiginstance. -
Method Summary
Modifier and TypeMethodDescriptionintRetrieves the previous version of the configuration file before loading/updating.getProperty(String key, String defaultValue) Gets a property value.Retrieves the unique identifier of the server.booleanisDebug()Checks if debug logging is enabled.booleanChecks if metrics submission is enabled.booleanChecks if this is the first time the metrics are running.booleanChecks if additional/custom metrics are enabled for submission.booleanChecks if metrics submission is enabled.static DefaultConfigReads a config from the specified path with default settings.static DefaultConfigReads a config from the specified path with custom comments and external control flags.voidsetDefaultProperty(Map<String, String> properties) Sets default properties.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Config
getConfigVersion
-
Field Details
-
DEFAULT_COMMENT
-
-
Constructor Details
-
DefaultConfig
public DefaultConfig(Path file, String[] comment, boolean externallyManaged, Properties properties, boolean firstRun, UUID serverId, boolean additionalMetrics, boolean submitMetrics, boolean debug, boolean enabled, int oldConfigVersion) Constructs a newDefaultConfiginstance.- Parameters:
file- the config file pathcomment- the comment headerexternallyManaged- true if configuration is externally managedproperties- the raw propertiesfirstRun- whether it is the first time running statsserverId- the server IDadditionalMetrics- whether to submit additional metricssubmitMetrics- whether to submit metricsdebug- whether debug logging is enabledenabled- whether metrics collection is enabledoldConfigVersion- the configuration version before upgrade
-
-
Method Details
-
read
Reads a config from the specified path with default settings.- Parameters:
file- the path to the config file- Returns:
- the loaded DefaultConfig
- Throws:
RuntimeException- if loading or saving fails
-
read
public static DefaultConfig read(Path file, String[] comment, boolean externallyManaged, boolean externallyEnabled) throws RuntimeException Reads a config from the specified path with custom comments and external control flags.- Parameters:
file- the path to the config filecomment- the comment header to write to the file if savedexternallyManaged- true if the configuration is controlled externallyexternallyEnabled- true if externally enabled- Returns:
- the loaded DefaultConfig
- Throws:
RuntimeException- if loading or saving fails
-
getServerId
Description copied from interface:ConfigRetrieves the unique identifier of the server.- Specified by:
getServerIdin interfaceConfig- Returns:
- the server identifier UUID
-
isEnabled
-
isSubmitAdditionalMetrics
public boolean isSubmitAdditionalMetrics()Description copied from interface:ConfigChecks if additional/custom metrics are enabled for submission.- Specified by:
isSubmitAdditionalMetricsin interfaceConfig- Returns:
- true if enabled, false otherwise
-
isSubmitMetrics
public boolean isSubmitMetrics()Description copied from interface:ConfigChecks if metrics submission is enabled.- Specified by:
isSubmitMetricsin interfaceConfig- Returns:
- true if enabled, false otherwise
-
isDebug
-
isFirstRun
public boolean isFirstRun()Description copied from interface:ConfigChecks if this is the first time the metrics are running.- Specified by:
isFirstRunin interfaceConfig- Returns:
- true if first run, false otherwise
-
setDefaultProperty
-
getProperty
Description copied from interface:ConfigGets a property value.- Specified by:
getPropertyin interfaceConfig- Parameters:
key- the keydefaultValue- the default value to return if not present- Returns:
- the property value or the default value
-
getOldConfigVersion
public int getOldConfigVersion()Description copied from interface:ConfigRetrieves the previous version of the configuration file before loading/updating. If the configuration file was not upgraded, it will be equal toConfig.getConfigVersion().- Specified by:
getOldConfigVersionin interfaceConfig- Returns:
- the previous configuration version, or
Config.getConfigVersion()if not updated
-