Delay BrandInfo sending

Implement Game Join event and send Brand Info only when server
acknowledged game join, as ZizzyDizzyMC did before, else server may
generate an invalid packet error because it was still in "login" mode
and not in "playing" mode. Fix second issue in #95
This commit is contained in:
ORelio 2015-09-30 20:01:57 +02:00
parent 8bd130eb3a
commit b25a665c82
3 changed files with 19 additions and 3 deletions

View file

@ -120,9 +120,6 @@ namespace MinecraftClient
{ {
if (handler.Login()) if (handler.Login())
{ {
if (!String.IsNullOrWhiteSpace(Settings.BrandInfo))
handler.SendBrandInfo(Settings.BrandInfo.Trim());
if (singlecommand) if (singlecommand)
{ {
handler.SendChatMessage(command); handler.SendChatMessage(command);
@ -322,6 +319,16 @@ namespace MinecraftClient
client.Close(); client.Close();
} }
/// <summary>
/// Called when a server was successfully joined
/// </summary>
public void OnGameJoined()
{
if (!String.IsNullOrWhiteSpace(Settings.BrandInfo))
handler.SendBrandInfo(Settings.BrandInfo.Trim());
}
/// <summary> /// <summary>
/// Received some text from the server /// Received some text from the server
/// </summary> /// </summary>

View file

@ -139,6 +139,9 @@ namespace MinecraftClient.Protocol.Handlers
case 0x00: //Keep-Alive case 0x00: //Keep-Alive
SendPacket(0x00, packetData); SendPacket(0x00, packetData);
break; break;
case 0x01: //Join game
handler.OnGameJoined();
break;
case 0x02: //Chat message case 0x02: //Chat message
string message = readNextString(ref packetData); string message = readNextString(ref packetData);
try try

View file

@ -23,6 +23,12 @@ namespace MinecraftClient.Protocol
string GetSessionID(); string GetSessionID();
string[] GetOnlinePlayers(); string[] GetOnlinePlayers();
/// <summary>
/// Called when a server was successfully joined
/// </summary>
void OnGameJoined();
/// <summary> /// <summary>
/// This method is called when the protocol handler receives a chat message /// This method is called when the protocol handler receives a chat message
/// </summary> /// </summary>