// Path: src/main/java/de/jeter/chatex/ChatEx.java
// public class ChatEx extends JavaPlugin {
// 
//     private static ChatEx INSTANCE;
//     private UpdateChecker updatechecker = null;
// 
//     @Override
//     public void onEnable() {
//         INSTANCE = this;
// 
//         Config.load();
//         Locales.load();
//         PluginManager.load();
//         ChatLogger.load();
//         RGBColors.load();
// 
//         getServer().getPluginManager().registerEvents(new ChatListener(), this);
//         getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//         getCommand("chatex").setExecutor(new CommandHandler());
// 
//         if (Config.CHECK_UPDATE.getBoolean()) {
//             updatechecker = new UpdateChecker(this, 71041);
//         }
// 
//         ChannelHandler.load();
// 
//         if (Config.B_STATS.getBoolean()) {
//             Metrics metrics = new Metrics(this, 7744);
//             getLogger().info("Thanks for using bstats, it was enabled!");
//         }
// 
//         getLogger().info("is now enabled!");
//     }
// 
//     @Override
//     public void onDisable() {
//         ChatLogger.close();
//         getServer().getScheduler().cancelTasks(this);
//         getLogger().info("is now disabled!");
//     }
// 
//     public static ChatEx getInstance() {
//         return INSTANCE;
//     }
// 
//     public UpdateChecker getUpdateChecker() {
//         return this.updatechecker;
//     }
// }
// 
// Path: src/main/java/de/jeter/chatex/utils/HookManager.java
// public class HookManager {
// 
//     public static boolean checkVault() {
//         Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("Vault");
//         return plugin != null && plugin.isEnabled();
//     }
// 
//     public static boolean checkPlaceholderAPI() {
//         Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlaceholderAPI");
//         return plugin != null && plugin.isEnabled();
//     }
// 
// }
// 
// Path: src/main/java/de/jeter/chatex/utils/Utils.java
// public class Utils {
// 
//     public static String translateColorCodes(String string, Player p) {
//         return p.hasPermission("chatex.chat.color") ? replaceColors(string) : string;
//     }
// 
//     public static String replaceColors(String message) {
//         message = RGBColors.translateCustomColorCodes(message);
//         return ChatColor.translateAlternateColorCodes('&', message);
//     }
// 
//     public static List<Player> getLocalRecipients(Player sender) {
//         Location playerLocation = sender.getLocation();
//         List<Player> recipients = new ArrayList<>();
// 
//         double squaredDistance = Math.pow(Config.RANGE.getInt(), 2);
//         for (Player recipient : sender.getWorld().getPlayers()) {
//             if (Config.RANGE.getInt() > 0 && (playerLocation.distanceSquared(recipient.getLocation()) > squaredDistance)) {
//                 continue;
//             }
//             recipients.add(recipient);
//         }
// 
//         return recipients;
//     }
// 
//     public static String replacePlayerPlaceholders(Player player, String format) {
//         if (player == null) {
//             return format;
//         }
//         String result = format;
// 
//         if (HookManager.checkPlaceholderAPI()) {
//             result = PlaceholderAPI.setPlaceholders(player, result);
//         }
// 
//         result = result.replace("%displayname", player.getDisplayName());
//         result = result.replace("%prefix", PluginManager.getInstance().getPrefix(player));
//         result = result.replace("%suffix", PluginManager.getInstance().getSuffix(player));
//         result = result.replace("%player", player.getName());
//         result = result.replace("%world", player.getWorld().getName());
//         result = result.replace("%group", PluginManager.getInstance().getGroupNames(player).length > 0 ? PluginManager.getInstance().getGroupNames(player)[0] : "none");
//         result = replaceColors(result);
// 
//         return result;
//     }
// 
//     public static String escape(String string) {
//         return string.replace("%", "%%");
//     }
// 
//     public static boolean checkForBypassString(String message) {
//         for (String block : Config.ADS_BYPASS.getStringList()) {
//             if (message.toLowerCase().contains(block.toLowerCase())) {
//                 return true;
//             }
//         }
//         return false;
//     }
// 
//     public static void notifyOps(String msg) {
//         for (Player op : ChatEx.getInstance().getServer().getOnlinePlayers()) {
//             if (!op.hasPermission("chatex.notifyad")) {
//                 continue;
//             }
//             op.sendMessage(msg);
//         }
//     }
// 
// }


