Fix null reference when trying to get protocol version (#1298)

* Fix null reference when trying to get protocol version
* Use only stored version of protocolversion
(No need to add a switch because the protocol version will not change between InitializeClient() calls)
Co-authored-by: ORelio <ORelio@users.noreply.github.com>
This commit is contained in:
ReinforceZwei 2020-10-31 03:35:03 +08:00 committed by GitHub
parent ec9f999857
commit ce389b6b31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,6 +55,7 @@ namespace MinecraftClient
private string host; private string host;
private int port; private int port;
private int protocolversion;
private string username; private string username;
private string uuid; private string uuid;
private string sessionid; private string sessionid;
@ -105,7 +106,7 @@ namespace MinecraftClient
public byte GetCurrentSlot() { return CurrentSlot; } public byte GetCurrentSlot() { return CurrentSlot; }
public int GetGamemode() { return gamemode; } public int GetGamemode() { return gamemode; }
public bool GetNetworkPacketCaptureEnabled() { return networkPacketCaptureEnabled; } public bool GetNetworkPacketCaptureEnabled() { return networkPacketCaptureEnabled; }
public int GetProtocolVersion() { return handler.GetProtocolVersion(); } public int GetProtocolVersion() { return protocolversion; }
// get bots list for unloading them by commands // get bots list for unloading them by commands
public List<ChatBot> GetLoadedChatBots() public List<ChatBot> GetLoadedChatBots()
@ -170,6 +171,7 @@ namespace MinecraftClient
this.username = user; this.username = user;
this.host = server_ip; this.host = server_ip;
this.port = port; this.port = port;
this.protocolVersion = protocolversion;
if (!singlecommand) if (!singlecommand)
{ {