mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-13 05:45:22 +01:00
Fix connection to work with new authentication module
This commit is contained in:
parent
0347894fd8
commit
b37c095039
@ -253,10 +253,10 @@ class AuthenticationToken(object):
|
||||
"selectedProfile": self.profile.to_dict(),
|
||||
"serverId": server_id})
|
||||
|
||||
if req.status_code == requests.codes.ok:
|
||||
if not req.raise_for_status():
|
||||
return True
|
||||
else:
|
||||
raise YggdrasilError("Failed to join game.")
|
||||
_raise_from_request(req)
|
||||
|
||||
|
||||
def _make_request(server, endpoint, data):
|
||||
@ -284,14 +284,17 @@ def _raise_from_request(req):
|
||||
if req.status_code == requests.codes.ok:
|
||||
return None
|
||||
|
||||
json_resp = req.json()
|
||||
try:
|
||||
json_resp = req.json()
|
||||
|
||||
if "error" not in json_resp and "errorMessage" not in json_resp:
|
||||
raise YggdrasilError("Malformed error message.")
|
||||
if "error" not in json_resp and "errorMessage" not in json_resp:
|
||||
raise YggdrasilError("Malformed error message.")
|
||||
|
||||
message = "[{status_code}] {error}: '{error_message}'"
|
||||
message = message.format(status_code=str(req.status_code),
|
||||
error=json_resp["error"],
|
||||
error_message=json_resp["errorMessage"])
|
||||
message = "[{status_code}] {error}: '{error_message}'"
|
||||
message = message.format(status_code=str(req.status_code),
|
||||
error=json_resp["error"],
|
||||
error_message=json_resp["errorMessage"])
|
||||
except ValueError:
|
||||
message = "Unknwon requests error: " + str(req.status_code)
|
||||
|
||||
raise YggdrasilError(message)
|
||||
|
@ -120,7 +120,7 @@ class Connection(object):
|
||||
self.reactor = LoginReactor(self)
|
||||
self._start_network_thread()
|
||||
login_start_packet = LoginStartPacket()
|
||||
login_start_packet.name = self.auth_token.username
|
||||
login_start_packet.name = self.auth_token.profile.name
|
||||
self.write_packet(login_start_packet)
|
||||
|
||||
def _connect(self):
|
||||
|
Loading…
Reference in New Issue
Block a user