Search in sources :

Example 1 with RPCommands

use of br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPCommands in project RedProtect by FabioZumbi12.

the class RedProtect method onEnable.

public void onEnable() {
    try {
        plugin = this;
        BossBar = checkBM();
        MyChunk = checkMyChunk();
        MyPet = checkMyPet();
        McMMo = checkMcMMo();
        Mc = checkMc();
        Vault = checkVault();
        SkillAPI = checkSkillAPI();
        PvPm = checkPvPm();
        Ess = checkEss();
        GP = checkGP();
        Dyn = checkDyn();
        WE = checkWe();
        AWE = checkAWe();
        SC = checkSP();
        Fac = checkFac();
        PLib = checkPLib();
        PlaceHolderAPI = checkPHAPI();
        JarFile = this.getFile();
        initVars();
        RPConfig.init();
        RPLang.init();
        rm.loadAll();
        OnlineMode = serv.getOnlineMode();
        serv.getPluginManager().registerEvents(new RPGlobalListener(), this);
        serv.getPluginManager().registerEvents(new RPBlockListener(), this);
        serv.getPluginManager().registerEvents(new RPPlayerListener(), this);
        serv.getPluginManager().registerEvents(new RPEntityListener(), this);
        serv.getPluginManager().registerEvents(new RPWorldListener(), this);
        serv.getPluginManager().registerEvents(new RPAddProtection(), this);
        version = getBukkitVersion();
        logger.debug("Version String: " + version);
        if (version >= 180) {
            serv.getPluginManager().registerEvents(new RPMine18(), this);
        }
        if (version >= 190) {
            serv.getPluginManager().registerEvents(new RPMine19(), this);
        }
        getCommand("RedProtect").setExecutor(new RPCommands());
        if (Vault) {
            RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
            if (rsp == null) {
                logger.warning("Vault found, but for some reason cant be used with RedProtect.");
                Vault = false;
            } else {
                econ = rsp.getProvider();
                logger.info("Vault found. Hooked.");
            }
        }
        if (PLib) {
            logger.info("ProtocolLib found. Hidding Gui Flag item stats.");
        }
        if (PvPm) {
            logger.info("PvPManager found. Hooked.");
        }
        if (Ess) {
            pless = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
            logger.info("Essentials found. Hooked.");
        }
        if (WE) {
            logger.info("WorldEdit found. Hooked.");
        }
        if (AWE) {
            logger.info("AsyncWorldEdit found. Hooked.");
        }
        if (BossBar) {
            logger.info("BossbarAPI found. Hooked.");
        }
        if (MyPet) {
            serv.getPluginManager().registerEvents(new MPListener(), this);
            logger.info("MyPet found. Hooked.");
        }
        if (McMMo) {
            serv.getPluginManager().registerEvents(new McMMoListener(), this);
            logger.info("McMMo found. Hooked.");
        }
        if (SkillAPI) {
            serv.getPluginManager().registerEvents(new SkillAPIListener(), this);
            logger.info("SkillAPI found. Hooked.");
        }
        if (MyChunk) {
            logger.sucess("MyChunk found. Ready to convert!");
            logger.warning("Use '/rp mychunkconvert' to start MyChunk conversion (This may cause lag during conversion)");
        }
        if (Mc) {
            logger.info("MagicCarpet found. Hooked.");
        }
        if (SC) {
            clanManager = SimpleClans.getInstance().getClanManager();
            logger.info("SimpleClans found. Hooked.");
        }
        if (Dyn && RPConfig.getBool("hooks.dynmap.enable")) {
            logger.info("Dynmap found. Hooked.");
            logger.info("Loading dynmap markers...");
            dynmap = new RPDynmap((DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap"));
            logger.info("Dynmap markers loaded!");
        }
        if (PlaceHolderAPI) {
            new RPPlaceHoldersAPI(this).hook();
            logger.info("PlaceHolderAPI found. Hooked and registered some chat placeholders.");
        }
        if (Fac) {
            serv.getPluginManager().registerEvents(new RPFactions(), this);
            logger.info("Factions found. Hooked.");
        }
        if (!RPConfig.getString("file-type").equalsIgnoreCase("mysql")) {
            RPUtil.ReadAllDB(rm.getAllRegions());
        } else {
            logger.info("Theres " + rm.getTotalRegionsNum() + " regions on (" + RPConfig.getString("file-type") + ") database!");
        }
        logger.info("Loading API...");
        this.rpAPI = new RedProtectAPI();
        logger.info("API Loaded!");
        logger.clear("&4 _   _  _  &c _   _   _  _ _  _  _ _ _  __");
        logger.clear("&4|_| |_ | \\ &c|_| |_| | |  |  |_ |   |    /");
        logger.clear("&4| \\ |_ |_/ &c|   | \\ |_|  |  |_ |_  |   /");
        logger.clear("&a¯ " + pdf.getFullName() + " enabled");
        logger.clear("");
        if (RPConfig.getBool("update-check.enable")) {
            logger.info("Checking for update...");
            if (CheckUpdate()) {
                logger.sucess("Update available! Use /rp update to download.");
            } else {
                logger.info("No update available.");
            }
        }
        if (RPConfig.getString("file-type").equals("yml")) {
            AutoSaveHandler();
        }
    } catch (Exception e) {
        e.printStackTrace();
        if (!RPConfig.getString("file-type").equalsIgnoreCase("mysql")) {
            logger.severe("Error enabling RedProtect, plugin will shut down.");
            this.disable();
        }
    }
}
Also used : RPPlayerListener(br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPPlayerListener) RPWorldListener(br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPWorldListener) DynmapAPI(org.dynmap.DynmapAPI) RPGlobalListener(br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPGlobalListener) RPAddProtection(br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPAddProtection) MPListener(br.net.fabiozumbi12.RedProtect.Bukkit.hooks.MPListener) RPMine19(br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPMine19) RPMine18(br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPMine18) SkillAPIListener(br.net.fabiozumbi12.RedProtect.Bukkit.hooks.SkillAPIListener) RPFactions(br.net.fabiozumbi12.RedProtect.Bukkit.hooks.RPFactions) RPBlockListener(br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPBlockListener) McMMoListener(br.net.fabiozumbi12.RedProtect.Bukkit.hooks.McMMoListener) Economy(net.milkbowl.vault.economy.Economy) RPEntityListener(br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPEntityListener) RedProtectAPI(br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI) RPPlaceHoldersAPI(br.net.fabiozumbi12.RedProtect.Bukkit.hooks.RPPlaceHoldersAPI) RPDynmap(br.net.fabiozumbi12.RedProtect.Bukkit.hooks.RPDynmap) RPCommands(br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPCommands)

Example 2 with RPCommands

use of br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPCommands in project RedProtect by FabioZumbi12.

the class RedProtect method onServerStart.

@Listener
public void onServerStart(GameStartedServerEvent event) {
    try {
        String v = Sponge.getGame().getPlatform().getContainer(Component.API).getVersion().get();
        instance = this;
        if (v.startsWith("5") || v.startsWith("6")) {
            pvhelp = (RPVHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.RPVHelper56").newInstance();
        }
        if (v.startsWith("7")) {
            pvhelp = (RPVHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.RPVHelper7").newInstance();
        }
        initVars();
        OnlineMode = serv.getOnlineMode();
        cmdService.register(container, new RPCommands(), Arrays.asList("redprotect", "rp", "regionp", "regp"));
        game.getEventManager().registerListeners(container, new RPGlobalListener());
        game.getEventManager().registerListeners(container, new RPBlockListener());
        game.getEventManager().registerListeners(container, new RPPlayerListener());
        game.getEventManager().registerListeners(container, new RPEntityListener());
        game.getEventManager().registerListeners(container, new RPWorldListener());
        game.getEventManager().registerListeners(container, new RPMine18());
        game.getEventManager().registerListeners(container, new RPAddProtection());
        loadRegions();
        logger.info("Loading API...");
        this.rpAPI = new RedProtectAPI();
        logger.info("API Loaded!");
        logger.clear("&4 _   _  _  &c _   _   _  _ _  _  _ _ _  __");
        logger.clear("&4|_| |_ | \\ &c|_| |_| | |  |  |_ |   |    / ");
        logger.clear("&4| \\ |_ |_/ &c|   | \\ |_|  |  |_ |_  |   /");
        logger.clear("&a¯ Redprotect " + container.getVersion().get() + " enabled");
        logger.clear("");
    } catch (Exception e) {
        e.printStackTrace();
        logger.severe("Error enabling RedProtect, plugin will shut down.");
    }
}
Also used : RPBlockListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener) RPPlayerListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPPlayerListener) RPWorldListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPWorldListener) RPEntityListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPEntityListener) RedProtectAPI(br.net.fabiozumbi12.RedProtect.Sponge.API.RedProtectAPI) RPGlobalListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPGlobalListener) RPAddProtection(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPAddProtection) RPMine18(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPMine18) RPCommands(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPCommands) RPGlobalListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPGlobalListener) RPWorldListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPWorldListener) RPEntityListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPEntityListener) RPBlockListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener) RPPlayerListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPPlayerListener) Listener(org.spongepowered.api.event.Listener)

Aggregations

RedProtectAPI (br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI)1 MPListener (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.MPListener)1 McMMoListener (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.McMMoListener)1 RPDynmap (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.RPDynmap)1 RPFactions (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.RPFactions)1 RPPlaceHoldersAPI (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.RPPlaceHoldersAPI)1 SkillAPIListener (br.net.fabiozumbi12.RedProtect.Bukkit.hooks.SkillAPIListener)1 RPAddProtection (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPAddProtection)1 RPBlockListener (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPBlockListener)1 RPCommands (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPCommands)1 RPEntityListener (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPEntityListener)1 RPGlobalListener (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPGlobalListener)1 RPMine18 (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPMine18)1 RPMine19 (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPMine19)1 RPPlayerListener (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPPlayerListener)1 RPWorldListener (br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPWorldListener)1 RedProtectAPI (br.net.fabiozumbi12.RedProtect.Sponge.API.RedProtectAPI)1 RPAddProtection (br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPAddProtection)1 RPBlockListener (br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener)1 RPCommands (br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPCommands)1