How do i handle an event
Basically i want to do a console write when OnBotDisconnected event is fired (this is from MineSharp), from this i am getting Error CS0029 Cannot implicitly convert type void to MineSharp.Bot.Events.BotStringEvent
7 Replies
you can't subscribe to an event with a statement, you have to subscribe by providing a method
the simplest way is to put it in a lambda, like
() => Console.Write("...");
Managed to fix it, turns out the event required more variables in the () for some reason.
Change your code like:
private void BotDisconnected(object sender,Events.BotStringEventArgs e){
Console.Write("Disconnected");}
bot.OnDisconnected+=this.BotDisconnected();
yeah, the event expects a method with a specific signature but i don't know myself since idk what library you're using
you can use a lambda like i showed or a full-on method
its Minesharp https://github.com/psu-de/MineSharp
GitHub
GitHub - psu-de/MineSharp: High-Level async API to build minecraft ...
High-Level async API to build minecraft bots. Contribute to psu-de/MineSharp development by creating an account on GitHub.
probably shouldn't have said so 😬
Minecraft modding is notably explicitly allowed by Mojang/Microsoft
there are some limits around griefing servers, but the modding itself is fine