Base Extension

Base extensions for the Bot Viewer get called as soon as the user connects to the bot's server.


[Plugin(1, "Bot Viewer Extension Plugin", "Test plugin to showcase bot viewer possible extensions.")]
public class PluginCore : IStartPlugin
    public override void OnLoad(int version, int subversion, int buildversion) { }
    public override PluginResponse OnEnable(IBotSettings botSettings) { return base.OnEnable(botSettings); }

public class ExampleHandler : IBotServerHandler {
    public override async Task OnConnected() {
        // This function is called once a user connects to the bot's proxy server.

        this.Events.FromClient.ChatMessage += (message, token) => {
            // Catch all messages from the client that start with a # symbol.
            if (message.StartsWith("#")) {

                // servers have to respond in a json format, e.g.
                this.Client.SendChat("{\"text\":\"Test plugin received '"+message+"' message from you.\", \"bold\":true}"); 
                token.Cancel(); // Do not forward it to the server game server.

        this.Events.ToClient.AddVelocityToEntity += (entityId, modifiers, token) => {
            // Disable all velocity data being sent from the server (no knockback).
            if(entityId == Context.Player.GetEntityId())


As can be seen from the example code, there are two types of bot viewer based events: FromClient, which are events that get triggered by the client attempting to send data to the server, and ToClient, which are events that get triggered when the server is attempting to send data to the client.

Each of these events can be cancelled, which means it would never reach the desired destination (e.g.: cancel a ChatMessage event so a chat message is never actually sent to the server). This can be done by calling the token.Cancel() function, where the token variable is a pararemeter of each event.

Sending Data to Client

Data can be sent to the client through the Client variable, which should be accessed in the following way: this.Client, as can be seen in the example code. This class has functions that allow you to send data to the client, such as SendChat, which would send a chat message to che connected client.

To send data to the server you can still use the Context variable, which is heavilly documented in the API section of the docs.

Last updated