Class YamlUtils

java.lang.Object
fr.sandro642.github.misc.YamlUtils

public class YamlUtils extends Object
YamlUtils is a utility class for handling YAML files in the ConnectLib library. It provides methods to read configuration values such as the base URL, logging settings, and routes from a YAML file.
  • Constructor Details

    • YamlUtils

      public YamlUtils()
  • Method Details

    • getURL

      public String getURL()
      Gets the base URL from the YAML configuration file. * This method reads the `infos.yml` file located in the directory specified by the
      Returns:
      the base URL as a String, or null if an error occurs.
    • isLogEnabled

      public Boolean isLogEnabled()
      Checks if logging is enabled in the YAML configuration file. This method reads the `infos.yml` file and retrieves the `enableLogs` setting.
      Returns:
      true if logging is enabled, false if disabled, or null if an error occurs.
    • getRoutes

      public Map<String,String> getRoutes()
      Retrieves the routes defined in the YAML configuration file. This method reads the `infos.yml` file and returns a map of routes.
      Returns:
      a map of route names to their corresponding paths, or null if an error occurs.
    • generateTemplateIfNotExists

      public void generateTemplateIfNotExists(Map<Enum<?>,String> routes)
      Generates a template `infos.yml` file if it does not already exist. If the file exists, it updates the routes section with the provided routes.
      Parameters:
      routes - a map of route names to their corresponding paths