fixes for logger attribute

This commit is contained in:
əlemi 2022-04-18 19:35:11 +02:00
parent e2459f7982
commit c9f65f56aa
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E
4 changed files with 11 additions and 11 deletions

View file

@ -55,7 +55,7 @@ class GameState(Scaffold):
self.in_game = True
else:
self.in_game = False
self._logger.info(
self.logger.info(
"Reloading world: %s (%s) in %s",
self.dimension.name,
self.difficulty.name,
@ -73,7 +73,7 @@ class GameState(Scaffold):
self.in_game = True
else:
self.in_game = False
self._logger.info(
self.logger.info(
"Joined world: %s (%s) in %s",
self.dimension.name,
self.difficulty.name,
@ -100,7 +100,7 @@ class GameState(Scaffold):
self.food = packet.food + packet.foodSaturation
if died:
self.run_callbacks(DeathEvent.SENTINEL)
self._logger.info("Dead, respawning...")
self.logger.info("Dead, respawning...")
await asyncio.sleep(0.5)
await self.dispatcher.write(
PacketClientCommand(self.dispatcher.proto, actionId=0) # respawn
@ -109,7 +109,7 @@ class GameState(Scaffold):
@self.on_packet(PacketExperience)
async def player_xp_cb(packet:PacketExperience):
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.lvl = packet.level
self.total_xp = packet.totalExperience

View file

@ -25,7 +25,7 @@ class GameWorld(Scaffold):
@self.on_packet(PacketPosition)
async def player_rubberband_cb(packet:PacketPosition):
self.position = BlockPos(packet.x, packet.y, packet.z)
self._logger.info(
self.logger.info(
"Position synchronized : (x:%.0f,y:%.0f,z:%.0f)",
self.position.x, self.position.y, self.position.z
)

View file

@ -18,6 +18,8 @@ class Scaffold(
Runnable,
):
send_keep_alive : bool = True # TODO how to handle this?
def on_packet(self, packet:Type[Packet]):
def decorator(fun):
return self.register(packet, fun)
@ -33,16 +35,16 @@ class Scaffold(
self.dispatcher.state = ConnectionState.PLAY
self.run_callbacks(ConnectedEvent, ConnectedEvent())
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):
self._logger.info("Compression updated")
self.logger.info("Compression updated")
self.dispatcher.compression = packet.threshold
elif isinstance(packet, PacketKeepAlive):
if self.options.keep_alive:
if self.send_keep_alive:
keep_alive_packet = PacketKeepAliveResponse(340, keepAliveId=packet.keepAliveId)
await self.dispatcher.write(keep_alive_packet)
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
self.run_callbacks(type(packet), packet)
self.run_callbacks(Packet, packet)

View file

@ -12,8 +12,6 @@ class CallbacksHolder:
_callbacks : Dict[Any, List[Callable]]
_tasks : Dict[uuid.UUID, asyncio.Event]
_logger : logging.Logger
def __init__(self):
super().__init__()
self._callbacks = {}