def warp_player_to_player(self, from_string, to_string): from_player = self.player_manager.get_logged_in_by_name(from_string) to_player = self.player_manager.get_logged_in_by_name(to_string) if from_player is not None: if to_player is not None: from_protocol = self.factory.protocols[from_player.protocol] if from_player is not to_player: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_OTHER_SHIP", player=to_player.name.encode('utf-8'))) else: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t='WARP_UP')) from_protocol.client_protocol.transport.write(warp_packet) if from_string != to_string: self.protocol.send_chat_message("Warped ^yellow;%s^green; to ^yellow;%s^green;." % (from_string, to_string)) else: self.protocol.send_chat_message("Warped to ^yellow;%s^green;." % to_string) else: self.protocol.send_chat_message("No player by the name ^yellow;%s^green; found." % to_string) self.protocol.send_chat_message(self.warp.__doc__) return else: self.protocol.send_chat_message("No player by the name ^yellow;%s^green; found." % from_string) self.protocol.send_chat_message(self.warp.__doc__)
def warp_player_to_player(self, from_string, to_string): self.logger.debug( "Warp player-to-player command called by %s: %s to %s", self.protocol.player.name, from_string, to_string) from_player = self.player_manager.get_logged_in_by_name(from_string) to_player = self.player_manager.get_logged_in_by_name(to_string) if from_player is not None: if to_player is not None: from_protocol = self.factory.protocols[from_player.protocol] if from_player is not to_player: warp_packet = build_packet( Packets.WARP_COMMAND, warp_command_write( t="WARP_OTHER_SHIP", player=to_player.name.encode('utf-8'))) else: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t='WARP_UP')) from_protocol.client_protocol.transport.write(warp_packet) else: self.protocol.send_chat_message( "No player by the name %s found." % to_string) self.protocol.send_chat_message(self.warp.__doc__) return else: self.protocol.send_chat_message("No player by the name %s found." % from_string) self.protocol.send_chat_message(self.warp.__doc__)
def warp(self, name): """Warps you to a planet. Syntax: /warp [warp name]""" name = " ".join(name).strip().strip("\t") if len(name) == 0: warps = [] for warp in self.planet_warps: if warps != "": warps.append(warp[1]) warpnames = " ".join(warps) self.protocol.send_chat_message("List of planet warps:\n "+warpnames) return for warp in self.planet_warps: if warp[1] == name: sector, x, y, z, planet, satellite = warp[0].split(":") x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite)) warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, x=x, y=y, z=z, planet=planet, satellite=satellite)) self.protocol.client_protocol.transport.write(warp_packet) warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_DOWN")) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message("Warped.") return self.protocol.send_chat_message("No warp with that name!")
def warp_player_to_player(self, from_string, to_string): self.logger.debug("Warp player-to-player command called by %s: %s to %s", self.protocol.player.name, from_string, to_string) from_player = self.player_manager.get_logged_in_by_name(from_string) to_player = self.player_manager.get_logged_in_by_name(to_string) print from_player print to_player if from_player is not None: if to_player is not None: from_protocol = self.factory.protocols[from_player.protocol] if from_player is not to_player: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_OTHER_SHIP", player=to_player.name.encode('utf-8'))) print warp_packet else: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t='WARP_UP')) from_protocol.client_protocol.transport.write(warp_packet) else: self.protocol.send_chat_message("No player by the name %s found." % to_string) self.protocol.send_chat_message(self.warp.__doc__) return else: self.protocol.send_chat_message("No player by the name %s found." % from_string) self.protocol.send_chat_message(self.warp.__doc__)
def warp_player_to_player(self, from_string, to_string): self.logger.debug("Warp player-to-player command called by %s: %s to %s", self.protocol.player.name, from_string, to_string) from_player = self.player_manager.get_logged_in_by_name(from_string) to_player = self.player_manager.get_logged_in_by_name(to_string) if from_player is not None: if to_player is not None: from_protocol = self.factory.protocols[from_player.protocol] if from_player is not to_player: self.logger.debug("target: %s", to_player.uuid) warp_packet = build_packet(Packets.PLAYER_WARP, player_warp_write(t="WARP_TO", world_id=to_player.uuid)) else: warp_packet = build_packet(Packets.PLAYER_WARP, player_warp_write(t="WARP_TO_OWN_SHIP", world_id=None)) from_protocol.client_protocol.transport.write(warp_packet) if from_string != to_string: self.protocol.send_chat_message("Warped ^yellow;%s^green; to ^yellow;%s^green;." % (from_string, to_string)) else: self.protocol.send_chat_message("Warped to ^yellow;%s^green;." % to_string) else: self.protocol.send_chat_message("No player by the name ^yellow;%s^green; found." % to_string) self.protocol.send_chat_message(self.warp.__doc__) return else: self.protocol.send_chat_message("No player by the name ^yellow;%s^green; found." % from_string) self.protocol.send_chat_message(self.warp.__doc__)
def warp(self, name): """Warps you to a planet. Syntax: /warp [warp name]""" name = " ".join(name).strip().strip("\t") if len(name) == 0: warps = [] for warp in self.planet_warps: if warps != "": warps.append(warp[1]) warpnames = " ".join(warps) self.protocol.send_chat_message("List of planet warps:\n " + warpnames) return for warp in self.planet_warps: if warp[1] == name: sector, x, y, z, planet, satellite = warp[0].split(":") x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite)) warp_packet = build_packet( Packets.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, x=x, y=y, z=z, planet=planet, satellite=satellite), ) self.protocol.client_protocol.transport.write(warp_packet) warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_DOWN")) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message("Warped.") return self.protocol.send_chat_message("No warp with that name!")
def home(self, arg): """Warps you to your home planet.\nSyntax: /home""" player = self.player_manager.get_logged_in_by_name(self.protocol.player.name) from_protocol = self.factory.protocols[player.protocol] warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t='WARP_HOME')) from_protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message("^yellow;%s^green; warped to their home planet." % self.protocol.player.name)
def on_chat_received(self, data): now = datetime.now() try: p = chat_received().parse(data.data) if p.name == 'server': return # Running a regex substitution on every chat message isn't exactly great but it'll have to do for now. sender = self.player_manager.get_by_name( str( re.sub('(\\^\\w+;|\\^#\\w+;|\\W)|(\\s\\s+)', '', p.name) ) ) if self.config.chattimestamps: p.name = '{}> <{}'.format( now.strftime('%H:%M'), sender.colored_name(self.config.colors) ) else: p.name = sender.colored_name(self.config.colors) self.protocol.transport.write( build_packet(Packets.CHAT_RECEIVED, chat_received().build(p)) ) except AttributeError as e: self.logger.warning( 'Received AttributeError in colored_name. %s', str(e) ) self.protocol.transport.write(data.original_data) return False
def disconnect(self): x = build_packet( packets.Packets.CLIENT_DISCONNECT_REQUEST, packets.client_disconnect_request().build(Container(data=0)) ) self.transport.write(x) self.transport.abortConnection()
def poi(self, name): """Moves you and your ship to a Planet of Interest (PoI). Syntax: /poi [name] *omit [name] for list of PoI's""" name = " ".join(name).strip().strip("\t") if len(name) == 0: warps = [] for warp in self.planet_warps: if warps != "": warps.append(warp[1]) warpnames = "^green;, ^yellow;".join(warps) self.protocol.send_chat_message("List of PoI's: ^yellow;" + warpnames) return on_ship = self.protocol.player.on_ship if not on_ship: self.protocol.send_chat_message("You need to be on a ship!") return for warp in self.planet_warps: if warp[1] == name: sector, x, y, z, planet, satellite = warp[0].split(":") x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite)) warp_packet = build_packet( Packets.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, x=x, y=y, z=z, planet=planet, satellite=satellite), ) self.protocol.client_protocol.transport.write(warp_packet) # warp_packet = build_packet(Packets.WARP_COMMAND, # warp_command_write(t="WARP_DOWN")) # self.protocol.client_protocol.transport.write(warp_packet) # self.protocol.send_chat_message("Beamed down to ^yellow;%s^green; and your ship will arrive soon." % name) self.protocol.send_chat_message("Warp drive engaged! Warping to ^yellow;%s^green;." % name) return self.protocol.send_chat_message("There is no PoI with that name!")
def send_chat_message(self, text, channel=0, world='', name=''): """ Convenience function to send chat messages to the client. Note that this does *not* send messages to the server at large; broadcast should be used for messages to all clients, or manually constructed chat messages otherwise. :param text: Message text, may contain multiple lines. :param channel: The chat channel/context. 0 is global, 1 is planet. :param world: World :param name: The name to display before the message. Blank leaves no brackets, otherwise it will be displayed as `<name>`. :return: None """ if '\n' in text: lines = text.split('\n') for line in lines: self.send_chat_message(line) return chat_data = packets.chat_received().build( Container(chat_channel=channel, world=world, client_id=0, name=name, message=text.encode("utf-8"))) chat_packet = build_packet(packets.Packets.CHAT_RECEIVED, chat_data) self.transport.write(chat_packet)
def warp_self_to_player(self, name): self.logger.debug("Warp command called by %s to %s", self.protocol.player.name, name) name = " ".join(name) target_player = self.player_manager.get_logged_in_by_name(name) if target_player is not None: if target_player is not self.protocol.player: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_OTHER_SHIP", player=target_player.name.encode('utf-8'))) else: warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t='WARP_UP')) self.protocol.client_protocol.transport.write(warp_packet) else: self.protocol.send_chat_message("No player by the name %s found." % name) self.protocol.send_chat_message(self.warp.__doc__)
def beam_to_planet(self, where): warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_DOWN")) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message("Beamed down to ^yellow;%s^green; and your ship will arrive soon." % where) self.factory.broadcast_planet( "%s^green; beamed down to the planet" % self.protocol.player.colored_name(self.config.colors), planet=self.protocol.player.planet)
def connectionLost(self, reason=connectionDone): """ Called as a pseudo-destructor when the connection is lost. :param reason: The reason for the disconnection. :return: None """ try: if self.client_protocol is not None: x = build_packet( packets.Packets.CLIENT_DISCONNECT, packets.client_disconnect().build(Container(data=0))) if self.player is not None and self.player.logged_in: self.client_disconnect(x) self.client_protocol.transport.write(x) self.client_protocol.transport.abortConnection() except: logger.error("Couldn't disconnect protocol.") finally: try: self.factory.protocols.pop(self.id) except: logger.info( "Protocol was not in factory list. This should not happen." ) finally: logger.info("Lost connection from IP: %s", self.transport.getPeer().host) self.transport.abortConnection()
def spawn(self, data): """ Warps your ship to spawn. Syntax: /spawn """ for warp in self.pois: if warp[1] == 'spawn': x, y, z, planet, satellite = warp[0].split(':') x, y, z, planet, satellite = map( int, (x, y, z, planet, satellite) ) warp_packet = build_packet( Packets.FLY_SHIP, fly_ship_write( x=x, y=y, z=z, planet=planet, satellite=satellite ) ) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message( 'Warp drive engaged! Warping to ^yellow;Spawn^green;.' ) return else: self.protocol.send_chat_message( 'The spawn planet must be set first!' )
def reject_with_reason(self, reason): rejection = build_packet( packets.Packets.CONNECT_RESPONSE, packets.connect_response().build( Container(success=False, client_id=0, reject_reason=reason))) self.protocol.transport.write(rejection) self.protocol.transport.loseConnection()
def send_chat_message(self, text, mode='BROADCAST', channel='', name=''): """ Convenience function to send chat messages to the client. Note that this does *not* send messages to the server at large; broadcast should be used for messages to all clients, or manually constructed chat messages otherwise. :param text: Message text, may contain multiple lines. :param channel: The chat channel/context. :param name: The name to display before the message. Blank leaves no brackets, otherwise it will be displayed as `<name>`. :return: None """ if '\n' in text: lines = text.split('\n') for line in lines: self.send_chat_message(line) return if self.player is not None: logger.vdebug(('Calling send_chat_message from player %s on channel' ' %s with mode %s with reported username of %s with' ' message: %s'), self.player.name, channel, mode, name, text) chat_data = packets.chat_received().build(Container(mode=mode, channel=channel, client_id=0, name=name, message=text.encode("utf-8"))) logger.vdebug("Built chat payload. Data: %s", chat_data.encode("hex")) chat_packet = build_packet(packets.Packets.CHAT_RECEIVED, chat_data) logger.vdebug("Built chat packet. Data: %s", chat_packet.encode("hex")) self.transport.write(chat_packet) logger.vdebug("Sent chat message with text: %s", text)
def send_chat_message(self, text, mode='BROADCAST', channel='', name=''): """ Convenience function to send chat messages to the client. Note that this does *not* send messages to the server at large; broadcast should be used for messages to all clients, or manually constructed chat messages otherwise. :param text: Message text, may contain multiple lines. :param channel: The chat channel/context. :param name: The name to display before the message. Blank leaves no brackets, otherwise it will be displayed as `<name>`. :return: None """ if '\n' in text: lines = text.split('\n') for line in lines: self.send_chat_message(line) return if self.player is not None: logger.vdebug( ('Calling send_chat_message from player %s on channel' ' %s with mode %s with reported username of %s with' ' message: %s'), self.player.name, channel, mode, name, text) chat_data = packets.chat_received().build( Container(mode=mode, channel=channel, client_id=0, name=name, message=text.encode("utf-8"))) logger.vdebug("Built chat payload. Data: %s", chat_data.encode("hex")) chat_packet = build_packet(packets.Packets.CHAT_RECEIVED, chat_data) logger.vdebug("Built chat packet. Data: %s", chat_packet.encode("hex")) self.transport.write(chat_packet) logger.vdebug("Sent chat message with text: %s", text)
def teleport_to_own_ship(self, data): """ Teleports a player to their own ship. If no source player is provided, we assume you mean yourself. Syntax: /teleport home [source player] """ usage = 'Syntax: /teleport home [source player]' if not data: source = self.protocol.player.name else: source, rest = extract_name(data) if not self._validate_player(source): self.protocol.send_chat_message(usage) return source = source.lower() source_player = self.player_manager.get_logged_in_by_name(source) if source_player is None: self.logger.debug('Error: Player %s is not logged in.', source) self.protocol.send_chat_message( 'Error: Player {} is not logged in.'.format(source) ) return source_protocol = self.factory.protocols[source_player.protocol] teleport_packet = build_packet( Packets.PLAYER_WARP, player_warp_toalias_write(alias=2) ) source_protocol.client_protocol.transport.write(teleport_packet)
def connectionLost(self, reason=connectionDone): """ Called as a pseudo-destructor when the connection is lost. :param reason: The reason for the disconnection. :return: None """ try: if self.client_protocol is not None: x = build_packet(packets.Packets.CLIENT_DISCONNECT_REQUEST, packets.client_disconnect_request().build(Container(data=0))) if self.player is not None and self.player.logged_in: self.client_disconnect_request(x) self.client_protocol.transport.write(x) self.client_protocol.transport.abortConnection() except: logger.error("Couldn't disconnect protocol.") finally: try: self.factory.protocols.pop(self.id) except: logger.info("Protocol was not in factory list. This should not happen.") logger.info("protocol id: %s" % self.id) finally: logger.info("Lost connection from IP: %s", self.transport.getPeer().host) self.transport.abortConnection()
def poi(self, name): """Warps your ship to a Planet of Interest (PoI).\nSyntax: /poi [name] *omit name for a list of PoI's""" name = " ".join(name).strip().strip("\t") if len(name) == 0: warps = [] for warp in self.pois: if warps != "": warps.append(warp[1]) warpnames = "^green;, ^yellow;".join(warps) if warpnames == "": warpnames = "^gray;(none)^green;" self.protocol.send_chat_message(self.poi.__doc__) self.protocol.send_chat_message("List of PoI's: ^yellow;" + warpnames) return on_ship = self.protocol.player.on_ship if not on_ship: self.protocol.send_chat_message("You need to be on a ship!") return for warp in self.pois: if warp[1] == name: x, y, z, planet, satellite = warp[0].split(":") x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite)) warp_packet = build_packet(Packets.FLY_SHIP, fly_ship_write(x=x, y=y, z=z, planet=planet, satellite=satellite)) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message("Warp drive engaged! Warping to ^yellow;%s^green;." % name) return self.protocol.send_chat_message("There is no PoI named ^yellow;%s^green;." % name)
def warp_player_to_outpost(self, player_string): self.logger.debug( 'Warp player-to-outpost command called by %s: ' 'sending %s to the outpost', self.protocol.player.name, player_string ) player_to_send = self.player_manager.get_logged_in_by_name( player_string ) if player_to_send is not None: player_protocol = self.factory.protocols[player_to_send.protocol] warp_packet = build_packet( Packets.PLAYER_WARP, player_warp_toworld_write( world_type=WarpWorldType.UNIQUE_WORLD, destination='outpost' ) ) player_protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message( 'Warped ^yellow;{}^green; to the outpost.'.format( player_string ) ) else: self.protocol.send_chat_message( 'No player by the name ^yellow;{}^green; found.'.format( player_string ) ) self.protocol.send_chat_message(self.warp.__doc__)
def send_chat_message(self, text, channel=0, world='', name=''): """ Convenience function to send chat messages to the client. Note that this does *not* send messages to the server at large; broadcast should be used for messages to all clients, or manually constructed chat messages otherwise. :param text: Message text, may contain multiple lines. :param channel: The chat channel/context. 0 is global, 1 is planet. :param world: World :param name: The name to display before the message. Blank leaves no brackets, otherwise it will be displayed as `<name>`. :return: None """ logger.debug("Sent chat message with text: %s", text) if '\n' in text: lines = text.split('\n') for line in lines: self.send_chat_message(line) return chat_data = packets.chat_received().build(Container(chat_channel=channel, world=world, client_id=0, name=name, message=text)) chat_packet = build_packet(packets.Packets.CHAT_RECEIVED, chat_data) self.transport.write(chat_packet)
def warp_player_to_player(self, from_string, to_string): self.logger.debug( 'Warp player-to-player command called by %s: %s to %s', self.protocol.player.name, from_string, to_string ) from_player = self.player_manager.get_logged_in_by_name(from_string) to_player = self.player_manager.get_logged_in_by_name(to_string) if from_player is not None: if to_player is not None: from_protocol = self.factory.protocols[from_player.protocol] if from_player is not to_player: self.logger.debug('target: %s', to_player.uuid) warp_packet = build_packet( Packets.PLAYER_WARP, player_warp_toplayer_write(uuid=to_player.uuid) ) else: warp_packet = build_packet( Packets.PLAYER_WARP, player_warp_toalias_write(alias=WarpAliasType.SHIP) ) from_protocol.client_protocol.transport.write(warp_packet) if from_string != to_string: self.protocol.send_chat_message( 'Warped ^yellow;{}^green;' ' to ^yellow;{}^green;.'.format(from_string, to_string) ) else: self.protocol.send_chat_message( 'Warped to ^yellow;{}^green;.'.format(to_string) ) else: self.protocol.send_chat_message( 'No player by the name ^yellow;{}^green; found.'.format( to_string ) ) self.protocol.send_chat_message(self.warp.__doc__) return else: self.protocol.send_chat_message( 'No player by the name ^yellow;{}^green; found.'.format( to_player ) ) self.protocol.send_chat_message(self.warp.__doc__)
def disconnect(self): logger.vdebug('Client protocol disconnect called.') x = build_packet( packets.Packets.CLIENT_DISCONNECT_REQUEST, packets.client_disconnect_request().build(Container(data=0)) ) self.transport.write(x) self.transport.abortConnection() logger.vdebug('Client protocol disconnected.')
def on_chat_received(self, data): try: p = chat_received().parse(data.data) sender = self.player_manager.get_logged_in_by_name(p.name) p.name = sender.colored_name(self.config.colors) self.protocol.transport.write(build_packet(Packets.CHAT_RECEIVED, chat_received().build(p))) except AttributeError: self.protocol.transport.write(data.original_data) return False
def goto(self, name): """ Warps your ship to a previously bookmarked planet. Syntax: /goto [name] *omit name for a list of bookmarks """ filename = os.path.join( 'config', 'bookmarks', '{}.json'.format(self.protocol.player.uuid) ) try: with open(filename) as f: self.bookmarks = json.load(f) except: self.bookmarks = [] name = ' '.join(name).strip().strip('\t') if name: warps = [] for warp in self.bookmarks: if warp: warps.append(warp[1]) warpnames = '^green;,^yellow; '.join(warps) if warpnames == '': warpnames = '^gray;(none)^green;' self.protocol.send_chat_message(self.goto.__doc__) self.protocol.send_chat_message( 'Bookmarks: ^yellow;{}'.format(warpnames) ) return on_ship = self.protocol.player.on_ship if not on_ship: self.protocol.send_chat_message('You need to be on a ship!') return for warp in self.bookmarks: if warp[1] == name: x, y, z, planet, satellite = map(int, warp[0].split(':')) warp_packet = build_packet( Packets.FLY_SHIP, fly_ship_write( x=x, y=y, z=z, planet=planet, satellite=satellite ) ) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message( 'Warp drive engaged! Warping to ^yellow;{}^green;.'.format( name ) ) return self.protocol.send_chat_message( 'There is no bookmark named: ^yellow;%s'.format(name) )
def beam_to_planet(self, where): warp_packet = build_packet(Packets.WARP_COMMAND, warp_command_write(t="WARP_DOWN")) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message( "Beamed down to ^yellow;%s^green; and your ship will arrive soon." % where) self.factory.broadcast_planet( "%s^green; beamed down to the planet" % self.protocol.player.colored_name(self.config.colors), planet=self.protocol.player.planet)
def on_chat_received(self, data): try: p = chat_received().parse(data.data) if p.name == "server": return sender = self.player_manager.get_logged_in_by_name(p.name) p.name = sender.colored_name(self.config.colors) self.protocol.transport.write(build_packet(Packets.CHAT_RECEIVED, chat_received().build(p))) except AttributeError as e: self.logger.warning("Received AttributeError in colored_name. %s", str(e)) self.protocol.transport.write(data.original_data) return False
def reject_with_reason(self, reason): # here there be magic... ask Carrots or Teihoo about this... magic_sector = "AQAAAAwAAAAy+gofAAX14QD/Z2mAAJiWgAUFYWxwaGEMQWxwaGEgU2VjdG9yAAAAELIfhbMFQWxwaGEHAgt0aHJlYXRMZXZlbAYCBAIEAg51bmxvY2tlZEJpb21lcwYHBQRhcmlkBQZkZXNlcnQFBmZvcmVzdAUEc25vdwUEbW9vbgUGYmFycmVuBQ1hc3Rlcm9pZGZpZWxkBwcCaWQFBWFscGhhBG5hbWUFDEFscGhhIFNlY3RvcgpzZWN0b3JTZWVkBISWofyWZgxzZWN0b3JTeW1ib2wFFy9jZW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NsZXMFBnR1bmRyYQUIdm9sY2FuaWMFBmJhcnJlbgUNYXN0ZXJvaWRmaWVsZAcIAmlkBQdzZWN0b3J4BG5hbWUFCFggU2VjdG9yCnNlY3RvclNlZWQEmPDzkpxuDHNlY3RvclN5bWJvbAUXL2NlbGVzdGlhbC9zZWN0b3IveC5wbmcIaHVlU2hpZnQEgTQIcHZwRm9yY2UDAQZwcmVmaXgFAVgPd29ybGRQYXJhbWV0ZXJzBwILdGhyZWF0TGV2ZWwGAgQKBBQOdW5sb2NrZWRCaW9tZXMGDgUEYXJpZAUGZGVzZXJ0BQhzYXZhbm5haAUGZm9yZXN0BQRzbm93BQRtb29uBQZqdW5nbGUFCmdyYXNzbGFuZHMFBW1hZ21hBQl0ZW50YWNsZXMFBnR1bmRyYQUIdm9sY2FuaWMFBmJhcnJlbgUNYXN0ZXJvaWRmaWVsZA==" unlocked_sector_magic = base64.decodestring( magic_sector.encode("ascii")) rejection = build_packet( packets.Packets.CONNECT_RESPONSE, packets.connect_response().build( Container(success=False, client_id=0, reject_reason=reason)) + unlocked_sector_magic) self.protocol.transport.write(rejection) self.protocol.transport.loseConnection()
def warp_player_to_outpost(self, player_string): self.logger.debug("Warp player-to-outpost command called by %s: sending %s to the outpost", self.protocol.player.name, player_string) player_to_send = self.player_manager.get_logged_in_by_name(player_string) if player_to_send is not None: player_protocol = self.factory.protocols[player_to_send.protocol] warp_packet = build_packet(Packets.PLAYER_WARP, player_warp_write(t="WARP_TO", world_id="outpost")) player_protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message("Warped ^yellow;%s^green; to the outpost." % player_string) else: self.protocol.send_chat_message("No player by the name ^yellow;%s^green; found." % player_string) self.protocol.send_chat_message(self.warp.__doc__)
def reject_with_reason(self, reason): rejection = build_packet( packets.Packets.CONNECT_RESPONSE, packets.connect_response().build( Container( success=False, client_id=0, reject_reason=reason ) ) ) self.protocol.transport.write(rejection) self.protocol.transport.loseConnection()
def warp_player_to_player(self, from_string, to_string): self.logger.debug( 'Warp player-to-player command called by %s: %s to %s', self.protocol.player.name, from_string, to_string) from_player = self.player_manager.get_logged_in_by_name(from_string) to_player = self.player_manager.get_logged_in_by_name(to_string) if from_player is not None: if to_player is not None: from_protocol = self.factory.protocols[from_player.protocol] if from_player is not to_player: self.logger.debug('target: %s', to_player.uuid) warp_packet = build_packet( Packets.PLAYER_WARP, player_warp_toplayer_write(uuid=to_player.uuid)) else: warp_packet = build_packet( Packets.PLAYER_WARP, player_warp_toalias_write(alias=WarpAliasType.SHIP)) from_protocol.client_protocol.transport.write(warp_packet) if from_string != to_string: self.protocol.send_chat_message( 'Warped ^yellow;{}^green;' ' to ^yellow;{}^green;.'.format( from_string, to_string)) else: self.protocol.send_chat_message( 'Warped to ^yellow;{}^green;.'.format(to_string)) else: self.protocol.send_chat_message( 'No player by the name ^yellow;{}^green; found.'.format( to_string)) self.protocol.send_chat_message(self.warp.__doc__) return else: self.protocol.send_chat_message( 'No player by the name ^yellow;{}^green; found.'.format( to_player)) self.protocol.send_chat_message(self.warp.__doc__)
def reject_with_reason(self, reason): # here there be magic... ask Carrots or Teihoo about this... magic_sector = "AQAAAAwAAAAy+gofAAX14QD/Z2mAAJiWgAUFYWxwaGEMQWxwaGEgU2VjdG9yAAAAELIfhbMFQWxwaGEHAgt0aHJlYXRMZXZlbAYCBAIEAg51bmxvY2tlZEJpb21lcwYHBQRhcmlkBQZkZXNlcnQFBmZvcmVzdAUEc25vdwUEbW9vbgUGYmFycmVuBQ1hc3Rlcm9pZGZpZWxkBwcCaWQFBWFscGhhBG5hbWUFDEFscGhhIFNlY3RvcgpzZWN0b3JTZWVkBISWofyWZgxzZWN0b3JTeW1ib2wFFy9jZWxlc3RpYWwvc2VjdG9yLzEucG5nCGh1ZVNoaWZ0BDsGcHJlZml4BQVBbHBoYQ93b3JsZFBhcmFtZXRlcnMHAgt0aHJlYXRMZXZlbAYCBAIEAg51bmxvY2tlZEJpb21lcwYHBQRhcmlkBQZkZXNlcnQFBmZvcmV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zZWN0b3IveC5wbmcIaHVlU2hpZnQEgTQIcHZwRm9yY2UDAQZwcmVmaXgFAVgPd29ybGRQYXJhbWV0ZXJzBwILdGhyZWF0TGV2ZWwGAgQKBBQOdW5sb2NrZWRCaW9tZXMGDgUEYXJpZAUGZGVzZXJ0BQhzYXZhbm5haAUGZm9yZXN0BQRzbm93BQRtb29uBQZqdW5nbGUFCmdyYXNzbGFuZHMFBW1hZ21hBQl0ZW50YWNsZXMFBnR1bmRyYQUIdm9sY2FuaWMFBmJhcnJlbgUNYXN0ZXJvaWRmaWVsZA==" unlocked_sector_magic = base64.decodestring(magic_sector.encode("ascii")) rejection = build_packet( packets.Packets.CONNECT_FAILURE, packets.connect_failure().build( Container( reject_reason=reason ) ) + unlocked_sector_magic ) self.protocol.transport.write(rejection) self.protocol.transport.loseConnection()
def poi(self, name): """ Warps your ship to a Planet of Interest (PoI). Syntax: /poi [name] *omit name for a list of PoI's """ name = ' '.join(name).strip().strip('\t') if not name: warps = [warp[1] for warp in self.pois] warpnames = '^green;, ^yellow;'.join(warps) if not warpnames: warpnames = '^gray;(none)^green;' self.protocol.send_chat_message(self.poi.__doc__) self.protocol.send_chat_message( "List of PoI's: ^yellow;{}".format(warpnames) ) return on_ship = self.protocol.player.on_ship if not on_ship: self.protocol.send_chat_message('You need to be on a ship!') return for warp in self.pois: if warp[1] == name: x, y, z, planet, satellite = warp[0].split(':') x, y, z, planet, satellite = map( int, (x, y, z, planet, satellite) ) warp_packet = build_packet( Packets.FLY_SHIP, fly_ship_write( x=x, y=y, z=z, planet=planet, satellite=satellite ) ) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message( 'Warp drive engaged! Warping to ^yellow;{}^green;.'.format( name ) ) return self.protocol.send_chat_message( 'There is no PoI named ^yellow;{}^green;.', name )
def on_chat_received(self, data): try: p = chat_received().parse(data.data) if p.name == "server": return sender = self.player_manager.get_logged_in_by_name(p.name) p.name = sender.colored_name(self.config.colors) self.protocol.transport.write( build_packet(Packets.CHAT_RECEIVED, chat_received().build(p))) except AttributeError as e: self.logger.warning("Received AttributeError in colored_name. %s", str(e)) self.protocol.transport.write(data.original_data) return False
def connectionLost(self, reason=connectionDone): """ Called as a pseudo-destructor when the connection is lost. :param reason: The reason for the disconnection. :return: None """ try: logger.vdebug('Trying to disconnect protocol from factory') if self.client_protocol is not None: logger.vdebug('The client_protocol is not None') x = build_packet( packets.Packets.CLIENT_DISCONNECT_REQUEST, packets.client_disconnect_request().build( Container(data=0) ) ) logger.vdebug('Disconnect packet has been built') try: if self.player is not None and self.player.logged_in: logger.vdebug('Player not none and is still logged in') self.client_disconnect_request(x) logger.vdebug('Client disconnect requested') except: logger.error('Couldn\'t complete disconnect request.') finally: self.client_protocol.transport.write(x) logger.vdebug('Kill packet written to transport protocol') self.client_protocol.transport.abortConnection() logger.vdebug('connection aborted') self.player.logged_in = 0 logger.vdebug('Player status forced to logged_in=0') except: logger.error('Couldn\'t disconnect protocol.') finally: try: self.factory.protocols.pop(self.id) except: logger.warning( 'Protocol was not in factory list. This should not happen.' ) logger.info('protocol id: %s' % self.id) finally: logger.info( 'Lost connection from IP: %s', self.transport.getPeer().host ) logger.vdebug('Connection aborted') self.transport.abortConnection()
def on_chat_received(self, data): now = datetime.now() try: p = chat_received().parse(data.data) if p.name == "server": return sender = self.player_manager.get_by_org_name(str(p.name)) if self.config.chattimestamps: p.name = now.strftime("%H:%M") + "> <" + sender.colored_name(self.config.colors) else: p.name = sender.colored_name(self.config.colors) self.protocol.transport.write(build_packet(Packets.CHAT_RECEIVED, chat_received().build(p))) except AttributeError as e: self.logger.warning("Received AttributeError in colored_name. %s", str(e)) self.protocol.transport.write(data.original_data) return False
def teleport_to_player(self, data): """Teleports a player to another player's location. If no source player is provided, we assume you mean yourself.\nSyntax: /teleport [player] (destination player) [source player]""" usage = 'Syntax: /teleport [player] (destination player) [source player]' if not data: self.protocol.send_chat_message(self.teleport_to_player.__doc__) return destination, rest = extract_name(data) if not self._validate_player(destination): self.protocol.send_chat_message(usage) return destination = destination.lower() if not rest: source = self.protocol.player.name source = source.lower() else: source, rest = extract_name(rest) if not self._validate_player(source): self.protocol.send_chat_message(usage) return source = source.lower() if source == destination: self.logger.debug("Error: player is teleporting to self.") self.protocol.send_chat_message("Why are you trying to teleport to yourself? That seems illogical, captain.") return destination_player = self.player_manager.get_logged_in_by_name(destination) if destination_player is None: self.logger.debug("Error: Player %s is not logged in.", destination) self.protocol.send_chat_message("Error: Player %s is not logged in." % (destination, )) return source_player = self.player_manager.get_logged_in_by_name(source) if source_player is None: self.logger.debug("Error: Player %s is not logged in.", source) self.protocol.send_chat_message("Error: Player %s is not logged in." % (source, )) return source_protocol = self.factory.protocols[source_player.protocol] teleport_packet = build_packet(Packets.PLAYER_WARP, player_warp_toplayer_write(uuid=destination_player.uuid)) source_protocol.client_protocol.transport.write(teleport_packet) self.logger.debug("Teleport command called by %s. Teleporting %s to %s", self.protocol.player.name, source, destination) self.protocol.send_chat_message("Teleported ^yellow;%s^green; to ^yellow;%s^green;." % (source, destination))
def connectionLost(self, reason=connectionDone): """ Called as a pseudo-destructor when the connection is lost. :param reason: The reason for the disconnection. :return: None """ try: x = build_packet(packets.Packets.CLIENT_DISCONNECT, packets.client_disconnect().build(Container(data=0))) if self.player and self.player.logged_in: self.client_disconnect(x) self.client_protocol.transport.write(x) except: logger.error("Couldn't disconnect protocol.") finally: self.die()
def spawn(self, data): """Warps your ship to spawn.\nSyntax: /spawn""" for warp in self.pois: if warp[1] == 'spawn': x, y, z, planet, satellite = warp[0].split(":") x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite)) warp_packet = build_packet(Packets.FLY_SHIP, fly_ship_write(x=x, y=y, z=z, planet=planet, satellite=satellite)) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message("Warp drive engaged! Warping to ^yellow;%s^green;." % 'Spawn') return else: self.protocol.send_chat_message("The spawn planet must be set first!")
def goto(self, name): """Warps your ship to a previously bookmarked planet.\nSyntax: /goto [name] *omit name for a list of bookmarks""" filename = "./config/bookmarks/" + self.protocol.player.uuid + ".json" try: with open(filename) as f: self.bookmarks = json.load(f) except: self.bookmarks = [] name = " ".join(name).strip().strip("\t") if len(name) == 0: warps = [] for warp in self.bookmarks: if warps != "": warps.append(warp[1]) warpnames = "^green;,^yellow; ".join(warps) if warpnames == "": warpnames = "^gray;(none)^green;" self.protocol.send_chat_message(self.goto.__doc__) self.protocol.send_chat_message("Bookmarks: ^yellow;" + warpnames) return on_ship = self.protocol.player.on_ship if not on_ship: self.protocol.send_chat_message("You need to be on a ship!") return for warp in self.bookmarks: if warp[1] == name: sector, x, y, z, planet, satellite = warp[0].split(":") x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite)) warp_packet = build_packet( Packets.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, x=x, y=y, z=z, planet=planet, satellite=satellite)) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message( "Warp drive engaged! Warping to ^yellow;%s^green;." % name) return self.protocol.send_chat_message( "There is no bookmark named: ^yellow;%s" % name)
def reject_with_reason(self, reason): # here there be magic... ask Carrots or Teihoo about this... magic_sector = ( 'AQAAAAwAAAAy+gofAAX14QD/Z2mAAJiWgAUFYWxwaGEMQWxwaGEgU2VjdG9yAAAAE' 'LIfhbMFQWxwaGEHAgt0aHJlYXRMZXZlbAYCBAIEAg51bmxvY2tlZEJpb21lcwYHBQ' 'RhcmlkBQZkZXNlcnQFBmZvcmVzdAUEc25vdwUEbW9vbgUGYmFycmVuBQ1hc3Rlcm9' 'pZGZpZWxkBwcCaWQFBWFscGhhBG5hbWUFDEFscGhhIFNlY3RvcgpzZWN0b3JTZWVk' 'BISWofyWZgxzZWN0b3JTeW1ib2wFFy9jZWxlc3RpYWwvc2VjdG9yLzEucG5nCGh1Z' 'VNoaWZ0BDsGcHJlZml4BQVBbHBoYQ93b3JsZFBhcmFtZXRlcnMHAgt0aHJlYXRMZX' 'ZlbAYCBAIEAg51bmxvY2tlZEJpb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9ja2VkQmlvbW' 'VzBgoFBGFyaWQFBmRlc2VydAUIc2F2YW5uYWgFBmZvcmVzdAUEc25vdwUEbW9vbgU' 'GanVuZ2xlBQpncmFzc2xhbmRzBQZiYXJyZW4FDWFzdGVyb2lkZmllbGQFZGVsdGEM' 'RGVsdGEgU2VjdG9yAAAA1Ooj2GcFRGVsdGEHAgt0aHJlYXRMZXZlbAYCBAgECA51b' 'mxvY2tlZEJpb21lcwYOBQRhcmlkBQZkZXNlcnQFCHNhdmFubmFoBQZmb3Jlc3QFBH' 'Nub3cFBG1vb24FBmp1bmdsZQUKZ3Jhc3NsYW5kcwUFbWFnbWEFCXRlbnRhY2xlcwU' 'GdHVuZHJhBQh2b2xjYW5pYwUGYmFycmVuBQ1hc3Rlcm9pZGZpZWxkBwcCaWQFBWRl' 'bHRhBG5hbWUFDERlbHRhIFNlY3RvcgpzZWN0b3JTZWVkBLWdop7hTgxzZWN0b3JTe' 'W1ib2wFFy9jZWxlc3RpYWwvc2VjdG9yLzQucG5nCGh1ZVNoaWZ0BHgGcHJlZml4BQ' 'VEZWx0YQ93b3JsZFBhcmFtZXRlcnMHAgt0aHJlYXRMZXZlbAYCBAgECA51bmxvY2t' '==') unlocked_sector_magic = base64.decodestring( magic_sector.encode('ascii')) rejection = build_packet( packets.Packets.CONNECT_FAILURE, packets.connect_failure().build(Container(reject_reason=reason)) + unlocked_sector_magic) self.protocol.transport.write(rejection) self.protocol.transport.loseConnection()
def poi(self, name): """Moves you and your ship to a Planet of Interest (PoI). Syntax: /poi <PoI name> or /poi for list of PoI's""" name = " ".join(name).strip().strip("\t") if len(name) == 0: warps = [] for warp in self.planet_warps: if warps != "": warps.append(warp[1]) warpnames = "^shadow,green;, ^shadow,yellow;".join(warps) self.protocol.send_chat_message("List of PoI's: ^shadow,yellow;" + warpnames) return on_ship = self.protocol.player.on_ship if not on_ship: self.protocol.send_chat_message("You need to be on a ship!") return for warp in self.planet_warps: if warp[1] == name: sector, x, y, z, planet, satellite = warp[0].split(":") x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite)) warp_packet = build_packet( Packets.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, x=x, y=y, z=z, planet=planet, satellite=satellite)) self.protocol.client_protocol.transport.write(warp_packet) # warp_packet = build_packet(Packets.WARP_COMMAND, # warp_command_write(t="WARP_DOWN")) # self.protocol.client_protocol.transport.write(warp_packet) # self.protocol.send_chat_message("Beamed down to ^shadow,yellow;%s^shadow,green; and your ship will arrive soon." % name) self.protocol.send_chat_message( "Warp drive engaged! Warping to ^shadow,yellow;%s^shadow,green;." % name) return self.protocol.send_chat_message("There is no PoI with that name!")
def poi(self, name): """Warps your ship to a Planet of Interest (PoI).\nSyntax: /poi [name] *omit name for a list of PoI's""" name = " ".join(name).strip().strip("\t") if len(name) == 0: warps = [] for warp in self.pois: if warps != "": warps.append(warp[1]) warpnames = "^green;, ^yellow;".join(warps) if warpnames == "": warpnames = "^gray;(none)^green;" self.protocol.send_chat_message(self.poi.__doc__) self.protocol.send_chat_message("List of PoI's: ^yellow;" + warpnames) return on_ship = self.protocol.player.on_ship if not on_ship: self.protocol.send_chat_message("You need to be on a ship!") return for warp in self.pois: if warp[1] == name: sector, x, y, z, planet, satellite = warp[0].split(":") x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite)) warp_packet = build_packet( Packets.WARP_COMMAND, warp_command_write(t="MOVE_SHIP", sector=sector, x=x, y=y, z=z, planet=planet, satellite=satellite)) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message( "Warp drive engaged! Warping to ^yellow;%s^green;." % name) #reactor.callLater(1, self.beam_to_planet, name) # enable this for 1s delayed warping of a player return self.protocol.send_chat_message( "There is no PoI named ^yellow;%s^green;." % name)
def poi(self, name): """ Warps your ship to a Planet of Interest (PoI). Syntax: /poi [name] *omit name for a list of PoI's """ name = ' '.join(name).strip().strip('\t') if not name: warps = [warp[1] for warp in self.pois] warpnames = '^green;, ^yellow;'.join(warps) if not warpnames: warpnames = '^gray;(none)^green;' self.protocol.send_chat_message(self.poi.__doc__) self.protocol.send_chat_message( "List of PoI's: ^yellow;{}".format(warpnames)) return on_ship = self.protocol.player.on_ship if not on_ship: self.protocol.send_chat_message('You need to be on a ship!') return for warp in self.pois: if warp[1] == name: x, y, z, planet, satellite = warp[0].split(':') x, y, z, planet, satellite = map(int, (x, y, z, planet, satellite)) warp_packet = build_packet( Packets.FLY_SHIP, fly_ship_write(x=x, y=y, z=z, planet=planet, satellite=satellite)) self.protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message( 'Warp drive engaged! Warping to ^yellow;{}^green;.'.format( name)) return self.protocol.send_chat_message( 'There is no PoI named ^yellow;{}^green;.', name)
def warp_player_to_outpost(self, player_string): self.logger.debug( 'Warp player-to-outpost command called by %s: ' 'sending %s to the outpost', self.protocol.player.name, player_string) player_to_send = self.player_manager.get_logged_in_by_name( player_string) if player_to_send is not None: player_protocol = self.factory.protocols[player_to_send.protocol] warp_packet = build_packet( Packets.PLAYER_WARP, player_warp_toworld_write( world_type=WarpWorldType.UNIQUE_WORLD, destination='outpost')) player_protocol.client_protocol.transport.write(warp_packet) self.protocol.send_chat_message( 'Warped ^yellow;{}^green; to the outpost.'.format( player_string)) else: self.protocol.send_chat_message( 'No player by the name ^yellow;{}^green; found.'.format( player_string)) self.protocol.send_chat_message(self.warp.__doc__)
def teleport_to_player(self, data): """ Teleports a player to another player's location. If no source player is provided, we assume you mean yourself. Syntax: /teleport [player] (destination player) [source player] """ usage = ( 'Syntax: /teleport [player] (destination player) [source player]' ) if not data: self.protocol.send_chat_message(self.teleport_to_player.__doc__) return destination, rest = extract_name(data) if not self._validate_player(destination): self.protocol.send_chat_message(usage) return destination = destination.lower() if not rest: source = self.protocol.player.name source = source.lower() else: source, rest = extract_name(rest) if not self._validate_player(source): self.protocol.send_chat_message(usage) return source = source.lower() if source == destination: self.logger.debug('Error: player is teleporting to self.') self.protocol.send_chat_message( 'Why are you trying to teleport to yourself? ' 'That seems illogical, captain.' ) return destination_player = self.player_manager.get_logged_in_by_name( destination ) if destination_player is None: self.logger.debug( 'Error: Player %s is not logged in.', destination ) self.protocol.send_chat_message( 'Error: Player {} is not logged in.'.format(destination) ) return source_player = self.player_manager.get_logged_in_by_name(source) if source_player is None: self.logger.debug('Error: Player %s is not logged in.', source) self.protocol.send_chat_message( 'Error: Player {} is not logged in.'.format(source) ) return source_protocol = self.factory.protocols[source_player.protocol] teleport_packet = build_packet( Packets.PLAYER_WARP, player_warp_toplayer_write(uuid=destination_player.uuid) ) source_protocol.client_protocol.transport.write(teleport_packet) self.logger.debug( 'Teleport command called by %s. Teleporting %s to %s', self.protocol.player.name, source, destination ) self.protocol.send_chat_message( 'Teleported ^yellow;{}^green; to ^yellow;{}^green;.'.format( source, destination ) )
def teleport_to_ship(self, data): """ Teleports a player to another player's ship. If no source player is provided, we assume you mean yourself. Syntax: /teleport ship (destination player) [source player] """ usage = 'Syntax: /teleport ship (destination player) [source player]' if not data: self.protocol.send_chat_message(self.teleport_to_ship.__doc__) return destination, rest = extract_name(data) if not self._validate_player(destination): self.protocol.send_chat_message(usage) return destination = destination.lower() if not rest: source = self.protocol.player.name source = source.lower() else: source, rest = extract_name(rest) if not self._validate_player(source): self.protocol.send_chat_message(usage) return source = source.lower() if source == destination: self.teleport_to_own_ship(None) return destination_player = self.player_manager.get_logged_in_by_name( destination) if destination_player is None: self.logger.debug('Error: Player %s is not logged in.', destination) self.protocol.send_chat_message( 'Error: Player {} is not logged in.'.format(destination)) return source_player = self.player_manager.get_logged_in_by_name(source) if source_player is None: self.logger.debug('Error: Player %s is not logged in.', source) self.protocol.send_chat_message( 'Error: Player {} is not logged in.'.format(source)) return source_protocol = self.factory.protocols[source_player.protocol] teleport_packet = build_packet( Packets.PLAYER_WARP, player_warp_toplayerworld_write( destination=destination_player.uuid)) source_protocol.client_protocol.transport.write(teleport_packet) self.logger.debug( "Teleport command called by %s. Teleporting %s to %s's ship", self.protocol.player.name, source, destination) self.protocol.send_chat_message( "Teleported ^green;{}^yellow; to ^green;{}^yellow;'s ship.".format( source, destination))