def _really_start(self): self.session = Session() yield self.session.login(self.username, self.password) self.factory = MinecraftClientFactory(self.username, self.password, self.session) self.client = internet.TCPClient(self.host, self.port, self.factory) self.client.setServiceParent(self)
class MinecraftClientService(service.MultiService): LAUNCHER_VERSION = 13 def __init__(self, username, password, host="localhost", port=25565): self.username = username self.password = password self.host = host self.port = port self.session = None service.MultiService.__init__(self) def startService(self): self._really_start() service.MultiService.startService(self) def stopService(self): service.MultiService.stopService(self) @defer.inlineCallbacks def _really_start(self): self.session = Session() yield self.session.login(self.username, self.password) self.factory = MinecraftClientFactory(self.username, self.password, self.session) self.client = internet.TCPClient(self.host, self.port, self.factory) self.client.setServiceParent(self)