Ejemplo n.º 1
0
        /// <inheritdoc />
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            torchServer = (TorchServer)torch;
            try
            {
                _config = Persistent <SEDBConfig> .Load(Path.Combine(StoragePath, "SEDiscordBridge.cfg"));
            } catch (Exception e)
            {
                Log.Warn(e);
            }
            if (_config?.Data == null)
            {
                _config = new Persistent <SEDBConfig>(Path.Combine(StoragePath, "SEDiscordBridge.cfg"), new SEDBConfig());
            }

            if (Config.BotToken.Length > 0)
            {
                _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
                if (_sessionManager != null)
                {
                    _sessionManager.SessionStateChanged += SessionChanged;
                }
                else
                {
                    Log.Warn("No session manager loaded!");
                }
            }
            else
            {
                Log.Warn("No BOT token set, plugin will not work at all! Add your bot TOKEN, save and restart torch.");
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc cref="Manager.Attach"/>
        public override void Attach()
        {
            base.Attach();

            if (_ctx == null)
            {
                _ctx = _patchManager.AcquireContext();
            }

            Torch.GameStateChanged += Torch_GameStateChanged;
            _sessionManager         = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                LogManager.GetCurrentClassLogger().Warn("No session manager. Player metrics won't work");
            }

            loadTimer           = new System.Timers.Timer(500);
            loadTimer.Elapsed  += LoadTimerElapsed;
            loadTimer.AutoReset = true;
            loadTimer.Start();

            var perfMetricManager = typeof(PerformanceMetricsManager);

            _ctx.GetPattern(_asyncSavingStart).Prefixes.Add(perfMetricManager.GetMethod(nameof(PrefixAsyncSavingStart), BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
            _ctx.GetPattern(_asyncSavingStart).Suffixes.Add(perfMetricManager.GetMethod(nameof(SuffixAsyncSavingStart), BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
            _ctx.GetPattern(_serverBanClient).Suffixes.Add(perfMetricManager.GetMethod(nameof(SuffixBanClient), BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
            _ctx.GetPattern(_spaceRespawnComponentCreateNewIdentity).Suffixes.Add(perfMetricManager.GetMethod(nameof(SuffixCreateNewIdentity), BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
            _patchManager.Commit();

            LogManager.GetCurrentClassLogger().Info("Attached");
        }
        /// <inheritdoc />
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);

            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                Log.Warn("No session manager loaded!");
            }

            var configFile = Path.Combine(StoragePath, ConfigFile);

            try
            {
                _config = Persistent <MarkerConfig> .Load(configFile);
            }
            catch (Exception e)
            {
                Log.Warn(e);
            }

            if (_config?.Data == null)
            {
                _config = new Persistent <MarkerConfig>(configFile, new MarkerConfig());
            }

            LoadConfig();
        }
Ejemplo n.º 4
0
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            Instance = this;
            ChatName = Torch.Config.ChatName;

            Load();

            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }

            /*
             * try
             * {
             *
             *  _config = Persistent<RandomWeatherConfig>.Load(configFile);
             *
             * }
             * catch (Exception e)
             * {
             *  Log.Warn(e);
             * }
             *
             * if (_config?.Data != null) return;
             * Log.Info("Created Default Config, because none was found!");
             *
             * _config = new Persistent<RandomWeatherConfig>(configFile, new RandomWeatherConfig());
             * _config.Save();
             */
        }
Ejemplo n.º 5
0
        public override void Init(ITorchBase torch)
        {
            //Log.Warn("DISCORD INIT YOU F**K");
            base.Init(torch);

            string path = Path.Combine(StoragePath, "DiscordPlugin.cfg");

            _config = Persistent <BotConfig> .Load(path);

            _chatQueue            = new ConcurrentQueue <Message>();
            _relayTimer           = new Timer(100);
            _relayTimer.Elapsed  += RelayTimer_Elapsed;
            _relayTimer.AutoReset = false;
            _relayTimer.Start();

            Instance = this;

            if (Config.Local)
            {
                Provider = new LocalBotProvider();
            }
            else
            {
                throw new NotImplementedException("Centralized bot not implemented yet.");
            }

            Provider.MessageCreated             += _provider_MessageCreated;
            _sessionManager                      = torch.Managers.GetManager <TorchSessionManager>();
            _sessionManager.SessionStateChanged += SessionManagerOnSessionStateChanged;
        }
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);

            var configFile = Path.Combine(StoragePath, "BiggestGridsBroadcast.cfg");

            try {
                _config = Persistent <GridsBroadcastConfig> .Load(configFile);
            } catch (Exception e) {
                Log.Warn(e);
            }

            if (_config?.Data == null)
            {
                Log.Info("Create Default Config, because none was found!");

                _config = new Persistent <GridsBroadcastConfig>(configFile, new GridsBroadcastConfig());
                _config.Save();
            }

            torchSessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (torchSessionManager != null)
            {
                torchSessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                Log.Warn("No session manager loaded!");
            }
        }
Ejemplo n.º 7
0
 public override void Init(ITorchBase torch)
 {
     base.Init(torch);
     SetupConfig();
     Instance       = this;
     SessionManager = Torch.Managers.GetManager <TorchSessionManager>();
     SessionManager.SessionStateChanged += SessionManagerOnSessionStateChanged;
 }
Ejemplo n.º 8
0
 /// <inheritdoc />
 public override void Dispose()
 {
     if (_sessionManager != null)
     {
         _sessionManager.SessionStateChanged -= SessionChanged;
     }
     _sessionManager = null;
 }
Ejemplo n.º 9
0
 public override void Dispose()
 {
     if (SessionManager != null)
     {
         SessionManager.SessionStateChanged -= SessionManagerOnSessionStateChanged;
     }
     SessionManager = null;
 }
Ejemplo n.º 10
0
        public void LoadSEDB()
        {
            ReflectEssentials();
            if (Config.BotToken.Length <= 0)
            {
                Log.Error("No BOT token set, plugin will not work at all! Add your bot TOKEN, save and restart torch.");
                return;
            }

            if (_sessionManager == null)
            {
                _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
                if (_sessionManager == null)
                {
                    Log.Warn("No session manager loaded!");
                }
                else
                {
                    _sessionManager.SessionStateChanged += SessionChanged;
                }
            }

            if (Torch.CurrentSession != null)
            {
                if (_multibase == null)
                {
                    _multibase = Torch.CurrentSession.Managers.GetManager <IMultiplayerManagerBase>();
                    if (_multibase == null)
                    {
                        Log.Warn("No join/leave manager loaded!");
                    }
                    else
                    {
                        _multibase.PlayerJoined += _multibase_PlayerJoined;
                        _multibase.PlayerLeft   += _multibase_PlayerLeft;
                        MyEntities.OnEntityAdd  += MyEntities_OnEntityAdd;
                    }
                }

                if (_chatmanager == null)
                {
                    _chatmanager = Torch.CurrentSession.Managers.GetManager <ChatManagerServer>();
                    if (_chatmanager == null)
                    {
                        Log.Warn("No chat manager loaded!");
                    }
                    else
                    {
                        _chatmanager.MessageRecieved += MessageRecieved;
                    }
                }
                InitPost();
            }
            else if (Config.PreLoad)
            {
                InitPost();
            }
        }
Ejemplo n.º 11
0
 public override void Init(ITorchBase torch)
 {
     base.Init(torch);
     Log.Info("Loading Crunch Koth");
     sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
     if (sessionManager != null)
     {
         sessionManager.SessionStateChanged += SessionChanged;
     }
     SetupConfig();
 }
Ejemplo n.º 12
0
 public override void Init(ITorchBase torch)
 {
     base.Init(torch);
     Log.Info("Loading Space Trucking");
     path = StoragePath;
     SetupConfig();
     sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
     if (sessionManager != null)
     {
         sessionManager.SessionStateChanged += SessionChanged;
     }
 }
Ejemplo n.º 13
0
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            Instance        = this;
            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }

            LoadConfig();
        }
