def flow_stop(src, ctx): server, info = __get(src) if PLAYERS.get(info.player): server.reply(info, RText(f"停止flow", RColor.yellow)) PLAYERS.pop(info.player) else: server.reply(info, RText(f"没有使用flow", RColor.yellow))
def store(src, ctx): server, info = __get(src) number = int(ctx.get("number")) if number <= 0: server.reply(info, RText("不能这样存储经验", RColor.red)) return xp_total = __get_xp_total(server, info.player) server.logger.debug(f"玩家 {info.player} 当前总经验 {xp_total}") number_all, _ = __store_space(xp_total) if number_all < number: server.reply(info, RText(f"当前最多只能存储{number_all}瓶", RColor.red)) else: reduce_xp = number * EXPERIENCE_BOTTLE server.rcon_query( f"execute at {info.player} run experience add {info.player} -{reduce_xp} points" ) server.rcon_query( f"execute at {info.player} run give {info.player} minecraft:experience_bottle {number}" )
def accept(src, ctx): server, info = __get(src) accept_player = ctx["player"] # 对方是否在线 if player_online(server, accept_player): # 查看邀请信息 k = accept_player + "_" + info.player t = int(time.time()) - INVITE.get(k, 0) if t < 180: server.rcon_query( f"execute at {info.player} run teleport {info.player} {accept_player}" ) server.rcon_query( f"execute at {info.player} run playsound minecraft:item.chorus_fruit.teleport player {info.player}" ) else: server.reply(info, RText("玩家没有邀请你或邀请已超过3分钟", RColor.yellow)) #playsound(server, info.player) pop_invite(k) else: server.reply( info, RTextList("玩家 ", RText(f"{accept_player}", RColor.red), " 不在线"))
def invite(src, ctx): server, info = __get(src) invite_player = ctx["player"] if invite_player == info.player: server.reply(info, RText("不能向你自已发送邀请", RColor.red)) return # 邀请的玩家是否在线 if player_online(server, invite_player): if check_level(server, info): # 查看邀请信息 k = info.player + "_" + invite_player v = int(time.time()) INVITE[k] = v server.tell(invite_player, click_invite(info.player, invite_player)) server.reply( info, RTextList("向玩家 ", RText(f"{invite_player}", RColor.yellow), " 发送tp邀请")) playsound(server, info.player) else: server.reply( info, RTextList("玩家 ", RText(f"{invite_player}", RColor.red), " 不在线"))
def remove(src, ctx): server, info = __get(src) u = USERTP.get(info.player) if u is None: server.tell(info.player, RText(f"当前没有收藏点.", RColor.red)) else: label_name = ctx.get("label_name") label = u.get(label_name) if label is None: server.reply( info, RTextList(RText("没有 "), RText(label_name, RColor.yellow), RText(" 收藏点"))) return u.pop(label_name) player_save(info.player, u) server.reply( info, RTextList("地点: ", RText(label_name, RColor.yellow, RStyle.strikethrough), " 删除成功")) playsound(server, info.player) server.logger.debug(f"remove ctx -------------->\n{ctx}")
def add(src, ctx): server, info = __get(src) # 查看玩家的等级够不够 if not check_level(server, info): server.reply(info, RText(f"当前等级不足,至少需要1级。", RColor.red)) return # 查询坐标 rcon_result = server.rcon_query(f"data get entity {info.player} Pos") position = re.search( f"{info.player} has the following entity data: \[(-?[0-9\.]+)d, (-?[0-9.]+)d, (-?[0-9.]+)d\]", rcon_result) x, y, z = position.group(1), position.group(2), position.group(3) x, y, z = round(float(x)), round(float(y)), round(float(z)) rcon_result = server.rcon_query(f"forceload add {x} {z}") load = re.match( f"Marked chunk \[(-?[0-9]+), (-?[0-9]+)\] in (.*) to be force loaded", rcon_result) if load is None: check = re.match("No chunks were marked for force loading", rcon_result) server.logger.error(f"{rcon_result=}") if check is None: server.reply(info, RText(f"未知错误,请报告服主。", RColor.red)) server.logger.error(f"{check=}") else: server.reply(info, RText(f"当前区块已经强制加载!(可能是其他人加载)", RColor.yellow)) else: # world = load.group(3) label_name = ctx["label_name"] u = player_load(info.player) u[label_name] = {"world": world, "x": x, "y": y, "z": z} server.tell( info.player, RTextList("强制加载区块: ", RText(label_name, RColor.yellow), " 添加成功")) player_save(info.player, u) if len(u) > PLAYER_MAX_BLOCK: server.reply( info, RText(f"强制加载区块已到最大数: {PLAYER_MAX_BLOCK} 请删除后添加", RColor.red)) return server.logger.debug(f"add ctx -------------->\n{ctx}")
def manual_backup_lock(server, msg): if backing.locked(): server.say(RText("备份的太频繁... 等会吧", RColor.red)) else: server.say(RText("手动触发备份存档 ...")) with backing: bi = BackInfo(server) bi.autobackup(msg) # 每次备份后,需要reset 自动备份计时器(B.value) B.value = 0
def flow_cmd(src, ctx): server, info = __get(src) player2 = ctx.get("player") if info.player == player2: server.reply(info, RText(f"你不需要flow你自己", RColor.red)) else: if PLAYERS.get(info.player): server.reply(info, RText(f"不用重复开flow功能", RColor.red)) else: PLAYERS[info.player] = player2 server.reply(info, RText(f"开始flow {player2}", RColor.yellow)) flow_thread(server, info.player, player2)
def rollback_lock(server, number): if backing.locked(): server.say(RText("有备份在进行中... 等会吧", RColor.red)) else: server.say(RText(f"回滚备份存档 ... {number}", RColor.yellow)) with backing: bi = BackInfo(server) bi.rollback(number) # 每次备份后,需要reset 自动备份计时器(B.value) B.value = 0
def add_health_thread(server, player, number): # copy 一份 FOOD food_local = copy.deepcopy(FOOD) server.logger.info(f"{player} 自动回血技能启动。") server.tell(player, RText(f"自动回血技能启动", RColor.yellow)) # 拿到玩家当前的最大血量 result = server.rcon_query( f"attribute {player} minecraft:generic.max_health base get") re_match = re.match( f"Base value of attribute Max Health for entity {player} is (.*)", result) max_health = float(re_match.group(1)) global EXIT while EXIT: #calllivecn has the following entity data: 20.0f text = server.rcon_query(f"data get entity {player} Health") result = re.match(f"""{player} has the following entity data: (.*)f""", text) health = float(result.group(1)) cmp = health / max_health if cmp <= number: index = check_food(server, player, food_local) food, v = food_local[0] if index: server.rcon_query(f"clear {player} {food} {v}") # result = server.rcon_query(f"clear {player} {food} {v}") # if re.match(f"No items were found on player {player}", result): # /effect give calllivecn minecraft:regeneration 1 3 true # 状态效果等级是从0开始的 server.rcon_query( f"effect give {player} minecraft:instant_health 1 0 true") # server.rcon_query(f"effect give {player} minecraft:regeneration 1 3 true") 不行,太慢 time.sleep(0.1) else: server.tell(player, RText(f"背包当前食物不够了!!!", RColor.red)) EXIT = False else: time.sleep(Interval) server.logger.info(f"{player} 自动回血技能结束。") server.tell(player, RText(f"自动回血技能结束。", RColor.yellow))
def add(src, ctx): server, info = __get(src) # 查询世界 rcon_result = server.rcon_query(f"data get entity {info.player} Dimension") if rcon_result is None: prompt = RText("rcon 没有开启, 请分别server.properties, MCDR/config.yml 开启。", RColor.red) server.logger.warning(prompt) server.tell(info.player, RText(f"{CMD} 插件没有配置成功,请联系服主。", RColor.red)) world = re.match( '{} has the following entity data: "(.*)"'.format(info.player), rcon_result).group(1) # 查询坐标 rcon_result = server.rcon_query(f"data get entity {info.player} Pos") position = re.search( f"{info.player} has the following entity data: \[(-?[0-9\.]+)d, (-?[0-9.]+)d, (-?[0-9.]+)d\]", rcon_result) x, y, z = position.group(1), position.group(2), position.group(3) x, y, z = round(float(x), 1), round(float(y), 1), round(float(z), 1) u = USERTP.get(info.player) if u is None: u = {} USERTP[info.player] = u elif len(u) > PLAYER_MAX_POINT: server.reply(info, RText(f"收藏点已到最大数: {PLAYER_MAX_POINT} 请删除后添加", RColor.red)) return # 查看玩家的等级够不够 if check_level(server, info): label_name = ctx["label_name"] u[label_name] = {"world": world, "x": x, "y": y, "z": z} server.tell( info.player, RTextList("地点: ", RText(label_name, RColor.yellow), " 收藏成功")) playsound(server, info.player) player_save(info.player, u) server.logger.debug(f"add ctx -------------->\n{ctx}")
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 timing(server, player): # time.sleep(10) # 测试 # 留出10秒,给倒计时。 time.sleep(SOUL_TIME - 10) rcon_result = server.rcon_query(f"data get entity {player} playerGameType") result = re.match(f"{player} has the following entity data: ([0-9]+)", rcon_result) # 如果玩家退出 if result is None: return gamemode = result.group(1) if gamemode == "3": pass else: return server.tell(player, RText(f"10秒后,返回身体.", RColor.green)) time.sleep(5) for i in range(5, 0, -1): server.tell(player, RText(f"{i}秒后,返回身体.", RColor.green)) time.sleep(1) player_soul = get_soul_info(player) if player_soul: world = player_soul["world"] x = player_soul["x"] y = player_soul["y"] z = player_soul["z"] server.rcon_query( f"execute at {player} in {world} run teleport {player} {x} {y} {z}" ) server.rcon_query( f"execute at {player} run gamemode survival {player}") else: server.tell(player, RText("出了点问题,请联系管理员。", RColor.red)) server.logger.warning(f"玩家 {player} 被卡在灵魂模式了。。。")
def rollback(self, number): tm = self.backup_list[number]["timestamp"] msg = self.backup_list[number]["msg"] if msg == "": self.server.say(RText(f"服务器30s 后回滚到:{tm}", RColor.green)) else: self.server.say(RText(f"服务器30s 后回滚到:{tm} 注释: {msg}", RColor.green)) time.sleep(25) for i in range(5, 1, -1): if msg == "": self.server.say(RText(f"服务器{i}s 后回滚到:{tm}", RColor.green)) else: self.server.say( RText(f"服务器{i}s 后回滚到:{tm} 注释: {msg}", RColor.green)) if self.server.is_server_running(): self.server.logger.info("关闭服务器中...") self.server.stop() self.server.wait_for_start() self.server.logger.info("等待服务器,关闭后,执行回滚.") else: self.server.logger.info("服务器没有运行") return rollback_dir = BACKUP_DIR / "rollback" if rollback_dir.exists(): shutil.rmtree(str(rollback_dir)) try: shutil.move(str(WORLD_DIR), str(rollback_dir)) backup2current(str(BACKUP_DIR / f"bak-{number}"), str(WORLD_DIR)) except Exception as e: raise e # 更新 BackInfo self.rollback_last["timestamp"] = time.strftime("%Y-%m-%d_%H:%M:%S") self.rollback_last["msg"] = msg self.__write() self.server.start()
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 rename(src, ctx): server, info = __get(src) u = player_load(info.player) if u == {}: server.tell(info.player, RText(f"当前没有强制加载区块.", RColor.red)) else: label_name = ctx["label_name"] label = u.get(label_name) if label is None: server.reply(info, RText(f"没有 {label_name} 强制加载区块", RColor.red)) else: if check_level(server, info): v = u.pop(label_name) u[ctx["label_name2"]] = v player_save(info.player, u) server.reply(info, RText("修改名称成功", RColor.green)) server.logger.debug(f"rename ctx -------------->\n{ctx}")
def rename(src, ctx): server, info = __get(src) if USERTP.get(info.player) is None: server.tell(info.player, RText(f"当前没有收藏点.", RColor.red)) else: u = USERTP.get(info.player) label_name = ctx["label_name"] label = u.get(label_name) if label is None: server.reply(info, RText(f"没有 {label_name} 收藏点", RColor.red)) else: if check_level(server, info): v = u.pop(label_name) u[ctx["label_name2"]] = v player_save(info.player, u) playsound(server, info.player) server.reply(info, RText("修改名称成功", RColor.green)) server.logger.debug(f"rename ctx -------------->\n{ctx}")
def condition(server, info): soul_player = SOUL_DIR / (info.player + ".json") if soul_player.exists(): return True else: result = server.rcon_query(f"experience query {info.player} levels") level = int( re.search(f"{info.player} has ([0-9]+) experience levels", result).group(1)) if level < 30: server.reply(info, RText("等你到一定等级了在来找我吧!", RColor.green)) return False else: server.rcon_query( f"execute at {info.player} run experience add {info.player} -30 levels" ) server.rcon_query( f"execute at {info.player} run playsound minecraft:entity.player.levelup player {info.player}" ) server.reply(info, RText("你现在已经学习会了~", RColor.green)) set_soul_info(info.player, {"timestamp": timestamp()}) return True
def rollback(src, ctx): server = src.get_server() info = src.get_info() number = int(ctx.get("number")) server.reply(info, f"{number}") bi = BackInfo(server) ls = bi.list() ls_len = len(ls) if 0 > number or number > ls_len - 1: server.reply(info, RText(f"回滚号,只能在 0-{ls_len - 1} 范围", RColor.red)) return rollback_lock(server, number)
def check_level(server, info): # 查看玩家的等级够不够 level = server.rcon_query(f"experience query {info.player} levels") l = re.match(f"{info.player} has ([0-9]+) experience levels", level).group(1) server.logger.debug(f"玩家 {info.player} 等级: {l}") if int(l) < 10: server.reply(info, RText("经验不足,至少需要10级", RColor.red)) return False else: # 扣掉1级 server.rcon_query(f"experience add {info.player} -1 levels") return True
def shopping(src, ctx): server, info = __get(src) number = int(ctx.get("number")) emerald_total = emerald(server, info.player) number_all, _ = divmod(emerald_total, UNIT_PRICE) if number > number_all: server.reply(info, RText(f"当前最多只能买{number_all}个", RColor.red)) else: reduce_emerald = number * UNIT_PRICE server.rcon_query( f"execute at {info.player} run clear {info.player} minecraft:emerald {reduce_emerald}" ) server.rcon_query( f"execute at {info.player} run give {info.player} minecraft:totem_of_undying {number}" )
def ready(self, player): # 如果已经开始游戏,跳过 if self.game_started: self.server.tell(player, RText(f"游戏已经开始,等待下一局.")) else: self.readys.add(player) # debug self.server.logger.info( f"ready(self, {player}) self.players --> {self.players} --> readys: {self.readys}" ) if self.players == self.readys and len(self.players) > 1: if not self.game_started: self.gameid = time.monotonic() self.game_start(self.gameid) self.server.logger.info("游戏线程启动完成。") else: # check 玩家人数,够不够开局 self.server.say(f"还有人没有准备,或人数不够(至少需要2名玩家)。")
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 autobackup(self, msg=""): self.server.say( RTextList(RText("开始备份存档: "), RText(f"{self.cur_timestamp} ", RColor.yellow), RText("..."))) t1 = time.time() # save-off self.server.rcon_query("save-off") # server.rcon_query("save-all flush") result = self.server.rcon_query("save-all") if re.findall("Saved the game", result): # self.server.say("拿到 `Saved the game` 结果") pass else: # self.server.say(RText("服务器可能 过于卡顿 备份失败。。。", RColor.red)) # self.server.say(RText(f"没拿到 `Saved the game` 拿到的是{result}", RColor.red)) return try: backup2current(str(WORLD_DIR), str(BACKUP_DIR / "bak-0")) except Exception as e: self.server.say(RText("插件内部错误。。。", RColor.red)) raise e self.server.rcon_query("save-on") t2 = time.time() self.server.say( RTextList(RText("备份存档: "), RText(f"{self.cur_timestamp}", RColor.yellow), RText(" 完成 "), RText(f"耗时:{round(t2-t1, 2)}s", RColor.yellow))) # 更新存档信息 self.__update(msg)
def remove(src, ctx): server, info = __get(src) u = player_load(info.player) if u == {}: server.tell(info.player, RText(f"当前没有强制加载区块.", RColor.red)) else: label_name = ctx.get("label_name") label = u.get(label_name) if label is None: server.reply( info, RTextList(RText("没有 "), RText(label_name, RColor.yellow), RText("强制加载区块"))) return position = u.pop(label_name) world = position["world"] x, z = position["x"], position["z"] # rcon_result = server.rcon_query( f"execute in {world} run forceload remove {x} {z}") unload = re.match( f"Unmarked chunk \[(-?[0-9]+), (-?[0-9]+)\] in (.*) for force loading", rcon_result) if unload is None: server.reply(info, RText(f"未知错误,请报告服主。", RColor.red)) server.logger.error(f"{rcon_result=}") else: player_save(info.player, u) server.reply( info, RTextList( "强制加载区块: ", RText(label_name, RColor.yellow, RStyle.strikethrough), " 删除成功")) server.logger.debug(f"remove ctx -------------->\n{ctx}")
def ls(src, ctx): server, info = __get(src) u = USERTP.get(info.player) msg = [ f"{'='*10} 当前没有收藏点, 快使用下面命令收藏一个吧。 {'='*10}", f"{CMD} add <收藏点名>", ] if u is None: server.reply(info, "\n".join(msg)) else: msg1 = [RText(f"{'='*10} 收藏点 {'='*10}\n", RColor.white)] msg2 = [] for label_name, data in u.items(): msg2.append( click_text(info.player, label_name, data["world"], data["x"], data["y"], data["z"])) msg = msg1 + fmt(msg2) server.reply(info, RTextList(*msg)) server.logger.debug(f"list ctx -------------->\n{ctx}")
def ls(src, ctx): server, info = __get(src) u = player_load(info.player) msg = [ f"{'='*10} 当前没有强制加载区块, 快使用下面命令添加一个吧。 {'='*10}", f"{CMD} add <名字>", ] if u == {}: server.reply(info, "\n".join(msg)) else: msg1 = [RText(f"{'='*10} 强制加载区块 {'='*10}\n", RColor.white)] msg2 = [] for label_name, data in u.items(): msg2.append( click_text(info.player, label_name, data["world"], data["x"], data["y"], data["z"])) msg = msg1 + fmt(msg2) server.reply(info, RTextList(*msg)) server.logger.debug(f"list ctx -------------->\n{ctx}")
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 game_start_init(self): # 做一些,开局前的准备; # 在每次开局前做? # 选出一个逃亡者 self.player_running = random.choice(list(self.players)) # 剩下的是killer p = self.players.copy() p.discard(self.player_running) self.killer = list(p) # 给逃亡者上tag, 结束时要取消掉 self.server.rcon_query(f"tag {self.player_running} add running") # 清除玩家成就 # self.server.rcon_query(f"advancement revoke @a everything") # 清空玩家物品 self.server.rcon_query(f"clear @a") # 清除玩家使用床等物品,的记录点, java 版并不行。 # self.server.rcon_query(f"clearspawnpoint @a") # 清空玩家效果 self.server.rcon_query(f"effect clear @a") # 清空玩家等级 self.server.rcon_query(f"experience set @a 0 levels") self.server.rcon_query(f"experience set @a 0 points") # 玩家生命恢复 # self.server.rcon_query(f"effect give @a minecraft:instant_health 1 20 true") self.server.rcon_query( f"effect give @a minecraft:instant_health 1 4 true") # 恢复饱食度 self.server.rcon_query( f"effect give @a minecraft:saturation 1 20 true") # 设置白天 self.server.rcon_query(f"time set day") # 先要扩大边界 29999984 , worldborder 需要小于三千万 self.server.rcon_query(f"worldborder set 29999984") # self.server.say("先扩大世界边界") # 拿到当前位置 self.x, self.y, self.z = get_pos_point(self.server, self.player_running) # 调换世界生出点 self.x += 2000 # spreadplayers <x> <z> <分散间距> <最大范围> [under 最大高度] <考虑队伍> <传送目标…> self.server.say(RText("寻找新一局初生点...", RColor.yellow)) # 召唤一个看不见的小盔甲架,名字为随机。 armor_name = random.randint(10000, 99999) self.server.rcon_query( f'''execute @r run summon minecraft:armor_stand ~ ~ ~ {{Small:1,Invisible:1,CustomName:'{{"text":"{armor_name}"}}'}}''' ) while True: # result = self.server.rcon_query(f"spreadplayers {self.x} {self.z} 15 30 false @a") # result = self.server.rcon_query(f"spreadplayers {self.x} {self.z} 50 60 false @a") self.server.say(RText("寻找新一局初生点...", RColor.yellow)) result = self.server.rcon_query( f"""execute as @e[type=minecraft:armor_stand,nbt={{CustomName:'{{"text":"{armor_name}"}}'}}] run spreadplayers {self.x} {self.z} 50 60 false @s""" ) if re.match( "Could not spread ([0-9]+) entities around (.*) \(too many entities for space - try using spread of at most ([0-9\.]+)\)", result): self.z += 500 else: break time.sleep(1) self.server.logger.info(result) # 输送玩家过去 self.server.rcon_query( f"spreadplayers {self.x} {self.z} 50 60 false @a") # 去掉生成的盔甲架 self.server.rcon_query( f"""kill @e[type=minecraft:armor_stand,nbt={{CustomName:'{{"text":"{armor_name}"}}'}}]""" ) # 设置世界中心和边界 self.server.rcon_query(f"worldborder center {self.x} {self.z}") self.server.rcon_query(f"worldborder set 2000") # 给每个玩家设置出生点,还有设置新的世界初生点。 self.setworldspawn() # 玩家死亡后立刻重生到新的地点 # self.server.rcon_query(f"gamerule doImmediateRespawn true") # self.server.rcon_query(f"kill @a") # self.server.rcon_query(f"gamerule doImmediateRespawn false") # 开启玩家之间 PVP self.server.rcon_query(f"team empty {self.teamname}") # self.server.rcon_query(f"gamemode survival @a") # 用 title 提示玩家游戏开始。 # self.server.rcon_query("execute at @a run playsound minecraft:item.totem.use player @a") self.server.rcon_query("title @a times 1 100 1") self.server.rcon_query( """title @a subtitle {{"text":"逃亡者是:{self.player_running}", "bold": true, "color":"red"}}""" ) self.server.rcon_query( f"""title @a title {{"text":"游戏开始!","bold":true, "color": "yellow"}}""" ) self.server.say(f"逃亡者是:{self.player_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