import de.jeter.chatex.ChatEx;
import de.jeter.chatex.utils.HookManager;
import de.jeter.chatex.utils.Utils;
import org.bukkit.entity.Player;
/*
 * This file is part of ChatEx
 * Copyright (C) 2020 ChatEx Team
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
package de.jeter.chatex.plugins;


public class PluginManager implements PermissionsPlugin {

    private static PermissionsPlugin handler;
    private static PluginManager INSTANCE;

    public static PermissionsPlugin getInstance() {
        return INSTANCE;
    }

    public static void load() {
        INSTANCE = new PluginManager();
// Path: src/main/java/de/jeter/chatex/ChatEx.java
// public class ChatEx extends JavaPlugin {
// 
//     private static ChatEx INSTANCE;
//     private UpdateChecker updatechecker = null;
// 
//     @Override
//     public void onEnable() {
//         INSTANCE = this;
// 
//         Config.load();
//         Locales.load();
//         PluginManager.load();
//         ChatLogger.load();
//         RGBColors.load();
// 
//         getServer().getPluginManager().registerEvents(new ChatListener(), this);
//         getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//         getCommand("chatex").setExecutor(new CommandHandler());
// 
//         if (Config.CHECK_UPDATE.getBoolean()) {
//             updatechecker = new UpdateChecker(this, 71041);
//         }
// 
//         ChannelHandler.load();
// 
//         if (Config.B_STATS.getBoolean()) {
//             Metrics metrics = new Metrics(this, 7744);
//             getLogger().info("Thanks for using bstats, it was enabled!");
//         }
// 
//         getLogger().info("is now enabled!");
//     }
// 
//     @Override
//     public void onDisable() {
//         ChatLogger.close();
//         getServer().getScheduler().cancelTasks(this);
//         getLogger().info("is now disabled!");
//     }
// 
//     public static ChatEx getInstance() {
//         return INSTANCE;
//     }
// 
//     public UpdateChecker getUpdateChecker() {
//         return this.updatechecker;
//     }
// }
// 
// Path: src/main/java/de/jeter/chatex/utils/HookManager.java
// public class HookManager {
// 
//     public static boolean checkVault() {
//         Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("Vault");
//         return plugin != null && plugin.isEnabled();
//     }
// 
//     public static boolean checkPlaceholderAPI() {
//         Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlaceholderAPI");
//         return plugin != null && plugin.isEnabled();
//     }
// 
// }
// 
// Path: src/main/java/de/jeter/chatex/utils/Utils.java
// public class Utils {
// 
//     public static String translateColorCodes(String string, Player p) {
//         return p.hasPermission("chatex.chat.color") ? replaceColors(string) : string;
//     }
// 
//     public static String replaceColors(String message) {
//         message = RGBColors.translateCustomColorCodes(message);
//         return ChatColor.translateAlternateColorCodes('&', message);
//     }
// 
//     public static List<Player> getLocalRecipients(Player sender) {
//         Location playerLocation = sender.getLocation();
//         List<Player> recipients = new ArrayList<>();
// 
//         double squaredDistance = Math.pow(Config.RANGE.getInt(), 2);
//         for (Player recipient : sender.getWorld().getPlayers()) {
//             if (Config.RANGE.getInt() > 0 && (playerLocation.distanceSquared(recipient.getLocation()) > squaredDistance)) {
//                 continue;
//             }
//             recipients.add(recipient);
//         }
// 
//         return recipients;
//     }
// 
//     public static String replacePlayerPlaceholders(Player player, String format) {
//         if (player == null) {
//             return format;
//         }
//         String result = format;
// 
//         if (HookManager.checkPlaceholderAPI()) {
//             result = PlaceholderAPI.setPlaceholders(player, result);
//         }
// 
//         result = result.replace("%displayname", player.getDisplayName());
//         result = result.replace("%prefix", PluginManager.getInstance().getPrefix(player));
//         result = result.replace("%suffix", PluginManager.getInstance().getSuffix(player));
//         result = result.replace("%player", player.getName());
//         result = result.replace("%world", player.getWorld().getName());
//         result = result.replace("%group", PluginManager.getInstance().getGroupNames(player).length > 0 ? PluginManager.getInstance().getGroupNames(player)[0] : "none");
//         result = replaceColors(result);
// 
//         return result;
//     }
// 
//     public static String escape(String string) {
//         return string.replace("%", "%%");
//     }
// 
//     public static boolean checkForBypassString(String message) {
//         for (String block : Config.ADS_BYPASS.getStringList()) {
//             if (message.toLowerCase().contains(block.toLowerCase())) {
//                 return true;
//             }
//         }
//         return false;
//     }
// 
//     public static void notifyOps(String msg) {
//         for (Player op : ChatEx.getInstance().getServer().getOnlinePlayers()) {
//             if (!op.hasPermission("chatex.notifyad")) {
//                 continue;
//             }
//             op.sendMessage(msg);
//         }
//     }
// 
// }


// Path: src/main/java/de/jeter/chatex/plugins/PluginManager.java
import de.jeter.chatex.ChatEx;
import de.jeter.chatex.utils.HookManager;
import de.jeter.chatex.utils.Utils;
import org.bukkit.entity.Player;

/*
 * This file is part of ChatEx
 * Copyright (C) 2020 ChatEx Team
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
package de.jeter.chatex.plugins;


public class PluginManager implements PermissionsPlugin {

    private static PermissionsPlugin handler;
    private static PluginManager INSTANCE;

    public static PermissionsPlugin getInstance() {
        return INSTANCE;
    }

    public static void load() {
        INSTANCE = new PluginManager();
        if (HookManager.checkVault() && Vault.setupChat()) {