Search in sources :

Example 1 with YamlConfiguration

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

the class LegacyPlaceholdersConverter method convert.

public static void convert() {
    Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[HoloMobHealth] Translating old placeholders to new placeholders...");
    YamlConfiguration config = HoloMobHealth.getConfiguration();
    List<String> lines = config.getStringList("Display.Text");
    for (int i = 0; i < lines.size(); i++) {
        String line = lines.get(i);
        if (getLegacyPlaceholderSet().stream().anyMatch(each -> line.contains(each))) {
            String newline = line;
            for (Entry<String, String> entry : legacyPlaceholders.entrySet()) {
                newline = newline.replace(entry.getKey(), entry.getValue());
            }
            lines.set(i, newline);
        }
    }
    config.set("Display.Text", lines);
    HoloMobHealth.plugin.saveConfig();
    Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[HoloMobHealth] Translation complete!");
}
Also used : YamlConfiguration(com.loohp.yamlconfiguration.YamlConfiguration)

Example 2 with YamlConfiguration

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

the class InteractiveChat method onEnable.

@Override
public void onEnable() {
    plugin = this;
    externalProcessor = new ProcessExternalMessage();
    getServer().getPluginManager().registerEvents(new Debug(), this);
    Metrics metrics = new Metrics(this, BSTATS_PLUGIN_ID);
    exactMinecraftVersion = Bukkit.getVersion().substring(Bukkit.getVersion().indexOf("(") + 5, Bukkit.getVersion().indexOf(")"));
    version = MCVersion.fromPackageName(getServer().getClass().getPackage().getName());
    if (!version.isSupported()) {
        getServer().getConsoleSender().sendMessage(ChatColor.RED + "[InteractiveChat] This version of minecraft is unsupported! (" + version.toString() + ")");
    }
    if (!getDataFolder().exists()) {
        getDataFolder().mkdirs();
    }
    try {
        ConfigManager.setup();
    } catch (IOException e) {
        e.printStackTrace();
        getServer().getPluginManager().disablePlugin(this);
        return;
    }
    protocolManager = ProtocolLibrary.getProtocolManager();
    getCommand("interactivechat").setExecutor(new Commands());
    bungeecordMode = ConfigManager.getConfig().getBoolean("Settings.Bungeecord");
    if (bungeecordMode) {
        getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "[InteractiveChat] Registering Plugin Messaging Channels for bungeecord...");
        getServer().getMessenger().registerOutgoingPluginChannel(this, "interchat:main");
        getServer().getMessenger().registerIncomingPluginChannel(this, "interchat:main", bungeeMessageListener = new BungeeMessageListener(this));
        getServer().getPluginManager().registerEvents(new ServerPingListener(), this);
        ServerPingListener.listen();
        Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () -> {
            if (parsePAPIOnMainThread) {
                Bukkit.getScheduler().runTask(plugin, () -> {
                    for (Player player : Bukkit.getOnlinePlayers()) {
                        PlaceholderParser.parse(ICPlayerFactory.getICPlayer(player), usePlayerNameHoverText);
                        PlaceholderParser.parse(ICPlayerFactory.getICPlayer(player), usePlayerNameClickValue);
                    }
                });
            } else {
                for (Player player : Bukkit.getOnlinePlayers()) {
                    PlaceholderParser.parse(ICPlayerFactory.getICPlayer(player), usePlayerNameHoverText);
                    PlaceholderParser.parse(ICPlayerFactory.getICPlayer(player), usePlayerNameClickValue);
                }
            }
        }, 0, 100);
    }
    BiConsumer<String, Inventory> inventoryRemovalListener = (hash, inv) -> {
        Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> closeInventoryViews(inv));
    };
    itemDisplay.registerRemovalListener(inventoryRemovalListener);
    inventoryDisplay.registerRemovalListener(inventoryRemovalListener);
    inventoryDisplay1Upper.registerRemovalListener(inventoryRemovalListener);
    inventoryDisplay1Lower.registerRemovalListener(inventoryRemovalListener);
    enderDisplay.registerRemovalListener(inventoryRemovalListener);
    mapDisplay.registerRemovalListener((hash, item) -> {
        Bukkit.getScheduler().runTask(InteractiveChat.plugin, () -> {
            for (Player player : Bukkit.getOnlinePlayers()) {
                boolean removed = MapViewer.MAP_VIEWERS.remove(player, item);
                if (removed) {
                    // noinspection deprecation
                    player.getInventory().setItemInHand(player.getInventory().getItemInHand());
                }
            }
        });
    });
    YamlConfiguration storage = ConfigManager.getStorageConfig();
    database = new Database(false, getDataFolder(), storage.getString("StorageType"), storage.getString("MYSQL.Host"), storage.getString("MYSQL.Database"), storage.getString("MYSQL.Username"), storage.getString("MYSQL.Password"), storage.getInt("MYSQL.Port"));
    database.setup();
    placeholderCooldownManager = new PlaceholderCooldownManager();
    getServer().getPluginManager().registerEvents(new ChatEvents(), this);
    getServer().getPluginManager().registerEvents(new InventoryEvents(), this);
    getServer().getPluginManager().registerEvents(new PlayerUtils(), this);
    getServer().getPluginManager().registerEvents(new OutChatPacket(), this);
    getServer().getPluginManager().registerEvents(new MapViewer(), this);
    OutChatPacket.chatMessageListener();
    if (!version.isLegacy()) {
        OutTabCompletePacket.tabCompleteListener();
    }
    RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
    perms = rsp.getProvider();
    if (isPluginEnabled("SuperVanish") || isPluginEnabled("PremiumVanish")) {
        getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[InteractiveChat] InteractiveChat has hooked into SuperVanish/PremiumVanish!");
        vanishHook = true;
    }
    if (isPluginEnabled("CMI", false)) {
        getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[InteractiveChat] InteractiveChat has hooked into CMI!");
        cmiHook = true;
    }
    if (isPluginEnabled("Essentials")) {
        getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[InteractiveChat] InteractiveChat has hooked into Essentials!");
        essentialsHook = true;
        getServer().getPluginManager().registerEvents(new EssentialsNicknames(), this);
        EssentialsNicknames._init_();
    }
    if (isPluginEnabled("EssentialsDiscord")) {
        getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[InteractiveChat] InteractiveChat has hooked into EssentialsDiscord!");
        essentialsDiscordHook = true;
        getServer().getPluginManager().registerEvents(new EssentialsDiscord(), this);
    }
    if (isPluginEnabled("DiscordSRV")) {
        getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[InteractiveChat] InteractiveChat has hooked into DiscordSRV!");
        DiscordSRV.api.subscribe(new DiscordSRVEvents());
        discordSrvHook = true;
    }
    if (isPluginEnabled("ViaVersion")) {
        getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[InteractiveChat] InteractiveChat has hooked into ViaVersion!");
        viaVersionHook = true;
    }
    if (isPluginEnabled("ProtocolSupport")) {
        getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[InteractiveChat] InteractiveChat has hooked into ProtocolSupport!");
        protocolSupportHook = true;
    }
    if (isPluginEnabled("eco")) {
        getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[InteractiveChat] InteractiveChat has hooked into Eco (Core)!");
        ecoHook = true;
    }
    if (isPluginEnabled("LuckPerms")) {
        getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[InteractiveChat] InteractiveChat has hooked into LuckPerms!");
        new LuckPermsEvents(this);
        luckPermsHook = true;
    }
    if (isPluginEnabled("MysqlPlayerDataBridge")) {
        getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[InteractiveChat] InteractiveChat has hooked into MysqlPlayerDataBridge!");
        mysqlPDBHook = true;
    }
    if (isPluginEnabled("VentureChat")) {
        VentureChatInjection._init_();
        getServer().getConsoleSender().sendMessage(ChatColor.LIGHT_PURPLE + "[InteractiveChat] InteractiveChat has injected into VentureChat!");
        ventureChatHook = true;
    }
    if (isPluginEnabled("dynmap")) {
        getServer().getConsoleSender().sendMessage(ChatColor.LIGHT_PURPLE + "[InteractiveChat] InteractiveChat has injected into Dynmap!");
        DynmapListener._init_();
        dynmapHook = true;
    }
    PlayernameDisplay.setup();
    MentionDisplay.setup();
    Charts.setup(metrics);
    if (updaterEnabled) {
        getServer().getPluginManager().registerEvents(new Updater(), this);
    }
    ClientSettingPacket.clientSettingsListener();
    playerDataManager = new PlayerDataManager(this, database);
    nicknameManager = new NicknameManager(uuid -> InteractiveChatAPI.getNicknames(uuid), () -> InteractiveChatAPI.getOnlineICPlayers().stream().filter(each -> each.isLocal()).map(each -> each.getUniqueId()).collect(Collectors.toSet()), 5000, (uuid, nicknames) -> {
        if (InteractiveChat.bungeecordMode) {
            Player bukkitPlayer = Bukkit.getPlayer(uuid);
            if (bukkitPlayer != null) {
                Set<String> nicks = new HashSet<>(nicknames);
                if (InteractiveChat.useBukkitDisplayName) {
                    nicks.add(bukkitPlayer.getDisplayName());
                }
                try {
                    BungeeMessageSender.forwardNicknames(System.currentTimeMillis(), uuid, nicks);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    });
    if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
        new Placeholders().register();
    }
    getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "[InteractiveChat] InteractiveChat has been Enabled!");
    Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
        if (queueRemoteUpdate && Bukkit.getOnlinePlayers().size() > 0) {
            try {
                if (BungeeMessageSender.resetAndForwardPlaceholderList(System.currentTimeMillis(), InteractiveChat.placeholderList.values())) {
                    queueRemoteUpdate = false;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }, 0, 100);
    try {
        Logger logger = LogManager.getRootLogger();
        LogFilter filter = new LogFilter();
        Method method = logger.getClass().getMethod("addFilter", Filter.class);
        method.invoke(logger, filter);
    } catch (Exception e) {
        Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[InteractiveChat] Unable to add filter to logger, safely skipping...");
    }
    gc();
}
Also used : Plugin(org.bukkit.plugin.Plugin) InventoryUtils(com.loohp.interactivechat.utils.InventoryUtils) PlayerUtils(com.loohp.interactivechat.utils.PlayerUtils) ValuePairs(com.loohp.interactivechat.objectholders.ValuePairs) InteractiveChatAPI(com.loohp.interactivechat.api.InteractiveChatAPI) Player(org.bukkit.entity.Player) Inventory(org.bukkit.inventory.Inventory) ClientSettingPacket(com.loohp.interactivechat.listeners.ClientSettingPacket) ICPlayer(com.loohp.interactivechat.objectholders.ICPlayer) InteractiveChatComponentSerializer(com.loohp.interactivechat.utils.InteractiveChatComponentSerializer) Map(java.util.Map) MentionPair(com.loohp.interactivechat.objectholders.MentionPair) NicknameManager(com.loohp.interactivechat.objectholders.NicknameManager) Method(java.lang.reflect.Method) PlayerDataManager(com.loohp.interactivechat.data.PlayerDataManager) PlaceholderCooldownManager(com.loohp.interactivechat.objectholders.PlaceholderCooldownManager) ChatEvents(com.loohp.interactivechat.listeners.ChatEvents) Bukkit(org.bukkit.Bukkit) Placeholders(com.loohp.interactivechat.placeholderapi.Placeholders) CommandSender(org.bukkit.command.CommandSender) BungeeMessageListener(com.loohp.interactivechat.bungeemessaging.BungeeMessageListener) YamlConfiguration(com.loohp.yamlconfiguration.YamlConfiguration) Filter(org.apache.logging.log4j.core.Filter) Updater(com.loohp.interactivechat.updater.Updater) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) EssentialsDiscord(com.loohp.interactivechat.hooks.essentials.EssentialsDiscord) ConcurrentCacheHashMap(com.loohp.interactivechat.objectholders.ConcurrentCacheHashMap) InventoryEvents(com.loohp.interactivechat.listeners.InventoryEvents) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) OutTabCompletePacket(com.loohp.interactivechat.listeners.OutTabCompletePacket) ItemStack(org.bukkit.inventory.ItemStack) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) ComponentSerializer(net.md_5.bungee.chat.ComponentSerializer) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) ProtocolManager(com.comphenix.protocol.ProtocolManager) Charts(com.loohp.interactivechat.metrics.Charts) Permission(net.milkbowl.vault.permission.Permission) ProtocolLibrary(com.comphenix.protocol.ProtocolLibrary) BungeeMessageSender(com.loohp.interactivechat.bungeemessaging.BungeeMessageSender) DynmapListener(com.loohp.interactivechat.hooks.dynmap.DynmapListener) MCVersion(com.loohp.interactivechat.utils.MCVersion) MentionDisplay(com.loohp.interactivechat.modules.MentionDisplay) HashMap(java.util.HashMap) ClickEvent(net.kyori.adventure.text.event.ClickEvent) EssentialsNicknames(com.loohp.interactivechat.hooks.essentials.EssentialsNicknames) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Database(com.loohp.interactivechat.data.Database) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) DiscordSRV(github.scarsz.discordsrv.DiscordSRV) ProcessExternalMessage(com.loohp.interactivechat.modules.ProcessExternalMessage) Component(net.kyori.adventure.text.Component) BiConsumer(java.util.function.BiConsumer) ICPlaceholder(com.loohp.interactivechat.objectholders.ICPlaceholder) LegacyComponentSerializer(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer) WeakHashMap(java.util.WeakHashMap) VentureChatInjection(com.loohp.interactivechat.hooks.venturechat.VentureChatInjection) OutChatPacket(com.loohp.interactivechat.listeners.OutChatPacket) ConfigManager(com.loohp.interactivechat.config.ConfigManager) LuckPermsEvents(com.loohp.interactivechat.hooks.luckperms.LuckPermsEvents) Metrics(com.loohp.interactivechat.metrics.Metrics) Debug(com.loohp.interactivechat.debug.Debug) IOException(java.io.IOException) MapViewer(com.loohp.interactivechat.listeners.MapViewer) AtomicLong(java.util.concurrent.atomic.AtomicLong) PlayernameDisplay(com.loohp.interactivechat.modules.PlayernameDisplay) EventPriority(org.bukkit.event.EventPriority) ICPlayerFactory(com.loohp.interactivechat.objectholders.ICPlayerFactory) DiscordSRVEvents(com.loohp.interactivechat.hooks.discordsrv.DiscordSRVEvents) LogFilter(com.loohp.interactivechat.objectholders.LogFilter) ChatColor(org.bukkit.ChatColor) PlaceholderParser(com.loohp.interactivechat.utils.PlaceholderParser) LogManager(org.apache.logging.log4j.LogManager) RegisteredServiceProvider(org.bukkit.plugin.RegisteredServiceProvider) Collections(java.util.Collections) ServerPingListener(com.loohp.interactivechat.bungeemessaging.ServerPingListener) Set(java.util.Set) HashSet(java.util.HashSet) ServerPingListener(com.loohp.interactivechat.bungeemessaging.ServerPingListener) ProcessExternalMessage(com.loohp.interactivechat.modules.ProcessExternalMessage) YamlConfiguration(com.loohp.yamlconfiguration.YamlConfiguration) EssentialsDiscord(com.loohp.interactivechat.hooks.essentials.EssentialsDiscord) Logger(org.apache.logging.log4j.Logger) Metrics(com.loohp.interactivechat.metrics.Metrics) Updater(com.loohp.interactivechat.updater.Updater) Database(com.loohp.interactivechat.data.Database) Permission(net.milkbowl.vault.permission.Permission) Debug(com.loohp.interactivechat.debug.Debug) PlayerUtils(com.loohp.interactivechat.utils.PlayerUtils) Player(org.bukkit.entity.Player) ICPlayer(com.loohp.interactivechat.objectholders.ICPlayer) InventoryEvents(com.loohp.interactivechat.listeners.InventoryEvents) ChatEvents(com.loohp.interactivechat.listeners.ChatEvents) DiscordSRVEvents(com.loohp.interactivechat.hooks.discordsrv.DiscordSRVEvents) IOException(java.io.IOException) Method(java.lang.reflect.Method) EssentialsNicknames(com.loohp.interactivechat.hooks.essentials.EssentialsNicknames) NicknameManager(com.loohp.interactivechat.objectholders.NicknameManager) IOException(java.io.IOException) PlayerDataManager(com.loohp.interactivechat.data.PlayerDataManager) Placeholders(com.loohp.interactivechat.placeholderapi.Placeholders) MapViewer(com.loohp.interactivechat.listeners.MapViewer) OutChatPacket(com.loohp.interactivechat.listeners.OutChatPacket) LuckPermsEvents(com.loohp.interactivechat.hooks.luckperms.LuckPermsEvents) BungeeMessageListener(com.loohp.interactivechat.bungeemessaging.BungeeMessageListener) PlaceholderCooldownManager(com.loohp.interactivechat.objectholders.PlaceholderCooldownManager) Inventory(org.bukkit.inventory.Inventory) LogFilter(com.loohp.interactivechat.objectholders.LogFilter)

