Search in sources :

Example 6 with YamlConfiguration

use of com.loohp.yamlconfiguration.YamlConfiguration in project InteractiveChat by LOOHP.

the class CMLMain method validConfigs.

protected static void validConfigs() throws IOException {
    File folder = new File("InteractiveChat");
    if (!folder.exists() || !folder.isDirectory()) {
        folder = new File("InteractiveChatBungee");
        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.yamlconfiguration.YamlConfiguration) File(java.io.File) FileInputStream(java.io.FileInputStream) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

YamlConfiguration (com.loohp.yamlconfiguration.YamlConfiguration)6 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ProtocolLibrary (com.comphenix.protocol.ProtocolLibrary)1 ProtocolManager (com.comphenix.protocol.ProtocolManager)1 InteractiveChatAPI (com.loohp.interactivechat.api.InteractiveChatAPI)1 BungeeMessageListener (com.loohp.interactivechat.bungeemessaging.BungeeMessageListener)1 BungeeMessageSender (com.loohp.interactivechat.bungeemessaging.BungeeMessageSender)1 ServerPingListener (com.loohp.interactivechat.bungeemessaging.ServerPingListener)1 ConfigManager (com.loohp.interactivechat.config.ConfigManager)1 Database (com.loohp.interactivechat.data.Database)1 PlayerDataManager (com.loohp.interactivechat.data.PlayerDataManager)1 Debug (com.loohp.interactivechat.debug.Debug)1 DiscordSRVEvents (com.loohp.interactivechat.hooks.discordsrv.DiscordSRVEvents)1 DynmapListener (com.loohp.interactivechat.hooks.dynmap.DynmapListener)1 EssentialsDiscord (com.loohp.interactivechat.hooks.essentials.EssentialsDiscord)1 EssentialsNicknames (com.loohp.interactivechat.hooks.essentials.EssentialsNicknames)1