def get_players(self): try: with Client(self.config.ip, self.config.port) as client: client.login(self.config.password) return client.players except Exception: self.log.exception('Failed to query minecraft RCON: ')
async def rcon(self, ctx: commands.Context, *, command: str): log.info('RCON: \'{}\''.format(command)) with Client(Config.mc_server_host, Config.rcon_port) as rcon: rcon.login(Config.rcon_password) resp: str = rcon.run(command) log.info('Response from RCON: \'{}\''.format(resp)) if resp: await ctx.send(resp)
def unlock_quests(quests: Dict[int, Set[str]]): affected_players = set() with Client(Config.mc_server_host, Config.rcon_port) as c: c.login(Config.rcon_password) for quest_id, players in quests.items(): for player in players: affected_players.add(player) c.run('bq_admin', 'complete', str(quest_id), player) for player in affected_players: c.run('execute', player, '~', '~', '~', 'bq_user', 'refresh')
def check(): ip = mystring1.get() port = mystring2.get() with Client(ip, port) as client: password = open("pass.txt", "r") for i in password: try: i2 = i.replace("\n", "") client.login(i2) logs.insert("insert", "Connect: " + i) mb.showinfo("Done!", "Password is: " + i) break except: logs.insert("insert", "Error: " + i)
async def __send_to_mc(self, message: discord.Message): if self.__should_not_send_to_mc(message): return try: with Client(Config.mc_server_host, Config.rcon_port) as rcon: rcon.login(Config.rcon_password) msg_obj: Any = _create_chat_msg_obj(message.author, message.clean_content) msg: str = json.dumps(msg_obj) log.info('Sending RCON tellraw message: {}'.format(msg)) resp: str = rcon.run('tellraw', '@a', msg) if resp: log.info('Response from RCON: {}'.format(resp)) except Exception as e: log.error('Error while sending RCON message: {}: {}'.format( message.author, message.clean_content)) for tb_line in ''.join( traceback.format_exception(type(e), e, e.__traceback__)).splitlines(): log.error(tb_line)
async def team(self, ctx, username: str = None, team: str = None): if username is None: await ctx.send(":x: , Username is required") return if team is None: await ctx.send(":x: , team is required") return team = team.lower() try: perms = t[team] except KeyError: await ctx.send(":x: , No Such Team!") return try: with Client('play.olympusmc.ml', 2003) as c: c.login(pwsd) c.run(f'lp user {username} set permission {perms}') await ctx.send( f":white_check_mark: , Player {username} has been added to Team {team}" ) except Exception as e: await ctx.send(":x: , An Error occured")
Get directions pointing the "same" way as self.direction """ dot_products = np.matmul(self.box, self.direction) return self.box[[True if dp > 0 else False for dp in dot_products]] def hemisphere(radius: float) -> np.array: box = generate_box(int(radius)) return box[[ True if r[1] >= 0 and np.linalg.norm(r) <= radius else False for r in box ]] if __name__ == '__main__': start = np.array((-147, 59, 194)) end = np.array((-218, 59, 205)) lp = LatticePath(start, end) lattice_iter = iter(lp) H = hemisphere(2.5) with Client(credentials.hostname, credentials.port) as client: client.login(credentials.password) for point in lattice_iter: for h in H: client.run( 'setblock', f'{point[0] + h[0]} {point[1] + h[1]} {point[2] + h[2]} air' ) sleep(1.5)
from time import sleep from mcipc.rcon import Client with Client('localhost', 25575) as client: client.login('hurra') # client.say('Hej med jer') # r = client.run('setblock', '-88 72 84 iron_block') x_offset, y_offset, z_offset = -224, 68, 263 h = 20 for y in range(h): for x in range(y, 2 * h - 1 - y): for z in range(y, 2 * h - 1 - y): r = client.run( 'setblock', f'{x_offset + x} {y_offset + y} {z_offset + z} sandstone') sleep(0.01)