Ejemplo n.º 1
0
        public void UnloadService(ServiceWrapper wrapper) => StopService(wrapper);        // Unload the service using the wrapper

        public void Init()                                                                // Initializes the service manager
        {
            if (Initialized)                                                              // Don't bother initializing if it already is initialized
            {
                return;
            }
            if (!Directory.Exists(ConfigurationPath))
            {
                Directory.CreateDirectory(ConfigurationPath);                                       // Create the services configuration
            }
            UniServicesData = new UniversalData(PointBlankServer.ConfigurationsPath + "/Services"); // Open the file
            ServicesData    = UniServicesData.GetData(EDataType.JSON) as JsonData;                  // Get the JSON

            foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies().Where(a => Attribute.GetCustomAttribute(a, typeof(PointBlankExtensionAttribute)) != null))
            {
                foreach (Type class_type in asm.GetTypes())
                {
                    LoadService(class_type);
                }
            }
            foreach (PointBlankService ser in _tempServices.OrderBy(a => a.LaunchIndex))
            {
                RunService(ser);
            }
            _tempServices.Clear();

            // Setup the events
            PointBlankPluginEvents.OnPluginLoaded += new PointBlankPluginEvents.PluginEventHandler(OnPluginLoaded);

            // Set the variables
            Initialized = true;
        }
Ejemplo n.º 2
0
        public override void Load()
        {
            // Setup universal configs
            UniSteamGoupConfig = new UniversalData(SteamGroupPath);
            UniPlayerConfig    = new UniversalData(PlayerPath);

            // Setup configs
            SteamGroupConfig = UniSteamGoupConfig.GetData(EDataType.JSON) as JsonData;
            PlayerConfig     = UniPlayerConfig.GetData(EDataType.JSON) as JsonData;

            // Setup events
            ServerEvents.OnPlayerConnected    += new ServerEvents.PlayerConnectionHandler(OnPlayerJoin);
            ServerEvents.OnPlayerDisconnected += new ServerEvents.PlayerConnectionHandler(OnPlayerLeave);

            // Load the configs
            if (!UniSteamGoupConfig.CreatedNew)
            {
                LoadSteamGroups();
            }
            else
            {
                FirstSteamGroups();
            }
            if (UniPlayerConfig.CreatedNew)
            {
                FirstPlayers();
            }
        }
Ejemplo n.º 3
0
        public override void Load()
        {
            if (!Directory.Exists(PointBlankServer.LibrariesPath))
            {
                Directory.CreateDirectory(PointBlankServer.LibrariesPath); // Create libraries directory
            }
            if (!Directory.Exists(PointBlankServer.PluginsPath))
            {
                Directory.CreateDirectory(PointBlankServer.PluginsPath); // Create plugins directory
            }
            if (!Directory.Exists(ConfigurationPath))
            {
                Directory.CreateDirectory(ConfigurationPath); // Create plugins directory
            }
            if (!Directory.Exists(TranslationPath))
            {
                Directory.CreateDirectory(TranslationPath); // Create plugins directory
            }
            // Setup the config
            UniConfig  = new UniversalData(SM.ConfigurationPath + "\\PluginManager");
            JSONConfig = UniConfig.GetData(EDataType.JSON) as JsonData;
            LoadConfig();

            foreach (string library in Directory.GetFiles(PointBlankServer.LibrariesPath, "*.dll")) // Get all the dll files in libraries directory
            {
                _libraries.Add(Assembly.Load(File.ReadAllBytes(library)));                          // Load and add the library
            }
            foreach (string plugin in Directory.GetFiles(PointBlankServer.PluginsPath, "*.dll"))    // Get all the dll files in plugins directory
            {
                try
                {
                    PluginWrapper wrapper = new PluginWrapper(plugin); // Create the plugin wrapper

                    _plugins.Add(wrapper);                             // Add the wrapper
                    if (!wrapper.Load() && !PluginConfiguration.ContinueOnError)
                    {
                        break;
                    }
                }
                catch (Exception ex)
                {
                    PointBlankLogging.LogError("Error initializing plugin!", ex);
                    if (!PluginConfiguration.ContinueOnError)
                    {
                        break;
                    }
                }
            }
            PointBlankPluginEvents.RunPluginsLoaded();
        }
Ejemplo n.º 4
0
        public override void Load()
        {
            // Setup config
            UniGroupConfig = new UniversalData(GroupPath);
            GroupConfig    = UniGroupConfig.GetData(EDataType.JSON) as JsonData;

            if (!UniGroupConfig.CreatedNew)
            {
                LoadGroups();
            }
            else
            {
                FirstGroups();
            }
        }
Ejemplo n.º 5
0
        public PluginWrapper(string pluginPath)
        {
            Location = pluginPath;
            Name     = Path.GetFileNameWithoutExtension(pluginPath);                                 // Get the file name
            Enabled  = false;                                                                        // Set enabled to false

            PluginAssembly = Assembly.Load(File.ReadAllBytes(pluginPath));                           // Load the assembly

            UniConfigurationData = new UniversalData(PluginManager.ConfigurationPath + "\\" + Name); // Load the configuration data
            ConfigurationData    = UniConfigurationData.GetData(EDataType.JSON) as JsonData;         // Get the JSON
            UniTranslationData   = new UniversalData(PluginManager.TranslationPath + "\\" + Name);   // Load the translation data
            TranslationData      = UniTranslationData.GetData(EDataType.JSON) as JsonData;           // Get the JSON

            // Setup the thread
            t = new Thread(new ThreadStart(delegate()
            {
                while (Enabled)
                {
                    if (LastUpdateCheck != null && !((DateTime.Now - LastUpdateCheck).TotalSeconds >=
                                                     PluginConfiguration.CheckUpdateTimeSeconds))
                    {
                        continue;
                    }
                    if (CheckUpdates())
                    {
                        if (PluginConfiguration.NotifyUpdates)
                        {
                            Notify();
                        }
                        if (PluginConfiguration.AutoUpdate)
                        {
                            Update();
                        }
                    }

                    LastUpdateCheck = DateTime.Now;
                }
            }));
        }
Ejemplo n.º 6
0
        public override void Load()
        {
            // Setup variables
            Commands   = new List <CommandWrapper>();
            UniConfig  = new UniversalData(ConfigurationPath);
            JSONConfig = UniConfig.GetData(EDataType.JSON) as JsonData;

            // Setup events
            PointBlankPluginEvents.OnPluginLoaded += new PointBlankPluginEvents.PluginEventHandler(OnPluginLoaded); // Run code every time a plugin is loaded

            // Run the code
            LoadConfig();
            foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies().Where(a => Attribute.GetCustomAttribute(a, typeof(PointBlankExtensionAttribute)) != null))
            {
                foreach (Type tClass in asm.GetTypes())
                {
                    if (tClass.IsClass)
                    {
                        LoadCommand(tClass);
                    }
                }
            }
        }