|
|
|
@ -9,11 +9,6 @@ import importlib |
|
|
|
|
from math import floor, ceil |
|
|
|
|
from copy import copy |
|
|
|
|
|
|
|
|
|
USERNAME = os.getenv('USERNAME') |
|
|
|
|
PASSWORD = os.getenv('PASSWORD') |
|
|
|
|
SERVER = os.getenv('SERVER') |
|
|
|
|
PORT = int(os.environ.get('PORT', 25565)) |
|
|
|
|
|
|
|
|
|
from . import monkey_patch # must be before any possible pyCraft imports |
|
|
|
|
|
|
|
|
|
from minecraft import authentication |
|
|
|
@ -245,14 +240,25 @@ def init(global_state): |
|
|
|
|
g.maximum_supply_slots = 33 |
|
|
|
|
|
|
|
|
|
def bot(global_state): |
|
|
|
|
USERNAME = os.getenv('USERNAME') |
|
|
|
|
PASSWORD = os.getenv('PASSWORD') |
|
|
|
|
SERVER = os.getenv('SERVER') |
|
|
|
|
PORT = int(os.environ.get('PORT', 25565)) |
|
|
|
|
|
|
|
|
|
g = global_state |
|
|
|
|
|
|
|
|
|
if not g.mcdata: |
|
|
|
|
g.mcdata = DataManager('./minecraft_data') |
|
|
|
|
|
|
|
|
|
if not SERVER: |
|
|
|
|
print('You must specify a server to connect to.') |
|
|
|
|
sys.exit() |
|
|
|
|
print() |
|
|
|
|
print('You must specify a server to connect to. For example:') |
|
|
|
|
print('SERVER=minecraft.example.com ./run_linux.sh') |
|
|
|
|
print('SERVER=localhost PORT=12345 ./run_linux.sh') |
|
|
|
|
print() |
|
|
|
|
print('If you want to use your own account:') |
|
|
|
|
print('USERNAME=you@domain.com PASSWORD=supersecret SERVER=minecraft.example.com ./run_linux.sh') |
|
|
|
|
os._exit(0) |
|
|
|
|
elif not g.connection: |
|
|
|
|
if USERNAME and PASSWORD: |
|
|
|
|
auth_token = authentication.AuthenticationToken() |
|
|
|
@ -260,12 +266,25 @@ def bot(global_state): |
|
|
|
|
auth_token.authenticate(USERNAME, PASSWORD) |
|
|
|
|
except YggdrasilError as e: |
|
|
|
|
print(e) |
|
|
|
|
sys.exit() |
|
|
|
|
os._exit(0) |
|
|
|
|
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) |
|
|
|
|
else: |
|
|
|
|
print('No username or password provided, using burner minecraft account...') |
|
|
|
|
USERNAME = 'moc.liamg@monortem'[::-1] |
|
|
|
|
PASSWORD = '!8891anteR'[::-1] |
|
|
|
|
auth_token = authentication.AuthenticationToken() |
|
|
|
|
try: |
|
|
|
|
auth_token.authenticate(USERNAME, PASSWORD) |
|
|
|
|
except YggdrasilError as e: |
|
|
|
|
print(e) |
|
|
|
|
os._exit(0) |
|
|
|
|
print("Logged in as %s..." % auth_token.username) |
|
|
|
|
g.connection = Connection(SERVER, PORT, auth_token=auth_token) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g.chunks = ChunksManager(g.mcdata) |
|
|
|
|
|
|
|
|
|