Ejemplo n.º 14
0
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            //Grab Settings
            string path = Path.Combine(StoragePath, "QuantumHangar.cfg");

            _config = Persistent <Settings> .Load(path);

            if (Config.FolderDirectory == null || Config.FolderDirectory == "")
            {
                Config.FolderDirectory = Path.Combine(StoragePath, "QuantumHangar");
            }

            TorchSession = Torch.Managers.GetManager <TorchSessionManager>();
            if (TorchSession != null)
            {
                TorchSession.SessionStateChanged += SessionChanged;
            }


            Tracker = new GridTracker();



            if (Config.GridMarketEnabled)
            {
                Market = new GridMarket(StoragePath);
                Market.InitilizeGridMarket();
            }
            else
            {
                Debug("Starting plugin WITHOUT the Hangar Market!", null, ErrorType.Warn);
            }


            try
            {
            }
            catch (Exception e)
            {
                Log.Info("Unable to load grid market files! " + e);
            }

            EnableDebug = Config.AdvancedDebug;
            Dir         = Config.FolderDirectory;


            PatchManager manager = DependencyProviderExtensions.GetManager <PatchManager>(Torch.Managers);
            Patcher      patcher = new Patcher();

            patcher.Apply(manager.AcquireContext(), this);
            //Load files
        }
