Пример #1
0
 private void _multibase_PlayerLeft(IPlayer obj)
 {
     //Remove to conecting list
     _conecting.Remove(obj.SteamId);
     if (Config.Leave.Length > 0)
     {
         DDBridge.SendStatusMessage(obj.Name, Config.Leave);
     }
 }
Пример #2
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;
            }
        }
Пример #3
0
        private void SessionChanged(ITorchSession session, TorchSessionState state)
        {
            try
            {
                if (!Config.Enabled)
                {
                    return;
                }

                switch (state)
                {
                case TorchSessionState.Loaded:

                    //load
                    LoadSEDB();
                    if (DDBridge != null)
                    {
                        DDBridge.SendStatusMessage(null, Config.Started);
                    }

                    break;

                case TorchSessionState.Unloaded:

                    //unload
                    timerStart = new DateTime(0);
                    if (Config.Stopped.Length > 0 && DDBridge != null)
                    {
                        DDBridge.SendStatusMessage(null, Config.Stopped);
                    }
                    UnloadSEDB();

                    break;

                default:
                    // ignore
                    break;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "SessionChanged: " + ex.Message);
            }
        }
        private void SessionChanged(ITorchSession session, TorchSessionState state)
        {
            if (!Config.Enabled)
            {
                return;
            }

            switch (state)
            {
            case TorchSessionState.Loaded:

                //load
                LoadSEDB();
                if (DDBridge != null)
                {
                    DDBridge.SendStatusMessage(null, Config.Started);
                }

                break;

            case TorchSessionState.Unloading:
                if (Config.Stopped.Length > 0)
                {
                    DDBridge.SendStatusMessage(null, Config.Stopped);
                }
                break;

            case TorchSessionState.Unloaded:
                //unload
                UnloadSEDB();

                break;

            default:
                // ignore
                break;
            }
        }