Extend BrandInfo setting

Brand Information tells the server what client is being used to connect
to the server, possible values are the following:

- none (do not tell anything)
- vanilla (tells that you are using MC vanilla)
- mcc (tell that you are using MCC + version)

This will usually not do anything unless plugins developers use this
information for developing some MCC interoperability eg more chat
interactions instead of using GUIs. This could also be used to block
third party clients, that's why brand information can be disabled or
changed to vanilla.
This commit is contained in:
ORelio 2015-09-29 14:00:44 +02:00
parent fe68e881fb
commit 8560753949
5 changed files with 53 additions and 23 deletions

View file

@ -610,6 +610,11 @@ namespace MinecraftClient.Protocol.Handlers
catch (SocketException) { return false; }
}
public bool SendBrandInfo(string brandInfo)
{
return false; //Only supported since MC 1.7
}
public string AutoComplete(string BehindCursor)
{
if (String.IsNullOrEmpty(BehindCursor))

View file

@ -139,12 +139,6 @@ namespace MinecraftClient.Protocol.Handlers
case 0x00: //Keep-Alive
SendPacket(0x00, packetData);
break;
case 0x01: //Join game
if (Settings.SendBrandInfoEnabled.Equals(true))
{
SendBrandInfo();
}
break;
case 0x02: //Chat message
handler.OnTextReceived(ChatParser.ParseText(readNextString(ref packetData)));
break;
@ -613,20 +607,6 @@ namespace MinecraftClient.Protocol.Handlers
}
}
/// <summary>
/// Sends information about the client version.
/// </summary>
private void SendBrandInfo()
{
byte[] channel = Encoding.UTF8.GetBytes("MC|Brand");
byte[] channelLen = getVarInt(channel.Length);
byte[] brand = Encoding.UTF8.GetBytes("Minecraft Console Client v" + Program.Version);
byte[] brandLen = getVarInt(brand.Length);
SendPacket(0x17, concatBytes(channelLen, channel, brandLen, brand));
}
/// <summary>
/// Send a chat message to the server
/// </summary>
@ -665,6 +645,29 @@ namespace MinecraftClient.Protocol.Handlers
catch (SocketException) { return false; }
}
/// <summary>
/// Tell the server what client is being used to connect to the server
/// </summary>
/// <param name="brandInfo">Client string describing the client</param>
/// <returns>True if brand info was successfully sent</returns>
public bool SendBrandInfo(string brandInfo)
{
if (String.IsNullOrEmpty(brandInfo))
return false;
try
{
byte[] channel = Encoding.UTF8.GetBytes("MC|Brand");
byte[] channelLen = getVarInt(channel.Length);
byte[] brand = Encoding.UTF8.GetBytes(brandInfo);
byte[] brandLen = getVarInt(brand.Length);
SendPacket(0x17, concatBytes(channelLen, channel, brandLen, brand));
return true;
}
catch (SocketException) { return false; }
catch (System.IO.IOException) { return false; }
}
/// <summary>
/// Disconnect from the server
/// </summary>