player_finished.mcfunction 1.9 KB

1234567891011121314151617181920212223
  1. # 玩家成功时由玩家自己触发
  2. # 计数
  3. tag @s remove mini_running
  4. function mini:main/update_player_count
  5. # 计算时间
  6. scoreboard players set #temp mem 150
  7. scoreboard players operation #temp mem -= $countdown mem
  8. execute if score #temp mem matches 1..100 run advancement grant @s only ltw:vs/treasure1
  9. execute if score #temp mem matches 1..60 run advancement grant @s only ltw:vs/treasure2
  10. execute if score #temp mem matches 1..40 run advancement grant @s only ltw:vs/treasure3
  11. execute if score #temp mem matches 1..33 run advancement grant @s only ltw:vs/treasure4
  12. # 显示提示
  13. execute if entity @s[tag=!rejoining] if score $player_finish mem matches 1 run tellraw @a ["",{"text": ">> ","color":"green","bold": true},{"selector": "@s"},{"text": " 已到达终点,用时 ","color":"green"},{"score": {"name": "#temp","objective": "mem"}}," 秒",{"text": "!第 ","color":"green"},{"score": {"name": "$player_finish","objective": "mem"},"color":"green"},{"text": " 名!","color":"green"}]
  14. execute if entity @s[tag=!rejoining] if score $player_finish mem matches 2..3 run tellraw @a ["",{"text": ">> ","color":"green","bold": true},{"selector": "@s"},{"text": " 已到达终点!第 ","color":"green"},{"score": {"name": "$player_finish","objective": "mem"},"color":"green"},{"text": " 名!","color":"green"}]
  15. execute if entity @s[tag=!rejoining] if score $player_finish mem matches 3 run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},{"text": "前三名已全部决出!无需再前往终点了,专心收集宝藏吧!","color":"aqua"}]
  16. execute if entity @s[tag=!rejoining] if score $player_finish mem matches ..2 run tellraw @s ["",{"text": ">> ","color":"aqua","bold": true},{"text": "继续收集宝藏,直到时间结束吧!","color":"aqua"}]
  17. execute as @a at @s run function lib:sounds/levelup
  18. # 给已完成的玩家加分
  19. scoreboard players add @a[tag=!mini_running] mini_score 1