Search in sources :

Example 6 with YamlConfiguration

use of com.loohp.interactivechat.libs.com.loohp.yamlconfiguration.YamlConfiguration in project InteractiveChat-DiscordSRV-Addon by LOOHP.

the class CMLMain method validConfigs.

protected static void validConfigs() throws IOException {
    File folder = new File("InteractiveChatDiscordSrvAddon");
    if (!folder.exists() || !folder.isDirectory()) {
        System.out.println("Error: Plugin folder not found");
        return;
    }
    Map<File, List<String>> results = new LinkedHashMap<>();
    for (File file : folder.listFiles()) {
        String fileName = file.getName();
        if (fileName.endsWith(".yml")) {
            YamlConfiguration yaml = new YamlConfiguration(new FileInputStream(file));
            results.put(file, validateConfigurationSection("", yaml));
        }
    }
    StringBuilder message = new StringBuilder("Validation Results: (Plugin Folder: " + folder.getAbsolutePath() + ")\n");
    for (Entry<File, List<String>> entry : results.entrySet()) {
        String fileName = entry.getKey().getName();
        List<String> errors = entry.getValue();
        message.append("\n").append(fileName).append(": ");
        if (errors.isEmpty()) {
            message.append("Valid!\n");
        } else {
            message.append("\n");
            for (String error : errors) {
                message.append(error).append("\n");
            }
        }
    }
    message.append("\nNote that a valid config doesn't mean REGEX are valid.");
    System.out.println(message);
}
Also used : List(java.util.List) LinkedList(java.util.LinkedList) YamlConfiguration(com.loohp.interactivechat.libs.com.loohp.yamlconfiguration.YamlConfiguration) File(java.io.File) FileInputStream(java.io.FileInputStream) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

YamlConfiguration (com.loohp.interactivechat.libs.com.loohp.yamlconfiguration.YamlConfiguration)6 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 PrintWriter (java.io.PrintWriter)3 StringWriter (java.io.StringWriter)3 List (java.util.List)3 ResourceManager (com.loohp.interactivechatdiscordsrvaddon.resources.ResourceManager)2 ResourcePackInfo (com.loohp.interactivechatdiscordsrvaddon.resources.ResourcePackInfo)2 Graphics2D (java.awt.Graphics2D)2 BufferedImage (java.awt.image.BufferedImage)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 PrintStream (java.io.PrintStream)2 Icon (javax.swing.Icon)2 JLabel (javax.swing.JLabel)2 GridConstraints (com.loohp.interactivechat.libs.com.intellij.uiDesigner.core.GridConstraints)1 GridLayoutManager (com.loohp.interactivechat.libs.com.intellij.uiDesigner.core.GridLayoutManager)1 Spacer (com.loohp.interactivechat.libs.com.intellij.uiDesigner.core.Spacer)1 Component (com.loohp.interactivechat.libs.net.kyori.adventure.text.Component)1 NamedTextColor (com.loohp.interactivechat.libs.net.kyori.adventure.text.format.NamedTextColor)1