2014-05-31 01:59:03 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
2015-11-27 17:16:33 +01:00
|
|
|
|
using MinecraftClient.Mapping;
|
2014-05-31 01:59:03 +02:00
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Protocol
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 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.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
|
|
|
|
public interface IMinecraftComHandler
|
|
|
|
|
|
{
|
2016-02-07 14:24:01 -08:00
|
|
|
|
/* The MinecraftCom Handler must
|
2014-05-31 01:59:03 +02:00
|
|
|
|
* provide these getters */
|
|
|
|
|
|
|
2015-06-20 22:58:18 +02:00
|
|
|
|
int GetServerPort();
|
|
|
|
|
|
string GetServerHost();
|
|
|
|
|
|
string GetUsername();
|
|
|
|
|
|
string GetUserUUID();
|
|
|
|
|
|
string GetSessionID();
|
2016-08-27 15:46:34 +02:00
|
|
|
|
string[] GetOnlinePlayers();
|
2015-11-27 17:16:33 +01:00
|
|
|
|
Location GetCurrentLocation();
|
2015-11-30 15:30:49 +01:00
|
|
|
|
World GetWorld();
|
2014-11-11 00:32:32 +11:00
|
|
|
|
|
2015-09-30 20:01:57 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when a server was successfully joined
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void OnGameJoined();
|
|
|
|
|
|
|
2014-05-31 01:59:03 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This method is called when the protocol handler receives a chat message
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void OnTextReceived(string text);
|
|
|
|
|
|
|
2014-11-10 20:43:00 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This method is called when a new player joins the game
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="uuid">UUID of the player</param>
|
2016-08-27 15:46:34 +02:00
|
|
|
|
/// <param name="name">Name of the player</param>
|
|
|
|
|
|
void OnPlayerJoin(Guid uuid, string name);
|
2014-11-10 20:43:00 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This method is called when a player has left the game
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="uuid">UUID of the player</param>
|
|
|
|
|
|
void OnPlayerLeave(Guid uuid);
|
|
|
|
|
|
|
2015-11-27 17:16:33 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when the server sets the new location for the player
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="location">New location of the player</param>
|
|
|
|
|
|
void UpdateLocation(Location location);
|
|
|
|
|
|
|
2014-05-31 01:59:03 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This method is called when the connection has been lost
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void OnConnectionLost(ChatBot.DisconnectReason reason, string message);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called ~10 times per second (10 ticks per second)
|
|
|
|
|
|
/// Useful for updating bots in other parts of the program
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void OnUpdate();
|
2016-02-07 14:24:01 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Registers the given plugin channel for the given bot.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="channel">The channel to register.</param>
|
|
|
|
|
|
/// <param name="bot">The bot to register the channel for.</param>
|
|
|
|
|
|
void RegisterPluginChannel(string channel, ChatBot bot);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Unregisters the given plugin channel for the given bot.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="channel">The channel to unregister.</param>
|
|
|
|
|
|
/// <param name="bot">The bot to unregister the channel for.</param>
|
|
|
|
|
|
void UnregisterPluginChannel(string channel, ChatBot bot);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2016-03-10 13:29:05 +01:00
|
|
|
|
/// Sends a plugin channel packet to the server.
|
|
|
|
|
|
/// See http://wiki.vg/Plugin_channel for more information about plugin channels.
|
2016-02-07 14:24:01 -08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="channel">The channel to send the packet on.</param>
|
|
|
|
|
|
/// <param name="data">The payload for the packet.</param>
|
|
|
|
|
|
/// <param name="sendEvenIfNotRegistered">Whether the packet should be sent even if the server or the client hasn't registered it yet.</param>
|
|
|
|
|
|
/// <returns>Whether the packet was sent: true if it was sent, false if there was a connection error or it wasn't registered.</returns>
|
|
|
|
|
|
bool SendPluginChannelMessage(string channel, byte[] data, bool sendEvenIfNotRegistered = false);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called when a plugin channel message was sent from the server.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="channel">The channel the message was sent on</param>
|
|
|
|
|
|
/// <param name="data">The data from the channel</param>
|
|
|
|
|
|
void OnPluginChannelMessage(string channel, byte[] data);
|
2014-05-31 01:59:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|