Пример #1
0
        private void SessionChanged(ITorchSession session, TorchSessionState state)
        {
            switch (state)
            {
            case TorchSessionState.Loaded:
                _multibase = Torch.CurrentSession.Managers.GetManager <IMultiplayerManagerBase>();
                if (_multibase != null)
                {
                    _multibase.PlayerJoined += _multibase_PlayerJoined;
                    MyEntities.OnEntityAdd  += MyEntities_OnEntityAdd;
                    _multibase.PlayerLeft   += _multibase_PlayerLeft;
                }
                else
                {
                    Log.Warn("No join/leave manager loaded!");
                }

                _chatmanager = Torch.CurrentSession.Managers.GetManager <ChatManagerServer>();
                if (_chatmanager != null)
                {
                    _chatmanager.MessageRecieved += MessageRecieved;
                }

                else
                {
                    Log.Warn("No chat manager loaded!");
                }

                Log.Warn("Starting Discord Bridge!");

                DDBridge = new DiscordBridge(this);

                //send status
                if (Config.UseStatus)
                {
                    StartTimer();
                }

                break;

            case TorchSessionState.Unloading:
                if (DDBridge != null)
                {
                    if (Config.Stopped.Length > 0)
                    {
                        DDBridge.SendStatusMessage(null, Config.Stopped);
                    }
                    DDBridge.Stopdiscord();
                }
                Log.Warn("Discord Bridge Unloaded!");

                Dispose();
                break;

            default:
                // ignore
                break;
            }
        }
 public void UnloadSEDB()
 {
     if (DDBridge != null)
     {
         Log.Info("Unloading Discord Bridge!");
         DDBridge.Stopdiscord();
         DDBridge = null;
         Log.Info("Discord Bridge Unloaded!");
     }
     Dispose();
 }
Пример #3
0
 public void UnloadSEDB()
 {
     try
     {
         if (DDBridge != null)
         {
             Log.Info("Unloading Discord Bridge!");
             DDBridge.Stopdiscord();
             DDBridge = null;
             Log.Info("Discord Bridge Unloaded!");
         }
         Dispose();
     } catch (Exception ex)
     {
         Log.Error(ex, "UnloadSEDB: " + ex.Message);
     }
 }