Sneyk / LibClassicBot

A bot for Minecraft Classic, written in C#.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LibClassicBot

LibClassicBot consists of two main projects:

  • LibClassicBot: A base library to connect to Classic Servers.
  • ClassicBotCoreTests: An implementation of LibClassicBot with a number of commands supported.

LibClassicBot is known to run well on .NET Framework 2.0 with the Microsoft Compiler. Mono has not been tested as of yet. LibClassicBot is further divided into two namespaces:

  • LibClassicBot: A base library to connect to Classic Servers.
  • LibClassicBot.Networking: Contains enumerations with the packet IDs of both Server and Client packets. Also contains the static class Packets, which can be used to create packets that can be sent via ClassicBot.Send(byte []).
  • LibClassicBot.Events: Events that are raised by the bot, such as socket errors and chat messages.
  • LibClassicBot.Remote: Contains classes and events for creating a server that remote clients are able to connect to. The remote protocol used also has the option of sending log files across.

Features

LibClassicBot is incomplete. Work on further additions are currently at a standstill due to schoolwork. However, I decided that I might as well release the source code of the bot as it currently stands.

Some things about LibClassicBot that are already implemented:

  • Plugins: Plugins are designed to be easy to implement, although at the moment they can only be added internally. I intend to add the ability to load .dll plugins later.
  • Permissions: The bot is designed to use a simple permissions system - Operators who are allowed to use the bot, and those who are not.

Usage

LibClassicBot is a library, and will not perform as a bot on its own. You can implement the library yourself, or you can modify the existing ClassicBotCoreTest. To get started, the following code will create a bot that connects to a locally hosted server on port 25565, and create a command that is triggered when someone types .test and is on the operators list.:

using System;
using System.Net;
using LibClassicBot;
using LibClassicBot.Events;

namespace LibClassicBotTest
{
	class Program
	{
		public static void Main(string[] args)
		{
			ClassicBot Bot1 = new ClassicBot("Bot",IPAddress.Loopback,25565,"operators.txt");	
			ClassicBot.CommandDelegate TestCommand = delegate(string Line)
			{
				Bot1.SendMessagePacket("Test.");
			};
			Bot1.RegisteredCommands.Add("test",TestCommand);
			Bot1.Start(false);
			Bot1.Events.ChatMessage += ChatMessage;
			Console.ReadLine();
		}
		static void ChatMessage(object sender, MessageEventArgs e)
		{
			Console.WriteLine(e.Line);
		}		
	}
}

This bot will connect to a locally hosted on port 25565, using the username Bot. Note that the bot will not connect in a verified state, and may be kicked if verification is turned to on. This bot will also send "Test." whenever a user on the operators list starts a chat message with the word ".test". The bot also used the ChatMessage event to display every chat line it receives. (Including colour codes).

The ClassicBot class is the core bot class. It handles plugins, events, networking, and more. Each bot must have a username and a path for it to store information regarding operators.

Licensing

LibClassicBot is licensed under the MIT license.

Additionally, LibClassicBot uses the StripColors method from fCraft, as well as a cut down version of the map file. fCraft is also released under the MIT license, licensing information regarding fCraft is avaliable here.

LibClassicBot also uses a LoginClient based on code from here. ManicDigger is released under the Public Domain license, as started on this page.

LibClassicBot's image drawing function is based on code from here. 800Craft is released under the BSD 3 clause license.

Minecraft is not officially affiliated with LibClassicBot, nor any of the aforementioned projects.

About

A bot for Minecraft Classic, written in C#.

License:Other