Class JsonConfig

java.lang.Object
me.efekos.simpler.config.JsonConfig

public class JsonConfig extends Object
Another type of configuration that can read JSON files.
  • Constructor Details

    • JsonConfig

      public JsonConfig(String resourceName, org.bukkit.plugin.java.JavaPlugin plugin)
      Another type of configuration that can read JSON files.
      Parameters:
      resourceName - Name of the resource you want to use as this config. Make sure that your resource name ends with `.yml` and you have a resource with the exact same name on your 'resources' folder.
      plugin - An instance of your plugin.
  • Method Details

    • setup

      public void setup() throws FileNotFoundException
      Loads the default configuration file to your plugin's data folder. Recommended to use inside JavaPlugin.onEnable().
      Throws:
      FileNotFoundException - when you don't have a default config file in your 'resources' folder.
    • getString

      public String getString(String path, String def)
      Finds a String from the configuration
      Parameters:
      path - Path to the String you want.
      def - Default String to be returned in case nothing found in path. There are good reasons behind this parameter being required.
      Returns:
      Whatever found.
    • getBoolean

      public Boolean getBoolean(String path, boolean def)
      Finds a Boolean from the configuration
      Parameters:
      path - Path to the Boolean you want.
      def - Default Boolean to be returned in case nothing found in path. There are good reasons behind this parameter being required.
      Returns:
      Whatever found.
    • getCharacter

      public Character getCharacter(String path, char def)
      Finds a Character from the configuration
      Parameters:
      path - Path to the Character you want.
      def - Default Character to be returned in case nothing found in path. There are good reasons behind this parameter being required.
      Returns:
      Whatever found.
    • getInteger

      public Integer getInteger(String path, int def)
      Finds an Integer from the configuration
      Parameters:
      path - Path to the Integer you want.
      def - Default Integer to be returned in case nothing found in path. There are good reasons behind this parameter being required.
      Returns:
      Whatever found.
    • getDouble

      public Double getDouble(String path, double def)
      Finds a Double from the configuration
      Parameters:
      path - Path to the Double you want.
      def - Default Double to be returned in case nothing found in path. There are good reasons behind this parameter being required.
      Returns:
      Whatever found.
    • getList

      public List<Object> getList(String path)
      Finds a list from config. Please note that:
      • Every boolean inside an array was saved as Boolean
      • Every string inside an array was saved as String
      • Every number inside an array was saved as Number
      • Every object inside an array was saved as JsonObject
      • Every array inside an array was saved as JsonArray
      Parameters:
      path - Key of the value that you want.
      Returns:
      A list if found, null otherwise.
    • reload

      public void reload()
      Reloads the config by reading the file again.