Example 3 with YamlConfiguration

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

the class CMLMain method launch.

public static void launch(String[] args) {
    try {
        YamlConfiguration pluginYaml = new YamlConfiguration(CMLMain.class.getClassLoader().getResourceAsStream("plugin.yml"));
        String pluginName = pluginYaml.getString("name");
        String version = pluginYaml.getString("version");
        System.out.println("Starting " + pluginName + " v" + version + " Tools...");
        System.out.println();
        main: while (true) {
            System.out.println("You are running " + pluginName + " v" + version);
            System.out.println();
            System.out.println("Links:");
            System.out.println("SpigotMC: \"https://www.spigotmc.org/resources/75870/\"");
            System.out.println("GitHub: \"https://github.com/LOOHP/InteractiveChat\"");
            System.out.println("Build Server: \"https://ci.loohpjames.com\"");
            System.out.println();
            System.out.println("Select one of the tools by typing in their corresponding number");
            System.out.println("1. Check for Updates   2. Validate Plugin Configs   3.Generate Default Configs   4. Exit");
            String input = IN.readLine();
            switch(input) {
                case "1":
                    checkForUpdates(version);
                    break;
                case "2":
                    validConfigs();
                    break;
                case "3":
                    generateDefaultConfigs();
                    break;
                default:
                    break main;
            }
        }
    } catch (Throwable e) {
        System.err.println("An error occurred!");
        e.printStackTrace();
    }
}
Also used : YamlConfiguration(com.loohp.yamlconfiguration.YamlConfiguration)

