Add support for chat commands
This commit is contained in:
10
bot.py
10
bot.py
@@ -177,14 +177,10 @@ def bot(global_state):
|
||||
g.chunks = ChunksManager(g.mcdata)
|
||||
g.chunks.register(g.connection)
|
||||
|
||||
g.chat = ChatManager()
|
||||
g.chat.register(g.connection)
|
||||
|
||||
g.connection.connect()
|
||||
|
||||
def packet_wrapper(handler):
|
||||
def wrapper(packet):
|
||||
print('Wrapper:', handler)
|
||||
handler(packet, g)
|
||||
return wrapper
|
||||
|
||||
@@ -197,6 +193,10 @@ def bot(global_state):
|
||||
h3 = packet_wrapper(packet_handlers.handle_block_change)
|
||||
g.connection.register_packet_listener(h3, BlockChangePacket)
|
||||
|
||||
g.chat = ChatManager(g)
|
||||
h4 = packet_wrapper(packet_handlers.handle_chat)
|
||||
g.chat.set_handler(h4)
|
||||
|
||||
try:
|
||||
while not g.pos:
|
||||
time.sleep(TICK)
|
||||
@@ -207,9 +207,7 @@ def bot(global_state):
|
||||
time.sleep(TICK)
|
||||
print('Chunks loaded.')
|
||||
|
||||
print('init..')
|
||||
init(g)
|
||||
print('done init')
|
||||
|
||||
while g.running:
|
||||
tick(g)
|
||||
|
Reference in New Issue
Block a user