mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add SendPluginChannelPacket to the IMinecraftCom interface.
This commit is contained in:
parent
7c8e856392
commit
77277bcf84
3 changed files with 62 additions and 24 deletions
|
|
@ -615,6 +615,31 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
return false; //Only supported since MC 1.7
|
return false; //Only supported since MC 1.7
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send a plugin channel packet to the server.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="channel">Channel to send packet on</param>
|
||||||
|
/// <param name="data">packet Data</param>
|
||||||
|
|
||||||
|
public bool SendPluginChannelPacket(string channel, byte[] data)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
byte[] channelLength = BitConverter.GetBytes((short)channel.Length);
|
||||||
|
Array.Reverse(channelLength);
|
||||||
|
|
||||||
|
byte[] channelData = Encoding.BigEndianUnicode.GetBytes(channel);
|
||||||
|
|
||||||
|
byte[] dataLength = BitConverter.GetBytes((short)data.Length);
|
||||||
|
Array.Reverse(dataLength);
|
||||||
|
|
||||||
|
Send(concatBytes(new byte[] { 0xFA }, channelLength, channelData, dataLength, data));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (SocketException) { return false; }
|
||||||
|
catch (System.IO.IOException) { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
public string AutoComplete(string BehindCursor)
|
public string AutoComplete(string BehindCursor)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(BehindCursor))
|
if (String.IsNullOrEmpty(BehindCursor))
|
||||||
|
|
|
||||||
|
|
@ -642,29 +642,6 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
SendPluginChannelPacket("FML|HS", concatBytes(new byte[] { (byte)discriminator }, data));
|
SendPluginChannelPacket("FML|HS", concatBytes(new byte[] { (byte)discriminator }, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Send a plugin channel packet (0x3F) to the server, compression and encryption will be handled automatically
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="channel">Channel to send packet on</param>
|
|
||||||
/// <param name="data">packet Data</param>
|
|
||||||
|
|
||||||
private void SendPluginChannelPacket(string channel, byte[] data)
|
|
||||||
{
|
|
||||||
// In 1.7, length needs to be included.
|
|
||||||
// In 1.8, it must not be.
|
|
||||||
if (protocolversion < MC18Version)
|
|
||||||
{
|
|
||||||
byte[] length = BitConverter.GetBytes((short)data.Length);
|
|
||||||
Array.Reverse(length);
|
|
||||||
|
|
||||||
SendPacket(0x17, concatBytes(getString(channel), length, data));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SendPacket(0x17, concatBytes(getString(channel), data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send a packet to the server, compression and encryption will be handled automatically
|
/// Send a packet to the server, compression and encryption will be handled automatically
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -861,9 +838,34 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(brandInfo))
|
if (String.IsNullOrEmpty(brandInfo))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
return SendPluginChannelPacket("MC|Brand", getString(brandInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send a plugin channel packet (0x17) to the server, compression and encryption will be handled automatically
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="channel">Channel to send packet on</param>
|
||||||
|
/// <param name="data">packet Data</param>
|
||||||
|
|
||||||
|
public bool SendPluginChannelPacket(string channel, byte[] data)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SendPluginChannelPacket("MC|Brand", getString(brandInfo));
|
// In 1.7, length needs to be included.
|
||||||
|
// In 1.8, it must not be.
|
||||||
|
if (protocolversion < MC18Version)
|
||||||
|
{
|
||||||
|
byte[] length = BitConverter.GetBytes((short)data.Length);
|
||||||
|
Array.Reverse(length);
|
||||||
|
|
||||||
|
SendPacket(0x17, concatBytes(getString(channel), length, data));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SendPacket(0x17, concatBytes(getString(channel), data));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (SocketException) { return false; }
|
catch (SocketException) { return false; }
|
||||||
|
|
|
||||||
|
|
@ -51,5 +51,16 @@ namespace MinecraftClient.Protocol
|
||||||
/// <returns>True if brand info was successfully sent</returns>
|
/// <returns>True if brand info was successfully sent</returns>
|
||||||
|
|
||||||
bool SendBrandInfo(string brandInfo);
|
bool SendBrandInfo(string brandInfo);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send a plugin channel packet to the server.
|
||||||
|
///
|
||||||
|
/// http://dinnerbone.com/blog/2012/01/13/minecraft-plugin-channels-messaging/
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="channel">Channel to send packet on</param>
|
||||||
|
/// <param name="data">packet Data</param>
|
||||||
|
/// <returns>True if message was successfully sent</returns>
|
||||||
|
|
||||||
|
bool SendPluginChannelPacket(string channel, byte[] data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue