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 VoicechatServerApi.getServerConfig() or VoicechatClientApi.getClientConfig().
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    getBoolean(String key, boolean def)
    Gets the boolean value of the given key.
    default double
    getDouble(String key, double def)
    Gets the double value of the given key.
    default int
    getInt(String key, int def)
    Gets the integer value of the given key.
    default String
    getString(String key, String def)
    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

      boolean hasKey(String key)
      Checks if the config has the given key.
      Parameters:
      key - the key
      Returns:
      true if the config has the key, false otherwise
    • getValue

      @Nullable String getValue(String key)
      Gets the raw value of the given key. NOTE: This gets the raw value from the config, so it will be a String 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

      default String getString(String key, String def)
      Gets the string value of the given key.
      Parameters:
      key - the key
      def - the default value
      Returns:
      the value or the default value if the key doesn't exist
    • getBoolean

      default boolean getBoolean(String key, boolean def)
      Gets the boolean value of the given key.
      Parameters:
      key - the key
      def - 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

      default int getInt(String key, int def)
      Gets the integer value of the given key.
      Parameters:
      key - the key
      def - 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

      default double getDouble(String key, double def)
      Gets the double value of the given key.
      Parameters:
      key - the key
      def - 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