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
|
|
@ -642,29 +642,6 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
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>
|
||||
/// Send a packet to the server, compression and encryption will be handled automatically
|
||||
/// </summary>
|
||||
|
|
@ -861,9 +838,34 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
if (String.IsNullOrEmpty(brandInfo))
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
catch (SocketException) { return false; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue