Class ServerPropertiesFile
java.lang.Object
me.pauleff.common.handlers.files.ServerPropertiesFile
-
Method Summary
Modifier and TypeMethodDescriptionstatic ServerPropertiesFileReturns a handle for the given properties file path.path()Returns the path to this properties file.Reads thelevel-namevalue from this properties file.static StringReads thelevel-namevalue from the given properties file.voidwriteProperty(String key, String value) Updates a key-value entry in this properties file, or appends it if the key is not present.static voidwriteProperty(Path path, String key, String value) Updates a key-value entry in the given properties file, or appends it if absent.
-
Method Details
-
of
Returns a handle for the given properties file path.- Parameters:
path- the path toserver.properties- Returns:
- a properties file handle
- Throws:
NullPointerException- ifpathisnull
-
worldName
-
writeProperty
Updates a key-value entry in the given properties file, or appends it if absent.- Parameters:
path- the path to the properties filekey- the property key to setvalue- the property value to write- Throws:
IOException- if reading or writing the file fails
-
path
-
worldName
Reads thelevel-namevalue from this properties file.Returns
"world"if the property is missing or the file cannot be read.- Returns:
- the configured world name, or
"world"as a fallback
-
writeProperty
Updates a key-value entry in this properties file, or appends it if the key is not present.Matching lines are identified by a
key=prefix. Line order and unrelated content are preserved. The file is rewritten in place.- Parameters:
key- the property key to setvalue- the property value to write- Throws:
NullPointerException- ifkeyorvalueisnullIOException- if reading or writing the file fails
-