示例#1
0
 public async Task HandleEventAsync(object?sender, UnturnedPlayerConnectedEvent @event)
 {
     foreach (var section in m_Configuration.GetSection("motd").GetChildren().ToList())
     {
         var text   = section.GetValue <string>("text");
         var colour = section.GetValue <string>("colour");
         await @event.Player.PrintMessageAsync(m_Filler.FillMessage(text), ColorTranslator.FromHtml(colour));
     }
 }
示例#2
0
        private async UniTask Annoyer()
        {
            while (true)
            {
                for (int i = 0; i < m_Configuration.GetSection("broadcasts").GetChildren().ToList().Count; i++)
                {
                    var text      = m_Configuration.GetSection("broadcasts").GetChildren().ToList()[i].GetValue <string>("text");
                    var colour    = m_Configuration.GetSection("broadcasts").GetChildren().ToList()[i].GetValue <string>("colour");
                    var image_url = m_Configuration.GetSection("broadcasts").GetChildren().ToList()[i].GetValue <string>("image_url");
                    m_CancellationTokenSource.Token.ThrowIfCancellationRequested();
                    if (Level.isLoaded)
                    {
                        await UniTask.SwitchToMainThread();

                        ChatManager.serverSendMessage(m_Filler.FillMessage(text), ColorTranslator.FromHtml(colour).ToUnityColor(), null, null, EChatMode.SAY, image_url, true);
                        await UniTask.SwitchToThreadPool();
                    }
                    await Task.Delay(m_Configuration.GetValue <int>("seconds_between_messages") * 1000);
                }
            }
        }