def help_and_run(src): server, info = __get(src) line1 = f"{'='*10} 使用方法 {'='*10}" line2 = f"{cmdprefix} 查看方法和使用" line3 = f"{cmdprefix} store <number> 存储number瓶经验(7经验/瓶)" line4 = RText(f"{cmdprefix} store-all 存储全部经验", RColor.yellow) line5 = RText(f"{cmdprefix} store-30 存储多出30级的经验", RColor.yellow) xp_total = __get_xp_total(server, info.player) number_all, space_all = __store_space(xp_total) number_30, space_30 = __store_space(xp_total - LEVEL30TOTAL) line4.set_hover_text( RTextList("当前能存:", RText(f"{number_all}", RColor.green), "瓶(", RText(f"{space_all}", RColor.blue), ")格")) if number_all > 0: line4.set_click_event(RAction.run_command, f"{cmdprefix} store {number_all}") line5.set_hover_text( RTextList("当前能存:", RText(f"{number_30}", RColor.green), "瓶(", RText(f"{space_30}", RColor.blue), ")格")) if number_30 > 0: line5.set_click_event(RAction.run_command, f"{cmdprefix} store {number_30}") server.reply(info, "\n".join([line1, line2, line3])) server.reply(info, RTextList(line4, "\n", line5))
def click_text(player, label_name, world, x, y, z): #r = RText(label_name, RColor.blue) r = RText(label_name, RColor.yellow) r.set_hover_text(RText(f"点击传送[{x}, {y}, {z}]", RColor.green)) # r.set_click_event(RAction.run_command, f"/execute at {player} in {world} run teleport {player} {x} {y} {z}") r.set_click_event(RAction.run_command, f"{CMD} {label_name}") return r
def welcome(server, player): msg = [ RText("=" * 10 + "嗨~!" + "=" * 10 + "\n\n"), RText(f"欢迎! {player} !\n\n", RColor.yellow), ] r = RText(">>> 点击这里,查看可用命令 <<<", RColor.green) r.set_hover_text("!!help") r.set_click_event(RAction.run_command, f"!!help") msg.append(r) server.tell(player, RTextList(*msg))
def help_and_run(src): server, info = __get(src) line1 = f"{'='*10} 使用方法 {'='*10}" line2 = f"{CMD} 查看方法和使用" line3 = f"{CMD} <number> 购买number个不死图腾(7绿宝石/个)" line4 = RText(f"{CMD} all 使用背包全部的绿宝石购买", RColor.yellow) total = emerald(server, info.player) number_all, _ = divmod(total, UNIT_PRICE) line4.set_hover_text( RTextList("当前能购买:", RText(f"{number_all}", RColor.green), "/个")) if number_all > 0: line4.set_click_event(RAction.run_command, f"{CMD} {number_all}") else: server.reply(info, RText("你当前背包绿宝石不够", RColor.red)) server.reply(info, "\n".join([line1, line2, line3])) server.reply(info, RTextList(line4))
def game_start(self, gameid): # 点我unready unready = RText("秒钟后游戏开始, 请不要中途退出。", RColor.yellow) unready.set_hover_text(RText("点我unready", RColor.green)) unready.set_click_event(RAction.run_command, f"unready") # 10秒后游戏开始 self.countdowning = True for i in range(10, 0, -1): # 如果有玩家 unready 取消开局 if not self.countdowning: self.server.say(RText("取消开局,有玩家unready。", RColor.yellow)) return self.server.say(RTextList(RText(f"{i} ", RColor.green), unready)) time.sleep(1) # 开局前准备 self.game_start_init() self.game_started = True # 每局开始时,第一次提示. first_show = True # sleep = 30 # testing sleep = 5 * 60 # 如果 逃亡者存活过30分钟,逃亡者胜利。 for i in range(6): if self.gameid != gameid: self.server.logger.info(f"之前的游戏线程退出 gameid: {self.gameid}.") return now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # 广播逃亡者位置,并高亮1分钟。 self.running_x, self.running_y, self.running_z = get_pos_point( self.server, self.player_running) self.server.say( RTextList( "逃亡者:", RText(self.player_running, RColor.yellow), "现在的位置是:", RText( f"x:{self.running_x} y:{self.running_y} z:{self.running_z} ", RColor.green), RText(f"{now}", RColor.green))) self.server.rcon_query( f"effect give {self.player_running} minecraft:glowing 60") # 向他杀者显示, 逃亡者坐标。 if first_show: first_show = False for killer in self.killer: flow_thread(self.server, 60, killer, self.player_running) time.sleep(5) # self.show_running_location() time.sleep(sleep - 5) else: for killer in self.killer: flow_thread(self.server, 60, killer, self.player_running) # self.show_running_location() time.sleep(sleep) # 时间到,逃亡者胜利。 self.game_end("running")
def click_text(player, label_name, world, x, y, z): r = RText(label_name, RColor.yellow) r.set_hover_text(RText(f"区块位置: {world} --> [{x}, {z}]", RColor.green)) # r.set_click_event(RAction.run_command, f"{CMD} {label_name}") return r
def click_invite(player1, player2): r = RText(f"{player1} 邀请你tp TA.", RColor.green) r.set_hover_text(RText(f"点击向玩家 {player1} 传送", RColor.green)) r.set_click_event(RAction.run_command, f"{CMD} accept {player1}") return r