Search in sources :

Example 1 with UCConfig

use of br.net.fabiozumbi12.UltimateChat.Bukkit.config.UCConfig in project UltimateChat by FabioZumbi12.

the class UChat method onServerStart.

@Listener
public void onServerStart(GamePostInitializationEvent event) {
    try {
        uchat = this;
        this.serv = Sponge.getServer();
        // init logger
        this.logger = new UCLogger(this.serv);
        // init config
        this.config = new UCConfig(this.factory);
        // init lang
        this.lang = new UCLang();
        // set compat perms
        this.setCompatperms();
        logger.info("Init commands module...");
        this.cmds = new UCCommands(this);
        game.getEventManager().registerListeners(plugin, new UCListener());
        // init other features
        // Jedis
        registerJedis();
        // JDA
        registerJDA();
        logger.info("Init API module...");
        this.ucapi = new uChatAPI();
        // register placeholdersapi
        if (Sponge.getPluginManager().getPlugin("placeholderapi").isPresent()) {
            new UCPlaceHoldersRelational(this);
        }
        getLogger().logClear("\n" + "&b  _    _ _ _   _                 _        _____ _           _  \n" + " | |  | | | | (_)               | |      / ____| |         | |  \n" + " | |  | | | |_ _ _ __ ___   __ _| |_ ___| |    | |__   __ _| |_ \n" + " | |  | | | __| | '_ ` _ \\ / _` | __/ _ \\ |    | '_ \\ / _` | __|\n" + " | |__| | | |_| | | | | | | (_| | ||  __/ |____| | | | (_| | |_ \n" + "  \\____/|_|\\__|_|_| |_| |_|\\__,_|\\__\\___|\\_____|_| |_|\\__,_|\\__|\n" + "                                                                \n" + "&a" + plugin.getName() + " " + plugin.getVersion().get() + " enabled!\n");
        if (this.UCJDA != null) {
            this.UCJDA.sendRawToDiscord(lang.get("discord.start"));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : API.uChatAPI(br.net.fabiozumbi12.UltimateChat.Sponge.API.uChatAPI) UCConfig(br.net.fabiozumbi12.UltimateChat.Sponge.config.UCConfig) UCLang(br.net.fabiozumbi12.UltimateChat.Sponge.config.UCLang) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Listener(org.spongepowered.api.event.Listener)

Example 2 with UCConfig

use of br.net.fabiozumbi12.UltimateChat.Bukkit.config.UCConfig in project UltimateChat by FabioZumbi12.

the class UChat method reload.

public void reload() {
    this.getServer().getScheduler().cancelTasks(this);
    try {
        this.config = new UCConfig(this);
    } catch (IOException e) {
        e.printStackTrace();
    }
    this.lang = new UCLang();
    this.registerAliases();
    this.registerJDA();
    this.registerJedis();
    this.initAutomessage();
    // ping other plugins when uchat reload
    UChatReloadEvent reloadEvent = new UChatReloadEvent();
    Bukkit.getPluginManager().callEvent(reloadEvent);
}
Also used : UCConfig(br.net.fabiozumbi12.UltimateChat.Bukkit.config.UCConfig) IOException(java.io.IOException) UCLang(br.net.fabiozumbi12.UltimateChat.Bukkit.config.UCLang) UChatReloadEvent(br.net.fabiozumbi12.UltimateChat.Bukkit.API.UChatReloadEvent)

Example 3 with UCConfig

use of br.net.fabiozumbi12.UltimateChat.Bukkit.config.UCConfig 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)

Example 4 with UCConfig

use of br.net.fabiozumbi12.UltimateChat.Bukkit.config.UCConfig in project UltimateChat by FabioZumbi12.

the class UChat method reload.

public void reload() throws IOException {
    this.cmds.removeCmds();
    this.channels = null;
    this.config = new UCConfig(factory);
    this.lang = new UCLang();
    try {
        setCompatperms();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    this.cmds = new UCCommands(this);
    registerJedis();
    registerJDA();
    // fire event
    UChatReloadEvent event = new UChatReloadEvent();
    Sponge.getEventManager().post(event);
}
Also used : UCConfig(br.net.fabiozumbi12.UltimateChat.Sponge.config.UCConfig) UCLang(br.net.fabiozumbi12.UltimateChat.Sponge.config.UCLang) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UChatReloadEvent(br.net.fabiozumbi12.UltimateChat.Sponge.API.UChatReloadEvent)

Aggregations

IOException (java.io.IOException)4 UCConfig (br.net.fabiozumbi12.UltimateChat.Bukkit.config.UCConfig)2 UCLang (br.net.fabiozumbi12.UltimateChat.Bukkit.config.UCLang)2 UCConfig (br.net.fabiozumbi12.UltimateChat.Sponge.config.UCConfig)2 UCLang (br.net.fabiozumbi12.UltimateChat.Sponge.config.UCLang)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 UChatReloadEvent (br.net.fabiozumbi12.UltimateChat.Bukkit.API.UChatReloadEvent)1 API.uChatAPI (br.net.fabiozumbi12.UltimateChat.Bukkit.API.uChatAPI)1 UChatBungee (br.net.fabiozumbi12.UltimateChat.Bukkit.Bungee.UChatBungee)1 UChatReloadEvent (br.net.fabiozumbi12.UltimateChat.Sponge.API.UChatReloadEvent)1 API.uChatAPI (br.net.fabiozumbi12.UltimateChat.Sponge.API.uChatAPI)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 Listener (org.spongepowered.api.event.Listener)1