mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-26 12:16:28 +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(),
|
"selectedProfile": self.profile.to_dict(),
|
||||||
"serverId": server_id})
|
"serverId": server_id})
|
||||||
|
|
||||||
if req.status_code == requests.codes.ok:
|
if not req.raise_for_status():
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
raise YggdrasilError("Failed to join game.")
|
_raise_from_request(req)
|
||||||
|
|
||||||
|
|
||||||
def _make_request(server, endpoint, data):
|
def _make_request(server, endpoint, data):
|
||||||
@ -284,6 +284,7 @@ def _raise_from_request(req):
|
|||||||
if req.status_code == requests.codes.ok:
|
if req.status_code == requests.codes.ok:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
json_resp = req.json()
|
json_resp = req.json()
|
||||||
|
|
||||||
if "error" not in json_resp and "errorMessage" not in json_resp:
|
if "error" not in json_resp and "errorMessage" not in json_resp:
|
||||||
@ -293,5 +294,7 @@ def _raise_from_request(req):
|
|||||||
message = message.format(status_code=str(req.status_code),
|
message = message.format(status_code=str(req.status_code),
|
||||||
error=json_resp["error"],
|
error=json_resp["error"],
|
||||||
error_message=json_resp["errorMessage"])
|
error_message=json_resp["errorMessage"])
|
||||||
|
except ValueError:
|
||||||
|
message = "Unknwon requests error: " + str(req.status_code)
|
||||||
|
|
||||||
raise YggdrasilError(message)
|
raise YggdrasilError(message)
|
||||||
|
@ -120,7 +120,7 @@ class Connection(object):
|
|||||||
self.reactor = LoginReactor(self)
|
self.reactor = LoginReactor(self)
|
||||||
self._start_network_thread()
|
self._start_network_thread()
|
||||||
login_start_packet = LoginStartPacket()
|
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)
|
self.write_packet(login_start_packet)
|
||||||
|
|
||||||
def _connect(self):
|
def _connect(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user