diff --git a/src/treepuncher/game/state.py b/src/treepuncher/game/state.py index 4f02e97..b042c50 100644 --- a/src/treepuncher/game/state.py +++ b/src/treepuncher/game/state.py @@ -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 diff --git a/src/treepuncher/game/world.py b/src/treepuncher/game/world.py index bd8fe69..96e89ec 100644 --- a/src/treepuncher/game/world.py +++ b/src/treepuncher/game/world.py @@ -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 ) diff --git a/src/treepuncher/scaffold.py b/src/treepuncher/scaffold.py index ca5d568..889ac6f 100644 --- a/src/treepuncher/scaffold.py +++ b/src/treepuncher/scaffold.py @@ -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) diff --git a/src/treepuncher/traits/callbacks.py b/src/treepuncher/traits/callbacks.py index 5c833a4..98221f6 100644 --- a/src/treepuncher/traits/callbacks.py +++ b/src/treepuncher/traits/callbacks.py @@ -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 = {}