def _new_player_gifter(self, connection): """ Helper routine for giving items to new players. :param connection: The connection we're showing the message to. :return: Null. """ yield from asyncio.sleep(2) for item, count in self.gifts.items(): count = int(count) if count > 10000 and item != "money": count = 10000 item_base = GiveItem.build(dict(name=item, count=count, variant_type=7, description="")) item_packet = pparser.build_packet(packets.packets["give_item"], item_base) yield from asyncio.sleep(0.1) yield from connection.raw_write(item_packet) send_message( connection, "You have been given {} {}".format(str(count), item), mode=ChatReceiveMode.COMMAND_RESULT ) return
def _new_player_gifter(self, connection): """ Helper routine for giving items to new players. :param connection: The connection we're showing the message to. :return: Null. """ yield from asyncio.sleep(2) for item, count in self.gifts.items(): count = int(count) if count > 10000 and item != "money": count = 10000 item_base = GiveItem.build( dict(name=item, count=count, variant_type=7, description="")) item_packet = pparser.build_packet(packets.packets['give_item'], item_base) yield from asyncio.sleep(.1) yield from connection.raw_write(item_packet) send_message(connection, "You have been given {} {}".format(str(count), item), mode=ChatReceiveMode.COMMAND_RESULT) return
def on_spawn_entity(self, data, connection): """ Catch when a player tries spawning an object in the world. :param data: The packet containing the action. :param connection: The connection from which the packet came. :return: Boolean, Varied. If the server generates the packet, let it pass. If planet is not protected, let it pass. If player is an Admin, let it pass. If player is list of builders, let it pass. Otherwise, block the packet from reaching the server. """ if not self.check_protection(connection.player.location): return True protection = self.get_protection(connection.player.location) if not protection.protected: return True if connection.player.check_role(Admin): return True elif protection.check_builder(connection.player): return True else: action = data["parsed"]["spawn_type"] if action not in [EntitySpawnType.OBJECT]: return True yield from self._protection_warn(data, connection) item_base = GiveItem.build( dict(name=data["parsed"]["payload"], count=1, variant_type=7, description="")) item_packet = pparser.build_packet(packets.packets['give_item'], item_base) yield from asyncio.sleep(.1) yield from connection.raw_write(item_packet) return False
def on_spawn_entity(self, data, connection): """ Catch when a player tries spawning an object in the world. :param data: The packet containing the action. :param connection: The connection from which the packet came. :return: Boolean, Varied. If the server generates the packet, let it pass. If planet is not protected, let it pass. If player is an Admin, let it pass. If player is list of builders, let it pass. Otherwise, block the packet from reaching the server. """ if not self.check_protection(connection.player.location): return True protection = self.get_protection(connection.player.location) if not protection.protected: return True if connection.player.check_role(Admin): return True elif connection.player.alias in protection.get_builders(): return True else: action = data["parsed"]["spawn_type"] if action not in [EntitySpawnType.OBJECT]: return True yield from self._protection_warn(data, connection) item_base = GiveItem.build(dict(name=data["parsed"]["payload"], count=1, variant_type=7, description="")) item_packet = pparser.build_packet(packets.packets['give_item'], item_base) yield from asyncio.sleep(.1) yield from connection.raw_write(item_packet) return False