# plugin_lifecycle
## Overview
MudBringer plugins can tap into various session lifecycle events. These are virtual methods on the `MudPlugin` base class that you can override to respond to state changes.
## Available Hooks
- **Initialize()**: Called once when the plugin is loaded via `/loadlib`.
- **OnConnected()**: Called immediately after the session establishes a TCP connection to the MUD server.
- **OnDisconnected()**: Called immediately when the session loses connection or is `/zap`ped.
- **OnProfileLoaded()**: Called when a new profile or script file is completely parsed and loaded.
## Examples:
```csharp
public override void OnConnected()
{
    Client.ExecuteClientCommand("/echo [Plugin] Connection established. Starting sync...");
    Client.ExecuteClientCommand("sync"); // Sent to server
}
```
