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 booleangetBoolean(String key, boolean def) Gets the boolean value of the given key.default doubleGets the double value of the given key.default intGets the integer value of the given key.default StringGets the string value of the given key.Gets the raw value of the given key.booleanChecks if the config has the given key.
-
Method Details
-
hasKey
Checks if the config has the given key.- Parameters:
key- the key- Returns:
trueif the config has the key,falseotherwise
-
getValue
Gets the raw value of the given key. NOTE: This gets the raw value from the config, so it will be aStringeven if the value is a number, a boolean or an enum.- Parameters:
key- the key- Returns:
- the value or
nullif 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,
falseif 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
-