Ejemplo n.º 15
0
        /// <inheritdoc />
        public override void Attach()
        {
            base.Attach();

            sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (sessionManager != null)
            {
                sessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                Log.Warn("No session manager loaded!");
            }
        }
        /// <inheritdoc />
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            var configFile = Path.Combine(StoragePath, "DiscordRoleManager.cfg");

            try
            {
                _config = Persistent <RoleConfig> .Load(configFile);
            }
            catch (Exception e)
            {
                Log.Warn(e);
            }

            if (_config?.Data == null)
            {
                _config = new Persistent <RoleConfig>(configFile, new RoleConfig());
            }

            if (Config.BotToken.Length == 0)
            {
                Log.Warn("No BOT token set, plugin will not work at all! Add your bot TOKEN, save and start torch.");
            }

            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                Log.Warn("No session manager loaded!");
            }

            var eventManager = Torch.Managers.GetManager <EventManager>();

            if (eventManager != null)
            {
                eventManager.RegisterHandler(new RoleEventHandler());
            }
            else
            {
                Log.Warn("No event manager loaded!");
            }

            ConnectDiscord();

            Instance = this;
        }
Ejemplo n.º 17
0
        /// <inheritdoc />
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            _config = Persistent <EssentialsConfig> .Load(Path.Combine(StoragePath, "Essentials.cfg"));

            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                Log.Warn("No session manager.  MOTD won't work");
            }
        }
Ejemplo n.º 18
0
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);

            SetupConfig();

            TorchSessionManager torchSessionManager = Torch.Managers.GetManager <TorchSessionManager>();

            if (torchSessionManager != null)
            {
                torchSessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                Log.Warn("No session manager loaded!");
            }
        }
        public override void Attach()
        {
            base.Attach();

            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                _log.Fatal("No session manager. FACTION SYNC DISABLED");
            }

            _wsEnabled = true;
            SetupWebSocket();
        }
Ejemplo n.º 20
0
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);

            // Set static instance.
            Instance = this;

            Log.Info("Loading Torch Economy...");
            // Load up the configuration
            string path = Path.Combine(StoragePath, "Economy.cfg");

            Log.Info($"Attempting to load config from {path}");
            _config = Persistent <EconomyConfig> .Load(path);

            // Build the SQLite dependencies.
            SQLiteInstaller.CheckSQLiteInstalled();

            // Associate Torch containers for lifetime management.
            _sessionManager = Torch.Managers.GetManager(typeof(TorchSessionManager)) as TorchSessionManager;
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;

                // Add mod override for the economy client mod for client enhancements.
                _sessionManager.AddOverrideMod(1772298664);
//                var instanceManager = Torch
//                    .Managers
//                    .GetManager<InstanceManager>();
//
//                instanceManager.
//                    .DedicatedConfig.Mods.Add(new ModItemInfo(new MyObjectBuilder_Checkpoint.ModItem(1772298664)));
            }
            else
            {
                Log.Warn("No session manager.  Economy system won't work.");
            }



            GetConnectionFactory().Setup();
            DefinitionResolver = GetContainer().GetInstance <DefinitionResolver>();

            Torch.GameStateChanged += OnGameStateChanged;
            Log.Info("Torch Economy Initialized!");
        }
Ejemplo n.º 21
0
        /// <inheritdoc />
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            string path = Path.Combine(StoragePath, "Essentials.cfg");

            Log.Info($"Attempting to load config from {path}");
            _config = Persistent <EssentialsConfig> .Load(path);

            _knownIds = new KnownIdsStorage(Path.Combine(StoragePath, "Essentials.KnownSteamIds.txt"));
            _knownIds.Read();
            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                Log.Warn("No session manager.  MOTD won't work");
            }
            homeDataPath = Path.Combine(StoragePath, "players.json");
            if (!File.Exists(homeDataPath))
            {
                File.Create(homeDataPath);
            }



            rankDataPath = Path.Combine(StoragePath, "ranks.json");
            if (!File.Exists(rankDataPath))
            {
                File.Create(rankDataPath);
            }



            Instance = this;
            _pm      = torch.Managers.GetManager <PatchManager>();
            _context = _pm.AcquireContext();
            SessionDownloadPatch.Patch(_context);

            if (Config.CutGameTags)
            {
                GameTagsPatch.Patch(_context);
            }
        }
Ejemplo n.º 22
0
        public override void Attach()
        {
            base.Attach();

            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                Log.Warn("No session manager loaded!");
            }

            if (_ctx == null)
            {
                _ctx = _patchManager.AcquireContext();
            }
        }
Ejemplo n.º 23
0
        /// <inheritdoc />
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            string path = Path.Combine(StoragePath, "Essentials.cfg");

            Log.Info($"Attempting to load config from {path}");
            _config = Persistent <EssentialsConfig> .Load(path);

            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                Log.Warn("No session manager.  MOTD won't work");
            }

            Instance = this;
        }
