using System; using System.Collections.Generic; using System.Linq; using System.Text; using MinecraftClient.Mapping; namespace MinecraftClient.Protocol { /// /// Interface for the MinecraftCom Handler. /// It defines some callbacks that the MinecraftCom handler must have. /// It allows the protocol handler to abstract from the other parts of the program. /// public interface IMinecraftComHandler { /* The MinecraftCom Handler must * provide these getters */ int GetServerPort(); string GetServerHost(); string GetUsername(); string GetUserUUID(); string GetSessionID(); string[] GetOnlinePlayers(); Location GetCurrentLocation(); World GetWorld(); /// /// Called when a server was successfully joined /// void OnGameJoined(); /// /// This method is called when the protocol handler receives a chat message /// /// Text received from the server /// Links embedded in text (for click events) void OnTextReceived(string text, IEnumerable links); /// /// This method is called when a new player joins the game /// /// UUID of the player /// Name of the player void OnPlayerJoin(Guid uuid, string name); /// /// This method is called when a player has left the game /// /// UUID of the player void OnPlayerLeave(Guid uuid); /// /// Called when the server sets the new location for the player /// /// New location of the player /// Yaw and pitch (optional and currently not parsed) void UpdateLocation(Location location, byte[] yawpitch); /// /// This method is called when the connection has been lost /// void OnConnectionLost(ChatBot.DisconnectReason reason, string message); /// /// Called ~10 times per second (10 ticks per second) /// Useful for updating bots in other parts of the program /// void OnUpdate(); /// /// Registers the given plugin channel for the given bot. /// /// The channel to register. /// The bot to register the channel for. void RegisterPluginChannel(string channel, ChatBot bot); /// /// Unregisters the given plugin channel for the given bot. /// /// The channel to unregister. /// The bot to unregister the channel for. void UnregisterPluginChannel(string channel, ChatBot bot); /// /// Sends a plugin channel packet to the server. /// See http://wiki.vg/Plugin_channel for more information about plugin channels. /// /// The channel to send the packet on. /// The payload for the packet. /// Whether the packet should be sent even if the server or the client hasn't registered it yet. /// Whether the packet was sent: true if it was sent, false if there was a connection error or it wasn't registered. bool SendPluginChannelMessage(string channel, byte[] data, bool sendEvenIfNotRegistered = false); /// /// Called when a plugin channel message was sent from the server. /// /// The channel the message was sent on /// The data from the channel void OnPluginChannelMessage(string channel, byte[] data); } }