From 7f9936d47396caf8e1916874497cf36e6d4eecd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E5=93=AA=E9=82=A3=E6=98=AF=E4=BB=80=E4=B9=88?= <79289641+god-what-is-that@users.noreply.github.com> Date: Tue, 19 Aug 2025 23:05:41 +0800 Subject: [PATCH 1/8] Update __init__.py --- tips/__init__.py | 53 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/tips/__init__.py b/tips/__init__.py index deda5b9..dfd2e0a 100644 --- a/tips/__init__.py +++ b/tips/__init__.py @@ -95,12 +95,53 @@ def send_tips(): if tips is not None: with tLock: while Task: - tip = random.choice(tips) - try: - tip = RText.from_json_object(tip) - except ValueError: - tip = str(tip) - psi.broadcast(RText.join(" ", [prefixRText, tip])) + + # 计算权重 + total_weight = sum(tip.get('weight', 0) for tip in tips) + + if total_weight != 0: + + # 权重分配 + rand = random.randint(1, total_weight) + current = 0 + selected_tip = None + commands = {} + + # 抽取tip + for one_tip in tips: + current += one_tip.get('weight', 0) + if rand <= current: + selected_tip = one_tip.get('text', None) + commands = one_tip.get('command', {}) + break + + if selected_tip is not None: + + # 执行tip附带的命令 + def execute_command(key: int): + count = len(commands) + while key <= count: + command = commands.get(key, None) + key = key+1 + if command is not None: + + # 添加命令delay的延时执行功能 + if command.startswith("delay"): + delay_time = float(command.split()[1]) + time.sleep(delay_time) + else: + psi.execute(command) + execute_command(1) + + # 用/n分行 + lines = selected_tip.split('/n') + for tip in lines: + + try: + tip = RText.from_json_object(tip) + except ValueError: + tip = str(tip) + psi.broadcast(RText.join(" ", [prefixRText, tip])) time.sleep(interval) From 3a306a1a6ce3cd1a002610d43124ed721611c394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E5=93=AA=E9=82=A3=E6=98=AF=E4=BB=80=E4=B9=88?= <79289641+god-what-is-that@users.noreply.github.com> Date: Tue, 19 Aug 2025 23:06:09 +0800 Subject: [PATCH 2/8] Update tips.yml --- resources/tips.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/resources/tips.yml b/resources/tips.yml index 986887b..bbea877 100644 --- a/resources/tips.yml +++ b/resources/tips.yml @@ -1,4 +1,13 @@ tips: - - 不要挖直上或直下! - - 使用!!etp back death返回死亡点 - - 新人在晚上建议挖三填一 \ No newline at end of file + - text: "不要挖直上或直下!/n小心掉进岩浆!" + weight: 20 + - text: "使用!!etp back death返回死亡点" + weight: 20 + - text: "新人在晚上建议挖三填一" + weight: 50 + - text: "Star Platinum!The World!" + weight: 10 + command: + 1: "tick freeze" + 2: "delay 5" + 3: "tick unfreeze" From 12d319d8fbb73b6a819f94a4438df0fcdbd8555f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E5=93=AA=E9=82=A3=E6=98=AF=E4=BB=80=E4=B9=88?= <79289641+god-what-is-that@users.noreply.github.com> Date: Tue, 19 Aug 2025 23:18:44 +0800 Subject: [PATCH 3/8] Update __init__.py --- tips/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tips/__init__.py b/tips/__init__.py index dfd2e0a..f93fc30 100644 --- a/tips/__init__.py +++ b/tips/__init__.py @@ -131,7 +131,6 @@ def execute_command(key: int): time.sleep(delay_time) else: psi.execute(command) - execute_command(1) # 用/n分行 lines = selected_tip.split('/n') @@ -142,6 +141,7 @@ def execute_command(key: int): except ValueError: tip = str(tip) psi.broadcast(RText.join(" ", [prefixRText, tip])) + execute_command(1) time.sleep(interval) From 0cc36ef798d9388c0400d9378696703c489410a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E5=93=AA=E9=82=A3=E6=98=AF=E4=BB=80=E4=B9=88?= <79289641+god-what-is-that@users.noreply.github.com> Date: Wed, 20 Aug 2025 01:57:12 +0800 Subject: [PATCH 4/8] Update __init__.py --- tips/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tips/__init__.py b/tips/__init__.py index f93fc30..3c57c63 100644 --- a/tips/__init__.py +++ b/tips/__init__.py @@ -113,6 +113,7 @@ def send_tips(): if rand <= current: selected_tip = one_tip.get('text', None) commands = one_tip.get('command', {}) + prefixRText = one_tip.get('prefix', prefixRText) break if selected_tip is not None: @@ -135,12 +136,11 @@ def execute_command(key: int): # 用/n分行 lines = selected_tip.split('/n') for tip in lines: - try: tip = RText.from_json_object(tip) except ValueError: tip = str(tip) - psi.broadcast(RText.join(" ", [prefixRText, tip])) + psi.broadcast(RText.join(" " if prefixRText is not "" and prefixRText is not None else "", [prefixRText if prefixRText is not None else "", tip])) execute_command(1) time.sleep(interval) From 5b9589105a676bdb7f956a1df1d39f83d86cd4e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E5=93=AA=E9=82=A3=E6=98=AF=E4=BB=80=E4=B9=88?= <79289641+god-what-is-that@users.noreply.github.com> Date: Wed, 20 Aug 2025 01:58:59 +0800 Subject: [PATCH 5/8] Update tips.yml --- resources/tips.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/tips.yml b/resources/tips.yml index bbea877..9b4ffc3 100644 --- a/resources/tips.yml +++ b/resources/tips.yml @@ -9,5 +9,13 @@ tips: weight: 10 command: 1: "tick freeze" - 2: "delay 5" - 3: "tick unfreeze" + 2: 'execute as @a unless entity @s[nbt={active_effects:[{id:"minecraft:jump_boost"}]}] run effect give @s minecraft:jump_boost 1000000 255 true' + 3: 'execute as @a unless entity @s[nbt={active_effects:[{id:"minecraft:slowness"}]}] run effect give @s minecraft:slowness 1000000 255 true' + 4: 'execute as @a unless entity @s[nbt={active_effects:[{id:"minecraft:mining_fatigue"}]}] run effect give @s minecraft:mining_fatigue 1000000 255 true' + 5: "delay 5" + 6: 'execute as @a[nbt={active_effects:[{id:"minecraft:jump_boost",amplifier:-1b}]}] run effect clear @s minecraft:jump_boost' + 7: 'execute as @a[nbt={active_effects:[{id:"minecraft:slowness",amplifier:-1b}]}] run effect clear @s minecraft:slowness' + 8: 'execute as @a[nbt={active_effects:[{id:"minecraft:mining_fatigue",amplifier:-1b}]}] run effect clear @s minecraft:mining_fatigue' + 9: "tick unfreeze" + 10: 'tellraw @a {"text":"§5时间开始流动!"}' + prefix: "" From 34ee1797e29b182695173a08096354d25ce07218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E5=93=AA=E9=82=A3=E6=98=AF=E4=BB=80=E4=B9=88?= <79289641+god-what-is-that@users.noreply.github.com> Date: Wed, 20 Aug 2025 02:45:52 +0800 Subject: [PATCH 6/8] Update __init__.py --- tips/__init__.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/tips/__init__.py b/tips/__init__.py index 3c57c63..60f2330 100644 --- a/tips/__init__.py +++ b/tips/__init__.py @@ -119,19 +119,14 @@ def send_tips(): if selected_tip is not None: # 执行tip附带的命令 - def execute_command(key: int): - count = len(commands) - while key <= count: - command = commands.get(key, None) - key = key+1 - if command is not None: - - # 添加命令delay的延时执行功能 - if command.startswith("delay"): - delay_time = float(command.split()[1]) - time.sleep(delay_time) - else: - psi.execute(command) + def execute_command(): + for command in commands: + # 添加命令delay的延时执行功能 + if command.startswith("delay"): + delay_time = float(command.split()[1]) + time.sleep(delay_time) + else: + psi.execute(command) # 用/n分行 lines = selected_tip.split('/n') @@ -141,7 +136,7 @@ def execute_command(key: int): except ValueError: tip = str(tip) psi.broadcast(RText.join(" " if prefixRText is not "" and prefixRText is not None else "", [prefixRText if prefixRText is not None else "", tip])) - execute_command(1) + execute_command() time.sleep(interval) From f0de90c638b69a1a98c8183d3cc36f904f82b660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E5=93=AA=E9=82=A3=E6=98=AF=E4=BB=80=E4=B9=88?= <79289641+god-what-is-that@users.noreply.github.com> Date: Wed, 20 Aug 2025 02:46:28 +0800 Subject: [PATCH 7/8] Update tips.yml --- resources/tips.yml | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/resources/tips.yml b/resources/tips.yml index 9b4ffc3..d8bd6ec 100644 --- a/resources/tips.yml +++ b/resources/tips.yml @@ -8,14 +8,16 @@ tips: - text: "Star Platinum!The World!" weight: 10 command: - 1: "tick freeze" - 2: 'execute as @a unless entity @s[nbt={active_effects:[{id:"minecraft:jump_boost"}]}] run effect give @s minecraft:jump_boost 1000000 255 true' - 3: 'execute as @a unless entity @s[nbt={active_effects:[{id:"minecraft:slowness"}]}] run effect give @s minecraft:slowness 1000000 255 true' - 4: 'execute as @a unless entity @s[nbt={active_effects:[{id:"minecraft:mining_fatigue"}]}] run effect give @s minecraft:mining_fatigue 1000000 255 true' - 5: "delay 5" - 6: 'execute as @a[nbt={active_effects:[{id:"minecraft:jump_boost",amplifier:-1b}]}] run effect clear @s minecraft:jump_boost' - 7: 'execute as @a[nbt={active_effects:[{id:"minecraft:slowness",amplifier:-1b}]}] run effect clear @s minecraft:slowness' - 8: 'execute as @a[nbt={active_effects:[{id:"minecraft:mining_fatigue",amplifier:-1b}]}] run effect clear @s minecraft:mining_fatigue' - 9: "tick unfreeze" - 10: 'tellraw @a {"text":"§5时间开始流动!"}' - prefix: "" + - "tick freeze" + - 'execute as @a unless entity @s[nbt={active_effects:[{id:"minecraft:jump_boost"}]}] run effect give @s minecraft:jump_boost 1000000 255 true' + - 'execute as @a unless entity @s[nbt={active_effects:[{id:"minecraft:slowness"}]}] run effect give @s minecraft:slowness 1000000 255 true' + - 'execute as @a unless entity @s[nbt={active_effects:[{id:"minecraft:mining_fatigue"}]}] run effect give @s minecraft:mining_fatigue 1000000 255 true' + - 'execute as @a unless entity @s[nbt={active_effects:[{id:"minecraft:weakness"}]}] run effect give @s minecraft:weakness 1000000 255 true' + - "delay 5" + - 'execute as @a[nbt={active_effects:[{id:"minecraft:jump_boost",amplifier:-1b}]}] run effect clear @s minecraft:jump_boost' + - 'execute as @a[nbt={active_effects:[{id:"minecraft:slowness",amplifier:-1b}]}] run effect clear @s minecraft:slowness' + - 'execute as @a[nbt={active_effects:[{id:"minecraft:mining_fatigue",amplifier:-1b}]}] run effect clear @s minecraft:mining_fatigue' + - 'execute as @a[nbt={active_effects:[{id:"minecraft:weakness",amplifier:-1b}]}] run effect clear @s minecraft:weakness' + - "tick unfreeze" + - 'tellraw @a {"text":"§5时间开始流动!"}' + prefix: "[事件]" From 6ec225333cce9f8ecd167af2bf839c3b5f12a571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E5=93=AA=E9=82=A3=E6=98=AF=E4=BB=80=E4=B9=88?= <79289641+god-what-is-that@users.noreply.github.com> Date: Wed, 20 Aug 2025 02:47:24 +0800 Subject: [PATCH 8/8] Update tips.yml --- resources/tips.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/tips.yml b/resources/tips.yml index d8bd6ec..2006020 100644 --- a/resources/tips.yml +++ b/resources/tips.yml @@ -19,5 +19,5 @@ tips: - 'execute as @a[nbt={active_effects:[{id:"minecraft:mining_fatigue",amplifier:-1b}]}] run effect clear @s minecraft:mining_fatigue' - 'execute as @a[nbt={active_effects:[{id:"minecraft:weakness",amplifier:-1b}]}] run effect clear @s minecraft:weakness' - "tick unfreeze" - - 'tellraw @a {"text":"§5时间开始流动!"}' + - 'tellraw @a {"text":"[事件] §5时间开始流动!"}' prefix: "[事件]"