fixes for logger attribute
This commit is contained in:
parent
e2459f7982
commit
c9f65f56aa
4 changed files with 11 additions and 11 deletions
|
@ -55,7 +55,7 @@ class GameState(Scaffold):
|
||||||
self.in_game = True
|
self.in_game = True
|
||||||
else:
|
else:
|
||||||
self.in_game = False
|
self.in_game = False
|
||||||
self._logger.info(
|
self.logger.info(
|
||||||
"Reloading world: %s (%s) in %s",
|
"Reloading world: %s (%s) in %s",
|
||||||
self.dimension.name,
|
self.dimension.name,
|
||||||
self.difficulty.name,
|
self.difficulty.name,
|
||||||
|
@ -73,7 +73,7 @@ class GameState(Scaffold):
|
||||||
self.in_game = True
|
self.in_game = True
|
||||||
else:
|
else:
|
||||||
self.in_game = False
|
self.in_game = False
|
||||||
self._logger.info(
|
self.logger.info(
|
||||||
"Joined world: %s (%s) in %s",
|
"Joined world: %s (%s) in %s",
|
||||||
self.dimension.name,
|
self.dimension.name,
|
||||||
self.difficulty.name,
|
self.difficulty.name,
|
||||||
|
@ -100,7 +100,7 @@ class GameState(Scaffold):
|
||||||
self.food = packet.food + packet.foodSaturation
|
self.food = packet.food + packet.foodSaturation
|
||||||
if died:
|
if died:
|
||||||
self.run_callbacks(DeathEvent.SENTINEL)
|
self.run_callbacks(DeathEvent.SENTINEL)
|
||||||
self._logger.info("Dead, respawning...")
|
self.logger.info("Dead, respawning...")
|
||||||
await asyncio.sleep(0.5)
|
await asyncio.sleep(0.5)
|
||||||
await self.dispatcher.write(
|
await self.dispatcher.write(
|
||||||
PacketClientCommand(self.dispatcher.proto, actionId=0) # respawn
|
PacketClientCommand(self.dispatcher.proto, actionId=0) # respawn
|
||||||
|
@ -109,7 +109,7 @@ class GameState(Scaffold):
|
||||||
@self.on_packet(PacketExperience)
|
@self.on_packet(PacketExperience)
|
||||||
async def player_xp_cb(packet:PacketExperience):
|
async def player_xp_cb(packet:PacketExperience):
|
||||||
if packet.level != self.lvl:
|
if packet.level != self.lvl:
|
||||||
self._logger.info("Level up : %d", packet.level)
|
self.logger.info("Level up : %d", packet.level)
|
||||||
self.xp = packet.experienceBar
|
self.xp = packet.experienceBar
|
||||||
self.lvl = packet.level
|
self.lvl = packet.level
|
||||||
self.total_xp = packet.totalExperience
|
self.total_xp = packet.totalExperience
|
||||||
|
|
|
@ -25,7 +25,7 @@ class GameWorld(Scaffold):
|
||||||
@self.on_packet(PacketPosition)
|
@self.on_packet(PacketPosition)
|
||||||
async def player_rubberband_cb(packet:PacketPosition):
|
async def player_rubberband_cb(packet:PacketPosition):
|
||||||
self.position = BlockPos(packet.x, packet.y, packet.z)
|
self.position = BlockPos(packet.x, packet.y, packet.z)
|
||||||
self._logger.info(
|
self.logger.info(
|
||||||
"Position synchronized : (x:%.0f,y:%.0f,z:%.0f)",
|
"Position synchronized : (x:%.0f,y:%.0f,z:%.0f)",
|
||||||
self.position.x, self.position.y, self.position.z
|
self.position.x, self.position.y, self.position.z
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,6 +18,8 @@ class Scaffold(
|
||||||
Runnable,
|
Runnable,
|
||||||
):
|
):
|
||||||
|
|
||||||
|
send_keep_alive : bool = True # TODO how to handle this?
|
||||||
|
|
||||||
def on_packet(self, packet:Type[Packet]):
|
def on_packet(self, packet:Type[Packet]):
|
||||||
def decorator(fun):
|
def decorator(fun):
|
||||||
return self.register(packet, fun)
|
return self.register(packet, fun)
|
||||||
|
@ -33,16 +35,16 @@ class Scaffold(
|
||||||
self.dispatcher.state = ConnectionState.PLAY
|
self.dispatcher.state = ConnectionState.PLAY
|
||||||
self.run_callbacks(ConnectedEvent, ConnectedEvent())
|
self.run_callbacks(ConnectedEvent, ConnectedEvent())
|
||||||
async for packet in self.dispatcher.packets():
|
async for packet in self.dispatcher.packets():
|
||||||
self._logger.debug("[ * ] Processing %s", packet.__class__.__name__)
|
self.logger.debug("[ * ] Processing %s", packet.__class__.__name__)
|
||||||
if isinstance(packet, PacketSetCompression):
|
if isinstance(packet, PacketSetCompression):
|
||||||
self._logger.info("Compression updated")
|
self.logger.info("Compression updated")
|
||||||
self.dispatcher.compression = packet.threshold
|
self.dispatcher.compression = packet.threshold
|
||||||
elif isinstance(packet, PacketKeepAlive):
|
elif isinstance(packet, PacketKeepAlive):
|
||||||
if self.options.keep_alive:
|
if self.send_keep_alive:
|
||||||
keep_alive_packet = PacketKeepAliveResponse(340, keepAliveId=packet.keepAliveId)
|
keep_alive_packet = PacketKeepAliveResponse(340, keepAliveId=packet.keepAliveId)
|
||||||
await self.dispatcher.write(keep_alive_packet)
|
await self.dispatcher.write(keep_alive_packet)
|
||||||
elif isinstance(packet, PacketKickDisconnect):
|
elif isinstance(packet, PacketKickDisconnect):
|
||||||
self._logger.error("Kicked while in game : %s", helpers.parse_chat(packet.reason))
|
self.logger.error("Kicked while in game : %s", helpers.parse_chat(packet.reason))
|
||||||
break
|
break
|
||||||
self.run_callbacks(type(packet), packet)
|
self.run_callbacks(type(packet), packet)
|
||||||
self.run_callbacks(Packet, packet)
|
self.run_callbacks(Packet, packet)
|
||||||
|
|
|
@ -12,8 +12,6 @@ class CallbacksHolder:
|
||||||
_callbacks : Dict[Any, List[Callable]]
|
_callbacks : Dict[Any, List[Callable]]
|
||||||
_tasks : Dict[uuid.UUID, asyncio.Event]
|
_tasks : Dict[uuid.UUID, asyncio.Event]
|
||||||
|
|
||||||
_logger : logging.Logger
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._callbacks = {}
|
self._callbacks = {}
|
||||||
|
|
Loading…
Reference in a new issue