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. https://minecraft.tools/en/json_text.php
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())
token.Cancel();
};
}
}
Events
Sending Data to Client
Last updated