Search in sources :

Example 1 with RedProtectUtil

use of br.net.fabiozumbi12.RedProtect.Sponge.helpers.RedProtectUtil in project RedProtect by FabioZumbi12.

the class RedProtect method startLoad.

private void startLoad() throws Exception {
    redProtectUtil = new RedProtectUtil(this);
    config = new ConfigManager();
    lang = new LangManager();
    blockConfig = new BlockConfig();
    if (config.configRoot().purge.regen.enable_whitelist_regen && Bukkit.getServer().hasWhitelist()) {
        Bukkit.getServer().setWhitelist(false);
        RedProtect.get().logger.success("Whitelist disabled!");
    }
    logger.info("Registering commands...");
    cmdHandler = new CommandHandler(this);
    logger.info("Registering listeners...");
    getServer().getPluginManager().registerEvents(cmdHandler, this);
    getServer().getPluginManager().registerEvents(new GlobalListener(), this);
    getServer().getPluginManager().registerEvents(new BlockListener(), this);
    getServer().getPluginManager().registerEvents(new PlayerListener(), this);
    getServer().getPluginManager().registerEvents(new EntityListener(), this);
    getServer().getPluginManager().registerEvents(new WorldListener(), this);
    // Register hooks
    hooks.registerHooksFirst();
    rm = new RegionManager();
    rm.loadAll();
    redProtectUtil.ReadAllDB(rm.getAllRegions());
    rm.saveAll(false);
    if (!config.configRoot().file_type.equalsIgnoreCase("mysql")) {
        startAutoSave();
    }
    logger.info("There are " + rm.getTotalRegionsNum() + " regions on (" + config.configRoot().file_type + ") database!");
    // Register hooks
    hooks.registerHooksLast();
    // Load Gui lang file
    guiLang = new LangGuiManager();
    // Update Manager
    if (updater != null) {
        Bukkit.getScheduler().cancelTask(updater.getTaskId());
        updater = null;
    }
    if (config.configRoot().update.enable) {
        updater = new SpigetUpdater(this);
        updater.setCurrentJarFile(this.getFile().getName());
        updater.hourlyUpdateCheck(getServer().getConsoleSender(), config.configRoot().update.enable, false);
    }
    bukkitVersion = getBukkitVersion();
    logger.debug(LogLevel.DEFAULT, "Version String: " + bukkitVersion);
    if (bukkitVersion >= 180) {
        getServer().getPluginManager().registerEvents(new Compat18(), this);
    }
    if (bukkitVersion >= 190) {
        getServer().getPluginManager().registerEvents(new Compat19(), this);
    }
    if (bukkitVersion >= 1110) {
        getServer().getPluginManager().registerEvents(new Compat111(), this);
    }
    if (bukkitVersion >= 1140) {
        getServer().getPluginManager().registerEvents(new Compat114(), this);
    }
    if (bukkitVersion <= 189) {
        rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Bukkit.helpers.VersionHelper18").newInstance();
    }
    if (bukkitVersion >= 190) {
        rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Bukkit.helpers.VersionHelper112").newInstance();
    }
    if (bukkitVersion >= 1130) {
        rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Bukkit.helpers.VersionHelper113").newInstance();
    }
    if (bukkitVersion >= 1140) {
        rpvHelper = (VersionHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Bukkit.helpers.VersionHelperLatest").newInstance();
    }
    // Register as listener
    getServer().getPluginManager().registerEvents(rpvHelper, this);
    // Print helper version
    logger.info("Helper version: " + rpvHelper.getVersion());
    // Load gui items for Minecraft version
    config.setGuiRoot(rpvHelper.setGuiItems(config.guiRoot()));
    // Load mob permissions
    modListener = new ModListener(this);
    // Metrics
    try {
        Metrics metrics = new Metrics(this);
        metrics.addCustomChart(new Metrics.SingleLineChart("server_regions", () -> rm.getAllRegions().size()));
        if (metrics.isEnabled())
            logger.info("Metrics enabled! See our stats here: https://bstats.org/plugin/bukkit/RedProtect");
    } catch (Exception ex) {
        logger.info("Metrics not enabled due errors: " + ex.getLocalizedMessage());
    }
}
Also used : LangManager(br.net.fabiozumbi12.RedProtect.Bukkit.config.LangManager) CommandHandler(br.net.fabiozumbi12.RedProtect.Bukkit.commands.CommandHandler) SpigetUpdater(br.net.fabiozumbi12.RedProtect.Bukkit.updater.SpigetUpdater) ConfigManager(br.net.fabiozumbi12.RedProtect.Bukkit.config.ConfigManager) ObjectMappingException(ninja.leaping.configurate.objectmapping.ObjectMappingException) RedProtectUtil(br.net.fabiozumbi12.RedProtect.Bukkit.helpers.RedProtectUtil) Metrics(br.net.fabiozumbi12.RedProtect.Bukkit.metrics.Metrics) LangGuiManager(br.net.fabiozumbi12.RedProtect.Bukkit.config.LangGuiManager) RegionManager(br.net.fabiozumbi12.RedProtect.Bukkit.region.RegionManager) BlockConfig(br.net.fabiozumbi12.RedProtect.Bukkit.config.BlockConfig)

Example 2 with RedProtectUtil

use of br.net.fabiozumbi12.RedProtect.Sponge.helpers.RedProtectUtil in project RedProtect by FabioZumbi12.

the class RedProtect method startLoad.

private void startLoad() throws Exception {
    redProtectUtil = new RedProtectUtil();
    config = new ConfigManager(this.factory);
    lang = new LangManager();
    if (RedProtect.get().getConfigManager().configRoot().purge.regen.enable_whitelist_regen && Sponge.getServer().hasWhitelist()) {
        Sponge.getServer().setHasWhitelist(false);
        RedProtect.get().logger.success("Whitelist disabled!");
    }
    logger.info("Registering commands...");
    commandHandler = new CommandHandler(this);
    logger.info("Registering listeners...");
    Sponge.getGame().getEventManager().registerListeners(container, commandHandler);
    Sponge.getGame().getEventManager().registerListeners(container, new BlockListener());
    Sponge.getGame().getEventManager().registerListeners(container, new GlobalListener());
    Sponge.getGame().getEventManager().registerListeners(container, new PlayerListener());
    Sponge.getGame().getEventManager().registerListeners(container, new EntityListener());
    Sponge.getGame().getEventManager().registerListeners(container, new WorldListener());
    // Register hooks
    this.hooks.registerHooksFirst();
    rm = new RegionManager();
    rm.loadAll();
    RedProtect.get().getUtil().ReadAllDB(rm.getAllRegions());
    rm.saveAll(false);
    if (!config.configRoot().file_type.equalsIgnoreCase("mysql")) {
        AutoSaveHandler();
    }
    logger.info("There are " + rm.getTotalRegionsNum() + " regions on (" + config.configRoot().file_type + ") database!");
    // Register hooks
    this.hooks.registerHooksLast();
    // Load Gui lang file
    guiLang = new LangGuiManager();
}
Also used : RedProtectUtil(br.net.fabiozumbi12.RedProtect.Sponge.helpers.RedProtectUtil) LangManager(br.net.fabiozumbi12.RedProtect.Sponge.config.LangManager) LangGuiManager(br.net.fabiozumbi12.RedProtect.Sponge.config.LangGuiManager) RegionManager(br.net.fabiozumbi12.RedProtect.Sponge.region.RegionManager) CommandHandler(br.net.fabiozumbi12.RedProtect.Sponge.commands.CommandHandler) ConfigManager(br.net.fabiozumbi12.RedProtect.Sponge.config.ConfigManager)

Aggregations

CommandHandler (br.net.fabiozumbi12.RedProtect.Bukkit.commands.CommandHandler)1 BlockConfig (br.net.fabiozumbi12.RedProtect.Bukkit.config.BlockConfig)1 ConfigManager (br.net.fabiozumbi12.RedProtect.Bukkit.config.ConfigManager)1 LangGuiManager (br.net.fabiozumbi12.RedProtect.Bukkit.config.LangGuiManager)1 LangManager (br.net.fabiozumbi12.RedProtect.Bukkit.config.LangManager)1 RedProtectUtil (br.net.fabiozumbi12.RedProtect.Bukkit.helpers.RedProtectUtil)1 Metrics (br.net.fabiozumbi12.RedProtect.Bukkit.metrics.Metrics)1 RegionManager (br.net.fabiozumbi12.RedProtect.Bukkit.region.RegionManager)1 SpigetUpdater (br.net.fabiozumbi12.RedProtect.Bukkit.updater.SpigetUpdater)1 CommandHandler (br.net.fabiozumbi12.RedProtect.Sponge.commands.CommandHandler)1 ConfigManager (br.net.fabiozumbi12.RedProtect.Sponge.config.ConfigManager)1 LangGuiManager (br.net.fabiozumbi12.RedProtect.Sponge.config.LangGuiManager)1 LangManager (br.net.fabiozumbi12.RedProtect.Sponge.config.LangManager)1 RedProtectUtil (br.net.fabiozumbi12.RedProtect.Sponge.helpers.RedProtectUtil)1 RegionManager (br.net.fabiozumbi12.RedProtect.Sponge.region.RegionManager)1 ObjectMappingException (ninja.leaping.configurate.objectmapping.ObjectMappingException)1