/// <summary> /// Called when the server exits /// </summary> /// <param name="console">The server GUI - provides access to the underlying server process</param> public void OnExit(IServerConsole console) { foreach (IPlugin plugin in Enabled) { try { plugin.OnExit(console); } catch (Exception ex) { console.DisplayLine($"Error in method OnExit for plugin {plugin.Name}: {ex}", red); } } }
/// <summary> /// Called when a player disconnects from the server /// </summary> /// <param name="console">The server GUI - provides access to the underlying server process</param> /// <param name="message">The disconnection message</param> public void OnPlayerDisconnect(IServerConsole console, ServerConnectionMessage message) { foreach (IPlugin plugin in Enabled) { try { plugin.OnPlayerDisconnect(console, message); } catch (Exception ex) { console.DisplayLine($"Error in method OnPlayerDisconnect for plugin {plugin.Name}: {ex}", red); } } }
private async void PostWebhookMessage(DiscordWebhookMessage message, IServerConsole console) { if (config.WebhookUrl == null) { return; } try { await client.PostAsync(config.WebhookUrl, new StringContent(message.ToString(), Encoding.UTF8, "application/json")); } catch (Exception ex) { console.DisplayLine($"[Discord Webhook] Error sending webhook message: {ex}", Color.Red); } }