From 3ce37c9abf68bae7ad4ed1c13c56887a97a317bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BB=B6=E7=9A=93?= <1214946206@qq.com> Date: Tue, 26 Jul 2022 07:57:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E6=95=B0=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/interactor/on_click.json | 4 + .../carpet_player/tick/tick.mcfunction | 1 - .../functions/game_event/install.mcfunction | 3 +- data/fz/functions/game_event/load.mcfunction | 2 +- .../game_event/on_tick/on_tick.mcfunction | 1 + ...on => on_broke_block_with_tool.mcfunction} | 2 +- .../on_used_tool.mcfunction | 2 +- .../event/on_unsneak/on_unsneak.mcfunction | 2 +- .../interactor/interactor/display.mcfunction | 4 +- .../interactor/interactor/on_click.mcfunction | 4 +- .../interactor/reset_trigger.mcfunction | 2 +- .../module/scoreboard/clear_data.mcfunction | 22 ++ .../module/scoreboard/install.mcfunction | 5 + ...nt.mcfunction => fishing_count.mcfunction} | 0 .../module/scoreboard/uninstall.mcfunction | 25 +- ...d_fzsd_ignore_fakeplayer_scores.mcfunction | 2 +- data/fz/functions/system/tick.mcfunction | 1 - data/fz/predicates/is_fake_player.json | 2 +- data/fz/predicates/is_shadow_player.json | 2 +- .../game_event/carpet_player/tick.json | 6 - .../fz/tags/functions/game_event/on_tick.json | 6 + ...ock.json => on_broke_block_with_tool.json} | 0 .../functions/game_event/player/on_login.json | 2 - .../game_event/player/on_used_tool.json | 2 +- .../tags/functions/game_event/reset_all.json | 7 + data/minecraft/tags/functions/tick.json | 2 +- scripts/bots.sc | 5 - scripts/fz_score.sc | 267 ++++++++++++++++++ scripts/fzsd_ignore_fakeplayer_scores.sc | 77 ----- 29 files changed, 331 insertions(+), 129 deletions(-) delete mode 100644 data/fz/functions/game_event/carpet_player/tick/tick.mcfunction create mode 100644 data/fz/functions/game_event/on_tick/on_tick.mcfunction rename data/fz/functions/game_event/player/{on_broke_block.mcfunction => on_broke_block_with_tool.mcfunction} (85%) rename data/fz/functions/game_event/player/{on_broke_block => on_broke_block_with_tool}/on_used_tool.mcfunction (98%) rename data/fz/functions/module/scoreboard/interactor/subscribe/{fisning_count.mcfunction => fishing_count.mcfunction} (100%) delete mode 100644 data/fz/functions/system/tick.mcfunction delete mode 100644 data/fz/tags/functions/game_event/carpet_player/tick.json create mode 100644 data/fz/tags/functions/game_event/on_tick.json rename data/fz/tags/functions/game_event/player/{on_broke_block.json => on_broke_block_with_tool.json} (100%) create mode 100644 data/fz/tags/functions/game_event/reset_all.json delete mode 100644 scripts/bots.sc create mode 100644 scripts/fz_score.sc delete mode 100644 scripts/fzsd_ignore_fakeplayer_scores.sc diff --git a/data/fz/advancements/module/interactor/on_click.json b/data/fz/advancements/module/interactor/on_click.json index 6ab421e..d4ad13b 100644 --- a/data/fz/advancements/module/interactor/on_click.json +++ b/data/fz/advancements/module/interactor/on_click.json @@ -5,6 +5,10 @@ "trigger": "minecraft:tick", "conditions": { "player": [ + { + "condition": "minecraft:reference", + "name": "fz:is_real_player" + }, { "condition": "minecraft:inverted", "term": { diff --git a/data/fz/functions/game_event/carpet_player/tick/tick.mcfunction b/data/fz/functions/game_event/carpet_player/tick/tick.mcfunction deleted file mode 100644 index 8437585..0000000 --- a/data/fz/functions/game_event/carpet_player/tick/tick.mcfunction +++ /dev/null @@ -1 +0,0 @@ -scoreboard players remove @s fz.event.play_ticks 1 \ No newline at end of file diff --git a/data/fz/functions/game_event/install.mcfunction b/data/fz/functions/game_event/install.mcfunction index 562c5df..3694bc0 100644 --- a/data/fz/functions/game_event/install.mcfunction +++ b/data/fz/functions/game_event/install.mcfunction @@ -3,7 +3,8 @@ scoreboard objectives add fz.event.aviating_distance minecraft.custom:aviate_one scoreboard objectives add fz.event.damage_taken minecraft.custom:damage_taken scoreboard objectives add fz.event.death_count deathCount scoreboard objectives add fz.event.leave_game minecraft.custom:leave_game -scoreboard objectives add fz.event.play_ticks minecraft.custom:play_time +### 由 #fz:game_event/on_tick 赋值 +scoreboard objectives add fz.event.play_ticks dummy scoreboard objectives add fz.event.villager_trade minecraft.custom:traded_with_villager ## 使用工具 diff --git a/data/fz/functions/game_event/load.mcfunction b/data/fz/functions/game_event/load.mcfunction index 0953c38..ae5f722 100644 --- a/data/fz/functions/game_event/load.mcfunction +++ b/data/fz/functions/game_event/load.mcfunction @@ -1,4 +1,4 @@ -execute as @a run function #fz:game_event/player/on_login +execute as @a[predicate=fz:is_real_player] run function #fz:game_event/player/on_login ## 调试 execute if score fz.logger.level fz.variable.integer matches ..400 run tellraw @a [{"nbt": "fz.level.debug", "interpret": true, "storage": "fz:logger"}, {"text": "已加载系统组件:游戏事件"}] \ No newline at end of file diff --git a/data/fz/functions/game_event/on_tick/on_tick.mcfunction b/data/fz/functions/game_event/on_tick/on_tick.mcfunction new file mode 100644 index 0000000..c1484f3 --- /dev/null +++ b/data/fz/functions/game_event/on_tick/on_tick.mcfunction @@ -0,0 +1 @@ +scoreboard players add @a[predicate=fz:is_real_player] fz.event.play_ticks 1 \ No newline at end of file diff --git a/data/fz/functions/game_event/player/on_broke_block.mcfunction b/data/fz/functions/game_event/player/on_broke_block_with_tool.mcfunction similarity index 85% rename from data/fz/functions/game_event/player/on_broke_block.mcfunction rename to data/fz/functions/game_event/player/on_broke_block_with_tool.mcfunction index e22b990..35e7466 100644 --- a/data/fz/functions/game_event/player/on_broke_block.mcfunction +++ b/data/fz/functions/game_event/player/on_broke_block_with_tool.mcfunction @@ -4,4 +4,4 @@ execute if score fz.logger.level fz.variable.integer matches ..400 run tellraw @a [{"nbt": "fz.level.debug", "interpret": true, "storage": "fz:logger"}, {"text": "事件已触发:玩家"}, {"selector": "@s"}, {"text": "挖掘了方块"}] ## 运行事件 -function #fz:game_event/player/on_broke_block \ No newline at end of file +function #fz:game_event/player/on_broke_block_with_tool \ No newline at end of file diff --git a/data/fz/functions/game_event/player/on_broke_block/on_used_tool.mcfunction b/data/fz/functions/game_event/player/on_broke_block_with_tool/on_used_tool.mcfunction similarity index 98% rename from data/fz/functions/game_event/player/on_broke_block/on_used_tool.mcfunction rename to data/fz/functions/game_event/player/on_broke_block_with_tool/on_used_tool.mcfunction index 1b45cdf..0f9372d 100644 --- a/data/fz/functions/game_event/player/on_broke_block/on_used_tool.mcfunction +++ b/data/fz/functions/game_event/player/on_broke_block_with_tool/on_used_tool.mcfunction @@ -33,4 +33,4 @@ scoreboard players operation fz.var.score fz.variable.integer += @s fz.event.use scoreboard players operation fz.var.score fz.variable.integer += @s fz.event.used_tool.offset ## 判断分数 -execute unless score fz.var.score fz.variable.integer matches ..0 run function fz:game_event/player/on_broke_block \ No newline at end of file +execute unless score fz.var.score fz.variable.integer matches ..0 run function fz:game_event/player/on_broke_block_with_tool \ No newline at end of file diff --git a/data/fz/functions/module/interactor/event/on_unsneak/on_unsneak.mcfunction b/data/fz/functions/module/interactor/event/on_unsneak/on_unsneak.mcfunction index 2c8175c..4ec8363 100644 --- a/data/fz/functions/module/interactor/event/on_unsneak/on_unsneak.mcfunction +++ b/data/fz/functions/module/interactor/event/on_unsneak/on_unsneak.mcfunction @@ -1,3 +1,3 @@ # 本目录用于存放向事件中注册的函数,并不用来新建事件 -execute if score @s fz.module.interactor.player.config matches 1 if entity @s[x_rotation = -90] run function #fz:module/interactor/display \ No newline at end of file +execute unless score @s fz.module.interactor.player.config matches -1 if entity @s[x_rotation = -90] run function #fz:module/interactor/display \ No newline at end of file diff --git a/data/fz/functions/module/interactor/interactor/display.mcfunction b/data/fz/functions/module/interactor/interactor/display.mcfunction index 282312e..d6b43ca 100644 --- a/data/fz/functions/module/interactor/interactor/display.mcfunction +++ b/data/fz/functions/module/interactor/interactor/display.mcfunction @@ -3,5 +3,5 @@ execute if score fz.logger.level fz.variable.integer matches ..400 run tellraw @ execute if data storage fz:installed fz.module{last_death:1b} run tellraw @s {"text": "交互器打开方式:"} -execute if data storage fz:installed fz.module{last_death:1b} if score @s fz.module.interactor.player.config matches 1 run tellraw @s [{"text": "- 抬头+蹲起:"}, [{"text": "[", "color": "dark_gray", "hoverEvent": {"action": "show_text", "value": "点击关闭"}, "clickEvent": {"action": "run_command", "value": "/trigger fz.module.interactor.trigger set 900"}},{"text": "已开启", "color": "green"},{"text": "]"}]] -execute if data storage fz:installed fz.module{last_death:1b} unless score @s fz.module.interactor.player.config matches 1 run tellraw @s [{"text": "- 抬头+蹲起:"}, [{"text": "[", "color": "dark_gray", "hoverEvent": {"action": "show_text", "value": "点击开启"}, "clickEvent": {"action": "run_command", "value": "/trigger fz.module.interactor.trigger set 910"}},{"text": "已关闭", "color": "red"},{"text": "]"}]] \ No newline at end of file +execute if data storage fz:installed fz.module{last_death:1b} unless score @s fz.module.interactor.player.config matches -1 run tellraw @s [{"text": "- 抬头+蹲起:"}, [{"text": "[", "color": "dark_gray", "hoverEvent": {"action": "show_text", "value": "点击关闭"}, "clickEvent": {"action": "run_command", "value": "/trigger fz.module.interactor.trigger set 900"}},{"text": "已开启", "color": "green"},{"text": "]"}]] +execute if data storage fz:installed fz.module{last_death:1b} if score @s fz.module.interactor.player.config matches -1 run tellraw @s [{"text": "- 抬头+蹲起:"}, [{"text": "[", "color": "dark_gray", "hoverEvent": {"action": "show_text", "value": "点击开启"}, "clickEvent": {"action": "run_command", "value": "/trigger fz.module.interactor.trigger set 910"}},{"text": "已关闭", "color": "red"},{"text": "]"}]] \ No newline at end of file diff --git a/data/fz/functions/module/interactor/interactor/on_click.mcfunction b/data/fz/functions/module/interactor/interactor/on_click.mcfunction index e8efe7a..4a69e86 100644 --- a/data/fz/functions/module/interactor/interactor/on_click.mcfunction +++ b/data/fz/functions/module/interactor/interactor/on_click.mcfunction @@ -3,6 +3,6 @@ ## 调试 execute if score fz.logger.level fz.variable.integer matches ..400 run tellraw @a [{"nbt": "fz.level.debug", "interpret": true, "storage": "fz:logger"}, {"text": "玩家"}, {"selector": "@s"}, {"text": "的交互器分数为:"}, {"score": {"name": "@s", "objective": "fz.module.interactor.trigger"}}] -execute if score @s fz.module.interactor.trigger matches 900 run scoreboard players set @s fz.module.interactor.player.config 0 +execute if score @s fz.module.interactor.trigger matches 900 run scoreboard players set @s fz.module.interactor.player.config -1 -execute if score @s fz.module.interactor.trigger matches 910 run scoreboard players set @s fz.module.interactor.player.config 1 \ No newline at end of file +execute if score @s fz.module.interactor.trigger matches 910 run scoreboard players set @s fz.module.interactor.player.config 0 \ No newline at end of file diff --git a/data/fz/functions/module/interactor/reset_trigger.mcfunction b/data/fz/functions/module/interactor/reset_trigger.mcfunction index 4cdf237..1e0912f 100644 --- a/data/fz/functions/module/interactor/reset_trigger.mcfunction +++ b/data/fz/functions/module/interactor/reset_trigger.mcfunction @@ -1,6 +1,6 @@ # 调用者:#fz:module/interactor/reset_trigger -scoreboard players reset @s fz.module.interactor.trigger +scoreboard players set @s fz.module.interactor.trigger 0 scoreboard players enable @s fz.module.interactor.trigger ## 调试 diff --git a/data/fz/functions/module/scoreboard/clear_data.mcfunction b/data/fz/functions/module/scoreboard/clear_data.mcfunction index d023f1a..0c2ca39 100644 --- a/data/fz/functions/module/scoreboard/clear_data.mcfunction +++ b/data/fz/functions/module/scoreboard/clear_data.mcfunction @@ -20,5 +20,27 @@ scoreboard objectives remove fz.module.scoreboard.display.kill_count ### 交易榜 scoreboard objectives remove fz.module.scoreboard.display.trade_count +## 清除队伍 +### 轮播 +team remove fz.module.scoreboard.display.carousel +### 总榜 +team remove fz.module.scoreboard.display.general +### 活跃度 +team remove fz.module.scoreboard.display.activation +### 飞行距离 +team remove fz.module.scoreboard.display.aviating_distance +### 受伤害榜 +team remove fz.module.scoreboard.display.damage_taken +### 死亡榜 +team remove fz.module.scoreboard.display.death_count +### 挖掘榜 +team remove fz.module.scoreboard.display.dig_count +### 钓鱼榜 +team remove fz.module.scoreboard.display.fishing_count +### 击杀榜 +team remove fz.module.scoreboard.display.kill_count +### 交易榜 +team remove fz.module.scoreboard.display.trade_count + ## 日志 execute if score fz.logger.level fz.variable.integer matches ..500 run tellraw @a [{"nbt": "level.info", "interpret": true, "storage": "fz:logger"}, {"text": "已删除计分板数据!"}] \ No newline at end of file diff --git a/data/fz/functions/module/scoreboard/install.mcfunction b/data/fz/functions/module/scoreboard/install.mcfunction index 8c22575..09f1b24 100644 --- a/data/fz/functions/module/scoreboard/install.mcfunction +++ b/data/fz/functions/module/scoreboard/install.mcfunction @@ -51,6 +51,11 @@ team add fz.module.scoreboard.display.placement_count scoreboard objectives add fz.module.scoreboard.display.trade_count dummy team add fz.module.scoreboard.display.trade_count +team add fz.module.scoreboard.fake +team add fz.module.scoreboard.shadow +team modify fz.module.scoreboard.fake prefix {"text": "假的"} +team modify fz.module.scoreboard.shadow prefix {"text": "挂机"} + ## 标记为已安装 data modify storage fz:installed fz.module.scoreboard set value 1b diff --git a/data/fz/functions/module/scoreboard/interactor/subscribe/fisning_count.mcfunction b/data/fz/functions/module/scoreboard/interactor/subscribe/fishing_count.mcfunction similarity index 100% rename from data/fz/functions/module/scoreboard/interactor/subscribe/fisning_count.mcfunction rename to data/fz/functions/module/scoreboard/interactor/subscribe/fishing_count.mcfunction diff --git a/data/fz/functions/module/scoreboard/uninstall.mcfunction b/data/fz/functions/module/scoreboard/uninstall.mcfunction index 122434e..a829a2b 100644 --- a/data/fz/functions/module/scoreboard/uninstall.mcfunction +++ b/data/fz/functions/module/scoreboard/uninstall.mcfunction @@ -3,28 +3,6 @@ ## 关闭轮播循环 schedule clear fz:module/scoreboard/display/carousel/loop -## 清除队伍 -### 轮播 -team remove fz.module.scoreboard.display.carousel -### 总榜 -team remove fz.module.scoreboard.display.general -### 活跃度 -team remove fz.module.scoreboard.display.activation -### 飞行距离 -team remove fz.module.scoreboard.display.aviating_distance -### 受伤害榜 -team remove fz.module.scoreboard.display.damage_taken -### 死亡榜 -team remove fz.module.scoreboard.display.death_count -### 挖掘榜 -team remove fz.module.scoreboard.display.dig_count -### 钓鱼榜 -team remove fz.module.scoreboard.display.fishing_count -### 击杀榜 -team remove fz.module.scoreboard.display.kill_count -### 交易榜 -team remove fz.module.scoreboard.display.trade_count - ## 关闭计分板显示 scoreboard objectives setdisplay sidebar.team.aqua scoreboard objectives setdisplay sidebar.team.black @@ -43,6 +21,9 @@ scoreboard objectives setdisplay sidebar.team.red scoreboard objectives setdisplay sidebar.team.white scoreboard objectives setdisplay sidebar.team.yellow +team remove fz.module.scoreboard.fake +team remove fz.module.scoreboard.shadow + ## 询问是否清除数据 execute if score fz.logger.level fz.variable.integer matches ..600 run tellraw @s [{"nbt": "fz.level.alert", "interpret": true, "storage": "fz:logger"}, {"text": "您要删除计分板数据吗,它将会永久失去!(真的很久!)"}, {"text": "[确定]", "color": "dark_red", "clickEvent": {"action": "suggest_command", "value": "/function #fz:module/scoreboard/clear_data"}, "hoverEvent": {"action": "show_text", "contents": {"text": "将命令填入聊天框"}}}] diff --git a/data/fz/functions/system/carpet/try_load_fzsd_ignore_fakeplayer_scores.mcfunction b/data/fz/functions/system/carpet/try_load_fzsd_ignore_fakeplayer_scores.mcfunction index f98bd35..5018793 100644 --- a/data/fz/functions/system/carpet/try_load_fzsd_ignore_fakeplayer_scores.mcfunction +++ b/data/fz/functions/system/carpet/try_load_fzsd_ignore_fakeplayer_scores.mcfunction @@ -1 +1 @@ -script run if (system_info('app_list') ~ 'fzsd_ignore_fakeplayer_scores' == null, run('script load fzsd_ignore_fakeplayer_scores')) \ No newline at end of file +script run if (system_info('app_list') ~ 'fz_score' == null, run('script load fz_score')) \ No newline at end of file diff --git a/data/fz/functions/system/tick.mcfunction b/data/fz/functions/system/tick.mcfunction deleted file mode 100644 index f925484..0000000 --- a/data/fz/functions/system/tick.mcfunction +++ /dev/null @@ -1 +0,0 @@ -execute as @a if predicate fz:not_real_player run function #fz:game_event/carpet_player/tick \ No newline at end of file diff --git a/data/fz/predicates/is_fake_player.json b/data/fz/predicates/is_fake_player.json index 1dfe75c..d333fcd 100644 --- a/data/fz/predicates/is_fake_player.json +++ b/data/fz/predicates/is_fake_player.json @@ -2,6 +2,6 @@ "condition": "minecraft:entity_properties", "entity": "this", "predicate": { - "team": "fake" + "team": "fz.module.scoreboard.fake" } } \ No newline at end of file diff --git a/data/fz/predicates/is_shadow_player.json b/data/fz/predicates/is_shadow_player.json index 288b022..d0a3a01 100644 --- a/data/fz/predicates/is_shadow_player.json +++ b/data/fz/predicates/is_shadow_player.json @@ -2,6 +2,6 @@ "condition": "minecraft:entity_properties", "entity": "this", "predicate": { - "team": "shadow" + "team": "fz.module.scoreboard.shadow" } } \ No newline at end of file diff --git a/data/fz/tags/functions/game_event/carpet_player/tick.json b/data/fz/tags/functions/game_event/carpet_player/tick.json deleted file mode 100644 index 736c936..0000000 --- a/data/fz/tags/functions/game_event/carpet_player/tick.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "fz:game_event/carpet_player/tick/tick" - ] -} \ No newline at end of file diff --git a/data/fz/tags/functions/game_event/on_tick.json b/data/fz/tags/functions/game_event/on_tick.json new file mode 100644 index 0000000..c06fbcf --- /dev/null +++ b/data/fz/tags/functions/game_event/on_tick.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "fz:game_event/on_tick/on_tick" + ] +} \ No newline at end of file diff --git a/data/fz/tags/functions/game_event/player/on_broke_block.json b/data/fz/tags/functions/game_event/player/on_broke_block_with_tool.json similarity index 100% rename from data/fz/tags/functions/game_event/player/on_broke_block.json rename to data/fz/tags/functions/game_event/player/on_broke_block_with_tool.json diff --git a/data/fz/tags/functions/game_event/player/on_login.json b/data/fz/tags/functions/game_event/player/on_login.json index 8f7ca72..114f33e 100644 --- a/data/fz/tags/functions/game_event/player/on_login.json +++ b/data/fz/tags/functions/game_event/player/on_login.json @@ -1,8 +1,6 @@ { "replace": false, "values": [ - "#fz:game_event/advancement/reset_advancements", - "#fz:game_event/player/on_used_tool/reset_used_tool", "#fz:module/interactor/reset_trigger", "#fz:module/interactor/event/reset_advancements" ] diff --git a/data/fz/tags/functions/game_event/player/on_used_tool.json b/data/fz/tags/functions/game_event/player/on_used_tool.json index ed2dc87..6882884 100644 --- a/data/fz/tags/functions/game_event/player/on_used_tool.json +++ b/data/fz/tags/functions/game_event/player/on_used_tool.json @@ -1,6 +1,6 @@ { "replace": false, "values": [ - "fz:game_event/player/on_broke_block/on_used_tool" + "fz:game_event/player/on_broke_block_with_tool/on_used_tool" ] } \ No newline at end of file diff --git a/data/fz/tags/functions/game_event/reset_all.json b/data/fz/tags/functions/game_event/reset_all.json new file mode 100644 index 0000000..5188ef7 --- /dev/null +++ b/data/fz/tags/functions/game_event/reset_all.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "#fz:game_event/advancement/reset_advancements", + "#fz:game_event/player/on_used_tool/reset_used_tool" + ] +} \ No newline at end of file diff --git a/data/minecraft/tags/functions/tick.json b/data/minecraft/tags/functions/tick.json index bcfb83b..e1550df 100644 --- a/data/minecraft/tags/functions/tick.json +++ b/data/minecraft/tags/functions/tick.json @@ -1,6 +1,6 @@ { "replace": false, "values": [ - "fz:system/tick" + "#fz:game_event/on_tick" ] } \ No newline at end of file diff --git a/scripts/bots.sc b/scripts/bots.sc deleted file mode 100644 index eb2d616..0000000 --- a/scripts/bots.sc +++ /dev/null @@ -1,5 +0,0 @@ -// 一个用于生成皓皓的东西( - -__command() -> ( - run('player Harvey_Husky spawn') -) \ No newline at end of file diff --git a/scripts/fz_score.sc b/scripts/fz_score.sc new file mode 100644 index 0000000..b0c4032 --- /dev/null +++ b/scripts/fz_score.sc @@ -0,0 +1,267 @@ +// 计分板模块扩展插件 +// 忽略假人分数 +// **请勿修改文件名!!** +global_app_version = '1.0-beta.1'; + +__config() -> { + 'scope' -> 'global', + 'requires' -> { + 'carpet' -> '>=1.4.45', + 'minecraft' -> '>=1.17' + }, + 'command_permission' -> 4, + 'commands' -> { + '' -> 'help', + 'help' -> 'help', + 'delete_old' -> 'delete_old', + 'merge_old' -> 'restore_merge_old', + 'restore_from_stats' -> 'restore_from_stats', + 'recalculate_total' -> 'recalculate_total_scores' + } +}; + +__on_start() -> ( + global_team_cache = read_file('team_cache', 'json'); + debug(global_team_cache); + print(player('all'), 'fz_score.sc已加载!'); +); + +__on_close() -> ( + debug(global_team_cache); + delete_file('team_cache', 'json'); + write_file('team_cache', 'json', global_team_cache); +); + +__on_player_connects(player) -> ( + debug(player ~ 'name'); + debug(player ~ 'player_type'); + debug(player ~ 'team'); + debug(global_team_cache); + if(player ~ 'player_type' == 'fake' && player ~ 'team' != 'fz.module.scoreboard.fake', + ( + debug('1~'); + global_team_cache:(player ~ 'name') = player ~ 'team'; + debug(global_team_cache); + team_add('fz.module.scoreboard.fake', player); + ), + player ~ 'player_type' == 'shadow' && player ~ 'team' != 'fz.module.scoreboard.shadow', + ( + debug('2~'); + global_team_cache:(player ~ 'name') = player ~ 'team'; + team_add('fz.module.scoreboard.shadow', player); + ), + try_restore_team_from_cache(player); + ); + debug(global_team_cache); +); + +__on_player_disconnects(player, reason) -> ( + debug(player ~ 'name'); + debug(player ~ 'player_type'); + debug(player ~ 'team'); + debug(global_team_cache); + try_restore_team_from_cache(player); +); + +try_restore_team_from_cache(player) -> ( + debug('restore_team_from_cache'); + if(player ~ 'team' == 'fz.module.scoreboard.fake' + || player ~ 'team' == 'fz.module.scoreboard.shadow', + debug(global_team_cache); + if(global_team_cache:(player ~ 'name') == null, + ( + debug('global_team_cache:(player ~ \'name\') == null'); + team_leave(player); + ), + debug('global_team_cache:(player ~ \'name\') != null'); + team_add(global_team_cache:(player ~ 'name') , player); + delete(global_team_cache:(player ~ 'name')); + ); + ); +); + +help() -> ( + print('这是一条帮助'); + return(0); +); + +delete_old() -> ( + old_scoreboards = [ + 'usedDiaAxe', 'usedDiaPickaxe', 'usedDiaShovel', 'usedDiaHoe', 'usedIroAxe', 'usedIroPickaxe', + 'usedIroShovel', 'usedIroHoe', 'usedStoAxe', 'usedStoPickaxe', 'usedStoShovel', 'usedStoHoe', + 'usedWooAxe', 'usedWooPickaxe', 'usedWooShovel', 'usedWooHoe', 'usedGolAxe', 'usedGolPickaxe', + 'usedGolShovel', 'usedGolHoe', 'usedNetAxe', 'usedNetPickaxe', 'usedNetShovel', 'usedNetHoe', + 'usedShears', 'damageTaken', '10xDamageTaken', 'deathCounter', 'deathTester', 'digCounter', + 'fishingCounter', 'fishingTester', 'killCounter', 'tradingCounter', 'totalList', + 'bedrockBreaked', 'fz.bbl', 'fz.aviate1m', 'fz.aviateCounter', 'fz.aviateOneTime', 'Health', + 'carpetBot', 'parameter' + ]; + for(old_scoreboards, scoreboard_remove(_)); + team_remove('carpetBot'); + team_remove('shadowedPlayer'); + print('已清除旧版计分板!'); + return(0); +); + +restore_merge_old() -> ( + + merge_score('activation', 'fz.module.scoreboard.display.activation'); + merge_score('damageTaken', 'fz.module.scoreboard.display.damage_taken'); + merge_score('deathCounter', 'fz.module.scoreboard.display.death_count'); + merge_score('digCounter', 'fz.module.scoreboard.display.dig_count'); + merge_score('fishingCounter', 'fz.module.scoreboard.display.fishing_count'); + merge_score('killCounter', 'fz.module.scoreboard.display.kill_count'); + merge_score('tradingCounter', 'fz.module.scoreboard.display.trade_count'); + merge_score('bedrockBreaked', 'fz.module.scoreboard.display.bedrock_broke_count'); + merge_score('fz.aviate1m', 'fz.module.scoreboard.display.aviating_distance'); + // restore_score('fz.module.scoreboard.display.placement_count', ); + + // 清除旧计分板 + delete_old(); + + print('完成!'); + return(0); +); + +merge_score(from, to) -> ( + + // 旧计分板总分名字 + l_1 = sort(scoreboard(from)); + total_name_old = l_1:(length(l_1 - 1)); + + // 如有非法字符则确定是总分 + if(!(total_name_old ~ '\\W'), + total_name_old = null; + debug('1' + total_name_old); + ); + + // 如果目标计分板不存在则创建 + if(scoreboard() ~ to == null, scoreboard_add(to)); + + // 旧版数据包的假人列表 + fake_players = team_list('carpetBot'); + + // 新数据包的计分板中存储的玩家列表 + new_players = scoreboard('fz.module.interactor.trigger'); + debug('2' + new_players); + for(scoreboard(from), + debug('3' + _); + debug('3.1' + contains(fake_players, _)); + debug('3.2' + contains(new_players, _)); + debug('3.3' + str(_ != total_name_old)); + debug('3.4' + str((!contains(fake_players, _) + || contains(new_players, _) + ) && _ != total_name_old)); + if((!contains(fake_players, _) + || contains(new_players, _) + ) && _ != total_name_old, + debug('4' + _); + debug('from' + scoreboard(from, _)); + debug('to' + scoreboard(to, _)); + scoreboard(to, _, scoreboard(to, _) + scoreboard(from, _)); + ); + ); + + // 重新计算总分 + recalculate_total_score(to, get_total_score_name_new(to)); + + print('已合并:' + to); + return(0); +); + +// 因为新计分板允许玩家自定义显示的总榜名称,故续做复杂判断才能使脚本确定之 +get_total_score_name_new(scoreboard) -> ( + INT_MIN = -2147483648; + // 获取系统总榜id + system_total_name = replace(scoreboard, 'display', 'total'); + + + // 将系统总榜分数加上最小int值,使其成为最低分 + scoreboard( + 'fz.module.scoreboard.assign.general', + system_total_name, + scoreboard( + 'fz.module.scoreboard.assign.general', + system_total_name + ) + INT_MIN + ); + + // 将总分赋值到显示计分板上 + display_total_score(scoreboard); + + // 查找榜内最低分 + last_min_player = null; + for(scoreboard(scoreboard), + if(last_min_player == null, + ( + last_min_player = _; + ), + if(scoreboard(scoreboard, _) < scoreboard(scoreboard, last_min_player), + last_min_player = _; + ) + ); + debug(_); + ); + + // 恢复总榜分数 + scoreboard( + 'fz.module.scoreboard.assign.general', + system_total_name, + scoreboard( + 'fz.module.scoreboard.assign.general', + system_total_name + ) - INT_MIN + ); + display_total_score(scoreboard); + + // 返回榜内最低分的名称 + return(last_min_player); +); + +recalculate_total_scores() -> ( + return(0); +); + +recalculate_total_score(scoreboard, total_score_name_new) -> ( + // 计算总分 + total_score = 0; + for(scoreboard(scoreboard), + if(_ != total_score_name_new, + total_score += scoreboard(scoreboard, _); + ); + ); + // 赋值总分到系统总分计分板 + scoreboard( + 'fz.module.scoreboard.assign.general', + replace(scoreboard, 'display', 'total'), + total_score + ); + display_total_score(scoreboard); + return(0); +); + +display_total_score(scoreboard) -> ( + // 获取计算总榜的函数标签名 + str_1 = split('\\.', scoreboard); + function_name = str_1:(length(str_1) - 1); + // 运行函数,将分数赋值到显示计分板上 + run('function #fz:module/scoreboard/assign/scoreboard/general/' + function_name); + return(0); +); + +restore_from_stats() -> ( + return(0); +); + +merge_stat(scoreboard, ...stats) -> ( + return(0); +); + +contains(list, value) -> ( + return(list ~ value != null); +); + +debug(msg) -> ( + logger('debug', msg); + return(0); +); \ No newline at end of file diff --git a/scripts/fzsd_ignore_fakeplayer_scores.sc b/scripts/fzsd_ignore_fakeplayer_scores.sc deleted file mode 100644 index b0fa331..0000000 --- a/scripts/fzsd_ignore_fakeplayer_scores.sc +++ /dev/null @@ -1,77 +0,0 @@ -// 计分板模块扩展插件 -// 忽略假人分数 -// **请勿修改文件名!!** -global_app_version = '1.0-beta.1'; - -__config() -> { - 'scope' -> 'global', - 'requires' -> { - 'carpet' -> '>=1.4.45', - 'minecraft' -> '>=1.17' - } -}; - -__on_start() -> ( - global_team_cache = read_file('team_cache', 'json'); - debug(global_team_cache); - team_add('fake'); - team_add('shadow'); - print(player('all'), '已忽略计分板模块假人分数'); -); - -__on_close() -> ( - debug(global_team_cache); - delete_file('team_cache', 'json'); - write_file('team_cache', 'json', global_team_cache); -); - -__on_player_connects(player) -> ( - debug(player ~ 'name'); - debug(player ~ 'player_type'); - debug(player ~ 'team'); - debug(global_team_cache); - if (player ~ 'player_type' == 'fake' && player ~ 'team' != 'fake', - ( - global_team_cache:(player ~ 'name') = player ~ 'team'; - team_add('fake', player); - ), - player ~ 'player_type' == 'shadow' && player ~ 'team' != 'shadow', - ( - global_team_cache:(player ~ 'name') = player ~ 'team'; - team_add('shadow', player); - ), - if (player ~ 'team' == 'fake' - || player ~ 'team' == 'shadow', - if (global_team_cache:(player ~ 'name') != null, - ( - team_add(global_team_cache:(player ~ 'name'), player); - delete(global_team_cache, player); - ), - team_leave(player); - ); - ); - ); -); - -__on_player_disconnects(player, reason) -> ( - debug(player ~ 'name'); - debug(player ~ 'player_type'); - debug(player ~ 'team'); - debug(global_team_cache); - if (player ~ 'team' == 'fake' - || player ~ 'team' == 'shadow', - debug(global_team_cache); - if (global_team_cache:(player ~ 'name') != null, - ( - team_add(global_team_cache:(player ~ 'name') , player); - delete(global_team_cache:(player ~ 'name')); - ), - team_leave(player); - ); - ); -); - -debug(msg) -> ( - logger('debug', msg); - return(); -); \ No newline at end of file