Interface ConfigAccessor
public interface ConfigAccessor
An interface to access a config.
This is kept very generic, so it can be used for any config type.
This contains a few default methods to get primitive values from the config.
NOTE: You need to implement more complex values yourself (e.g. enums).
Can be obtained by calling
This contains a few default methods to get primitive values from the config.
NOTE: You need to implement more complex values yourself (e.g. enums).
Can be obtained by calling
VoicechatServerApi.getServerConfig()
or VoicechatClientApi.getClientConfig()
.-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
getBoolean
(String key, boolean def) Gets the boolean value of the given key.default double
Gets the double value of the given key.default int
Gets the integer value of the given key.default String
Gets the string value of the given key.Gets the raw value of the given key.boolean
Checks if the config has the given key.
-
Method Details
-
hasKey
Checks if the config has the given key.- Parameters:
key
- the key- Returns:
true
if the config has the key,false
otherwise
-
getValue
Gets the raw value of the given key. NOTE: This gets the raw value from the config, so it will be aString
even if the value is a number, a boolean or an enum.- Parameters:
key
- the key- Returns:
- the value or
null
if the key doesn't exist
-
getString
Gets the string value of the given key.- Parameters:
key
- the keydef
- the default value- Returns:
- the value or the default value if the key doesn't exist
-
getBoolean
Gets the boolean value of the given key.- Parameters:
key
- the keydef
- the default value- Returns:
- the boolean value,
false
if the value is not"true"
or the default value if the key doesn't exist
-
getInt
Gets the integer value of the given key.- Parameters:
key
- the keydef
- the default value- Returns:
- the value or the default value if the key doesn't exist
- Throws:
NumberFormatException
- if the value is not an integer
-
getDouble
Gets the double value of the given key.- Parameters:
key
- the keydef
- the default value- Returns:
- the value or the default value if the key doesn't exist
- Throws:
NumberFormatException
- if the value is not a double
-