Example 4 with YamlConfiguration

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

the class GUIMain method launch.

public static void launch(String[] args) {
    String title = "InteractiveChat Tools";
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        YamlConfiguration pluginYaml = new YamlConfiguration(GUIMain.class.getClassLoader().getResourceAsStream("plugin.yml"));
        String pluginName = pluginYaml.getString("name");
        String version = pluginYaml.getString("version");
        BufferedImage image = ImageIO.read(GUIMain.class.getClassLoader().getResourceAsStream("icon.png"));
        Icon icon = new ImageIcon(image);
        title = pluginName + " v" + version + " Tools";
        String message = "<html><center><b>You are running " + pluginName + " v" + version + "</b><br>" + "Select one of the tools below<html/>";
        JLabel messageLabel = createLabel(message, 15);
        messageLabel.setHorizontalAlignment(SwingConstants.CENTER);
        main: while (true) {
            int input = JOptionPane.showOptionDialog(null, messageLabel, title, JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, icon, new Object[] { "Check for Updates", "Validate Plugin Configs", "Generate Default Configs", "Custom Placeholder Creator", "Visit Links" }, null);
            switch(input) {
                case 0:
                    checkForUpdates(title, icon, version);
                    break;
                case 1:
                    validConfigs(title, icon);
                    break;
                case 2:
                    generateDefaultConfigs(title, icon);
                    break;
                case 3:
                    BufferedImage resizedIcon = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
                    Graphics2D g = resizedIcon.createGraphics();
                    g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
                    g.drawImage(image, 0, 0, 32, 32, null);
                    g.dispose();
                    customPlaceholderCreator(title, resizedIcon, icon);
                    break main;
                case 4:
                    visitLinks(title, icon);
                    break;
                default:
                    break main;
            }
        }
    } catch (Throwable e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        Toolkit.getDefaultToolkit().beep();
        JOptionPane.showMessageDialog(null, createLabel("An error occurred!\n" + sw, 13, Color.RED), title, JOptionPane.ERROR_MESSAGE);
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) StringWriter(java.io.StringWriter) JLabel(javax.swing.JLabel) JSONObject(org.json.simple.JSONObject) ImageIcon(javax.swing.ImageIcon) Icon(javax.swing.Icon) YamlConfiguration(com.loohp.yamlconfiguration.YamlConfiguration) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) PrintWriter(java.io.PrintWriter)

Example 5 with YamlConfiguration

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

the class GUIMain method validConfigs.

protected static void validConfigs(String title, Icon icon) throws IOException {
    File folder = new File("InteractiveChat");
    if (!folder.exists() || !folder.isDirectory()) {
        folder = new File("InteractiveChatBungee");
        if (!folder.exists() || !folder.isDirectory()) {
            Toolkit.getDefaultToolkit().beep();
            JOptionPane.showMessageDialog(null, createLabel("Error: Plugin folder not found", 15, Color.RED), title, JOptionPane.ERROR_MESSAGE, icon);
            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.");
    JOptionPane.showMessageDialog(null, createLabel(message.toString(), 13), title, JOptionPane.INFORMATION_MESSAGE, icon);
}
Also used : LinkedList(java.util.LinkedList) List(java.util.List) 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