Ejemplo n.º 24
0
        public override void Attach()
        {
            base.Attach();

            _uplinkManager = Torch.Managers.GetManager <HiveUplink.HiveUplinkManager>();
            if (_uplinkManager == null)
            {
                _log.Fatal("No hive uplink manager. HIVE DISABLED");
            }

            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }
            else
            {
                _log.Fatal("No session manager. FACTION HIVE DISABLED");
            }
        }
        /// <inheritdoc />
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);

            ScriptsPath = Path.Combine(StoragePath, "Scripts");

            _config = Persistent <ScriptManagerConfig> .Load(Path.Combine(StoragePath, "ScriptManager.cfg"));

            ScriptEntry.loadingComplete = true;
            Log.Info("Config has been loaded.");

            Instance = this;

            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += OnSessionStateChanged;
            }

            var patchMgr     = torch.Managers.GetManager <PatchManager>();
            var patchContext = patchMgr.AcquireContext();

            PatchSession(patchContext);
            PatchPB(patchContext);     //apply hooks
            patchMgr.Commit();

            //Your init code here, the game is not initialized at this point.

            Task.Run(delegate
            {
                foreach (var script in _config.Data.Whitelist)
                {
                    string code    = "";
                    code           = script.Code;
                    script.MD5Hash = Util.GetMD5Hash(code);
                }
            });

            MessageHandler.Init();
        }
Ejemplo n.º 26
0
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            Instance = this;
            Config.Instance.Load();
            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            _pm             = torch.Managers.GetManager <PatchManager>();
            _context        = _pm.AcquireContext();
            NexusDetected   = Torch.Managers.GetManager <PluginManager>().Plugins.Keys
                              .Contains(new Guid("28a12184-0422-43ba-a6e6-2e228611cca5"));
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }

            if (NexusDetected)
            {
                Log.Warn("Nexus plugin detected, some features will be disabled");
                return;
            }
            ReputationPatch.Patch(_context);
        }
Ejemplo n.º 27
0
        /// <inheritdoc />
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            string path = Path.Combine(StoragePath, "TebexTorchAPI.cfg");

            Tebex.logInfo($"Attempting to load config from {path}");
            _config = Persistent <TebexConfig> .Load(path);

            _sessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged += SessionChanged;
            }

            System.Net.ServicePointManager.ServerCertificateValidationCallback +=
                (sender, certificate, chain, errors) => { return(true); };

            Torch.GameStateChanged += GameStateChanged;

            this.information = new WebstoreInfo();
            Instance         = this;
        }
Ejemplo n.º 28
0
        /// <inheritdoc />
        public override void Dispose()
        {
            if (_multibase != null)
            {
                _multibase.PlayerJoined -= _multibase_PlayerJoined;
                MyEntities.OnEntityAdd  -= MyEntities_OnEntityAdd;
                _multibase.PlayerLeft   -= _multibase_PlayerLeft;
            }

            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged -= SessionChanged;
            }
            _sessionManager = null;

            if (_chatmanager != null)
            {
                _chatmanager.MessageRecieved -= MessageRecieved;
            }
            _chatmanager = null;

            StopTimer();
        }
Ejemplo n.º 29
0
        /// <inheritdoc cref="Manager.Detach"/>
        public override void Detach()
        {
            base.Detach();

            loadTimer.Stop();
            loadTimer.Dispose();

            Torch.GameStateChanged -= Torch_GameStateChanged;
            if (_sessionManager != null)
            {
                _sessionManager.SessionStateChanged -= SessionChanged;
            }
            _sessionManager = null;
            if (ws != null)
            {
                ws.Stop();
                ws = null;
            }

            _patchManager.FreeContext(_ctx);

            LogManager.GetCurrentClassLogger().Info("Detached");
        }
Ejemplo n.º 30
0
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);
            Instance       = this;
            SessionManager = Torch.Managers.GetManager <TorchSessionManager>();
            SessionManager.SessionStateChanged += SessionManagerOnSessionStateChanged;
            SetupConfig();
            string pathString = System.IO.Path.Combine(StoragePath, "ReferralData");

            System.IO.Directory.CreateDirectory(pathString);
            UserDataPath = Path.Combine(StoragePath + @"\ReferralData", "Users.xml");
            if (!File.Exists(UserDataPath))
            {
                var serializer = new XmlSerializer(typeof(UserData));
                var userData   = new UserData {
                    Users = new ObservableCollection <User>()
                };
                using (var fileWriter = new FileStream(UserDataPath, FileMode.OpenOrCreate, FileAccess.ReadWrite,
                                                       FileShare.ReadWrite))
                {
                    serializer.Serialize(fileWriter, userData);
                }
            }
        }