Search in sources :

Example 1 with UChatBungee

use of br.net.fabiozumbi12.UltimateChat.Bukkit.Bungee.UChatBungee in project UltimateChat by FabioZumbi12.

the class UChat method onEnable.

public void onEnable() {
    try {
        uchat = this;
        logger = new UCLogger(this);
        config = new UCConfig(this);
        lang = new UCLang();
        amConfig = new YamlConfiguration();
        // check hooks
        Vault = checkVault();
        SClans = checkSC();
        MarryReloded = checkMR();
        MarryMaster = checkMM();
        ProtocolLib = checkPL();
        PlaceHolderAPI = checkPHAPI();
        Factions = checkFac();
        listener = new UCListener();
        getServer().getPluginCommand("uchat").setExecutor(listener);
        getServer().getPluginManager().registerEvents(listener, this);
        getServer().getPluginManager().registerEvents(new UCChatProtection(), this);
        getServer().getMessenger().registerOutgoingPluginChannel(this, "uChat");
        getServer().getMessenger().registerIncomingPluginChannel(this, "uChat", new UChatBungee());
        // register aliases
        registerAliases();
        if (ProtocolLib) {
            logger.info("ProtocolLib found. Hooked.");
        }
        if (PlaceHolderAPI) {
            try {
                Class.forName("me.clip.placeholderapi.expansion.Relational");
                if (new UCPlaceHoldersRelational(this).register()) {
                    isRelation = true;
                    logger.info("PlaceHolderAPI found. Hooked and registered some chat placeholders with relational tag feature.");
                }
            } catch (ClassNotFoundException ex) {
                if (new UCPlaceHolders(this).register()) {
                    isRelation = false;
                    logger.info("PlaceHolderAPI found. Hooked and registered some chat placeholders.");
                }
            }
        }
        if (MarryReloded) {
            mapi = MarriageAPI.getInstance();
            logger.info("Marriage Reloaded found. Hooked.");
        }
        if (MarryMaster) {
            mm = (MarriageMaster) Bukkit.getPluginManager().getPlugin("MarriageMaster");
            logger.info("MarryMaster found. Hooked.");
        }
        if (SClans) {
            sc = SimpleClans.getInstance();
            logger.info("SimpleClans found. Hooked.");
        }
        if (Vault) {
            RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
            RegisteredServiceProvider<Chat> rschat = getServer().getServicesManager().getRegistration(Chat.class);
            RegisteredServiceProvider<Permission> rsperm = getServer().getServicesManager().getRegistration(Permission.class);
            // Economy
            if (rsp == null) {
                logger.warning("Vault found Economy, but for some reason cant be used.");
            } else {
                econ = rsp.getProvider();
                logger.info("Vault economy found. Hooked.");
            }
            // Chat
            if (rschat == null) {
                logger.warning("Vault found chat, but for some reason cant be used.");
            } else {
                chat = rschat.getProvider();
                logger.info("Vault chat found. Hooked.");
            }
            // Perms
            if (rsperm == null) {
                logger.warning("Vault found permissions, but for some reason cant be used.");
            } else {
                perms = rsperm.getProvider();
                logger.info("Vault perms found. Hooked.");
            }
        }
        logger.info("Init API module...");
        this.ucapi = new uChatAPI();
        // init other features
        // Jedis
        registerJedis();
        // JDA
        registerJDA();
        initAutomessage();
        getUCLogger().info("Server Version: " + getServer().getBukkitVersion());
        getUCLogger().logClear(ChatColor.translateAlternateColorCodes('&', "\n" + "&b  _    _ _ _   _                 _        _____ _           _  \n" + " | |  | | | | (_)               | |      / ____| |         | |  \n" + " | |  | | | |_ _ _ __ ___   __ _| |_ ___| |    | |__   __ _| |_ \n" + " | |  | | | __| | '_ ` _ \\ / _` | __/ _ \\ |    | '_ \\ / _` | __|\n" + " | |__| | | |_| | | | | | | (_| | ||  __/ |____| | | | (_| | |_ \n" + "  \\____/|_|\\__|_|_| |_| |_|\\__,_|\\__\\___|\\_____|_| |_|\\__,_|\\__|\n" + "                                                                \n" + "&a" + getDescription().getFullName() + " enabled!\n"));
        if (this.UCJDA != null) {
            this.UCJDA.sendRawToDiscord(lang.get("discord.start"));
        }
    } catch (Exception e) {
        e.printStackTrace();
        super.setEnabled(false);
    }
}
Also used : API.uChatAPI(br.net.fabiozumbi12.UltimateChat.Bukkit.API.uChatAPI) UChatBungee(br.net.fabiozumbi12.UltimateChat.Bukkit.Bungee.UChatBungee) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) IOException(java.io.IOException) InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException) Economy(net.milkbowl.vault.economy.Economy) Chat(net.milkbowl.vault.chat.Chat) Permission(net.milkbowl.vault.permission.Permission) UCConfig(br.net.fabiozumbi12.UltimateChat.Bukkit.config.UCConfig) UCLang(br.net.fabiozumbi12.UltimateChat.Bukkit.config.UCLang)

Aggregations

API.uChatAPI (br.net.fabiozumbi12.UltimateChat.Bukkit.API.uChatAPI)1 UChatBungee (br.net.fabiozumbi12.UltimateChat.Bukkit.Bungee.UChatBungee)1 UCConfig (br.net.fabiozumbi12.UltimateChat.Bukkit.config.UCConfig)1 UCLang (br.net.fabiozumbi12.UltimateChat.Bukkit.config.UCLang)1 IOException (java.io.IOException)1 Chat (net.milkbowl.vault.chat.Chat)1 Economy (net.milkbowl.vault.economy.Economy)1 Permission (net.milkbowl.vault.permission.Permission)1 InvalidConfigurationException (org.bukkit.configuration.InvalidConfigurationException)1 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)1