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 debug, boolean enabled) Constructs a newDefaultConfiginstance. -
Method Summary
Modifier and TypeMethodDescriptiongetProperty(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.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.
-
Field Details
-
DEFAULT_COMMENT
-
-
Constructor Details
-
DefaultConfig
public DefaultConfig(Path file, String[] comment, boolean externallyManaged, Properties properties, boolean firstRun, UUID serverId, boolean additionalMetrics, boolean debug, boolean enabled) 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 metricsdebug- whether debug logging is enabledenabled- whether metrics collection is enabled
-
-
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
-
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
-