allow connection to offline mode servers without a password
This commit is contained in:
parent
666435ddae
commit
af9cc4b546
|
@ -3,14 +3,15 @@ if __name__ == '__main__':
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import importlib
|
import importlib
|
||||||
from math import floor, ceil
|
from math import floor, ceil
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
|
||||||
USERNAME = os.environ['USERNAME']
|
USERNAME = os.getenv('USERNAME')
|
||||||
PASSWORD = os.environ['PASSWORD']
|
PASSWORD = os.getenv('PASSWORD')
|
||||||
SERVER = os.environ['SERVER']
|
SERVER = os.getenv('SERVER')
|
||||||
PORT = int(os.environ.get('PORT', 25565))
|
PORT = int(os.environ.get('PORT', 25565))
|
||||||
|
|
||||||
from . import monkey_patch # must be before any possible pyCraft imports
|
from . import monkey_patch # must be before any possible pyCraft imports
|
||||||
|
@ -249,15 +250,22 @@ def bot(global_state):
|
||||||
if not g.mcdata:
|
if not g.mcdata:
|
||||||
g.mcdata = DataManager('./minecraft_data')
|
g.mcdata = DataManager('./minecraft_data')
|
||||||
|
|
||||||
if not g.connection:
|
if not SERVER:
|
||||||
auth_token = authentication.AuthenticationToken()
|
print('You must specify a server to connect to.')
|
||||||
try:
|
sys.exit()
|
||||||
auth_token.authenticate(USERNAME, PASSWORD)
|
elif not g.connection:
|
||||||
except YggdrasilError as e:
|
if USERNAME and PASSWORD:
|
||||||
print(e)
|
auth_token = authentication.AuthenticationToken()
|
||||||
sys.exit()
|
try:
|
||||||
print("Logged in as %s..." % auth_token.username)
|
auth_token.authenticate(USERNAME, PASSWORD)
|
||||||
g.connection = Connection(SERVER, PORT, auth_token=auth_token)
|
except YggdrasilError as e:
|
||||||
|
print(e)
|
||||||
|
sys.exit()
|
||||||
|
print("Logged in as %s..." % auth_token.username)
|
||||||
|
g.connection = Connection(SERVER, PORT, auth_token=auth_token)
|
||||||
|
elif USERNAME:
|
||||||
|
print('No password provided, attempting to connect in offline mode...')
|
||||||
|
g.connection = Connection(SERVER, PORT, username=USERNAME)
|
||||||
|
|
||||||
g.chunks = ChunksManager(g.mcdata)
|
g.chunks = ChunksManager(g.mcdata)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user