|
|
@ -77,24 +77,6 @@ def main(): |
|
|
|
|
|
|
|
|
|
|
|
database_session.initialize(config) |
|
|
|
database_session.initialize(config) |
|
|
|
|
|
|
|
|
|
|
|
if options.offline: |
|
|
|
|
|
|
|
print("Connecting in offline mode...") |
|
|
|
|
|
|
|
connection = Connection( |
|
|
|
|
|
|
|
options.address, options.port, username=options.username) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
auth_token = authentication.AuthenticationToken() |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
auth_token.authenticate(options.username, options.password) |
|
|
|
|
|
|
|
except YggdrasilError as e: |
|
|
|
|
|
|
|
print(e) |
|
|
|
|
|
|
|
sys.exit() |
|
|
|
|
|
|
|
print("Logged in as %s..." % auth_token.username) |
|
|
|
|
|
|
|
connection = Connection( |
|
|
|
|
|
|
|
options.address, options.port, auth_token=auth_token) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Initialize the discord part |
|
|
|
|
|
|
|
discord_bot = discord.Client() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_disconnect(join_game_packet): |
|
|
|
def handle_disconnect(join_game_packet): |
|
|
|
print('Disconnected.') |
|
|
|
print('Disconnected.') |
|
|
|
nonlocal connection |
|
|
|
nonlocal connection |
|
|
@ -104,7 +86,8 @@ def main(): |
|
|
|
if options.offline: |
|
|
|
if options.offline: |
|
|
|
print("Connecting in offline mode...") |
|
|
|
print("Connecting in offline mode...") |
|
|
|
connection = Connection( |
|
|
|
connection = Connection( |
|
|
|
options.address, options.port, username=options.username) |
|
|
|
options.address, options.port, username=options.username, |
|
|
|
|
|
|
|
handle_exception=handle_disconnect) |
|
|
|
else: |
|
|
|
else: |
|
|
|
auth_token = authentication.AuthenticationToken() |
|
|
|
auth_token = authentication.AuthenticationToken() |
|
|
|
try: |
|
|
|
try: |
|
|
@ -114,10 +97,31 @@ def main(): |
|
|
|
sys.exit() |
|
|
|
sys.exit() |
|
|
|
print("Logged in as %s..." % auth_token.username) |
|
|
|
print("Logged in as %s..." % auth_token.username) |
|
|
|
connection = Connection( |
|
|
|
connection = Connection( |
|
|
|
options.address, options.port, auth_token=auth_token) |
|
|
|
options.address, options.port, auth_token=auth_token, |
|
|
|
|
|
|
|
handle_exception=handle_disconnect) |
|
|
|
register_handlers(connection) |
|
|
|
register_handlers(connection) |
|
|
|
connection.connect() |
|
|
|
connection.connect() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if options.offline: |
|
|
|
|
|
|
|
print("Connecting in offline mode...") |
|
|
|
|
|
|
|
connection = Connection( |
|
|
|
|
|
|
|
options.address, options.port, username=options.username, |
|
|
|
|
|
|
|
handle_exception=handle_disconnect) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
auth_token = authentication.AuthenticationToken() |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
auth_token.authenticate(options.username, options.password) |
|
|
|
|
|
|
|
except YggdrasilError as e: |
|
|
|
|
|
|
|
print(e) |
|
|
|
|
|
|
|
sys.exit() |
|
|
|
|
|
|
|
print("Logged in as %s..." % auth_token.username) |
|
|
|
|
|
|
|
connection = Connection( |
|
|
|
|
|
|
|
options.address, options.port, auth_token=auth_token, |
|
|
|
|
|
|
|
handle_exception=handle_disconnect) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Initialize the discord part |
|
|
|
|
|
|
|
discord_bot = discord.Client() |
|
|
|
|
|
|
|
|
|
|
|
def register_handlers(connection): |
|
|
|
def register_handlers(connection): |
|
|
|
connection.register_packet_listener( |
|
|
|
connection.register_packet_listener( |
|
|
|
handle_join_game, clientbound.play.JoinGamePacket) |
|
|
|
handle_join_game, clientbound.play.JoinGamePacket) |
|
|
|