fz-survival-datapack/data/fz/functions/load.mcfunction
2021-08-03 06:52:38 +08:00

22 lines
2.5 KiB
Mcfunction

#新版本号
data modify storage fz:survival newVersion set value [2,1,3,2]
execute if data storage fz:survival newVersion[3] run data modify storage fz:survival snapshot set value 1b
execute unless data storage fz:survival newVersion[3] run data remove storage fz:survival snapshot
##data remove storage fz:survival snapshot
#版本号识别
scoreboard objectives add fz.cache dummy
execute store result score version1 fz.cache run data get storage fz:survival version[1]
execute store result score version2 fz.cache run data get storage fz:survival version[2]
execute store result score version3 fz.cache run data get storage fz:survival version[3]
execute store result score newVersion1 fz.cache run data get storage fz:survival newVersion[1]
execute store result score newVersion2 fz.cache run data get storage fz:survival newVersion[2]
execute store result score newVersion3 fz.cache run data get storage fz:survival newVersion[3]
#版本号比较
execute if data storage fz:survival installed{datapack: 1b} unless score version1 fz.cache = newVersion1 fz.cache run function fz:start/update
execute if data storage fz:survival installed{datapack: 1b} if score version1 fz.cache = newVersion1 fz.cache run function fz:start/00xx
scoreboard objectives remove fz.cache
#如果未安装且未卸载则安装
execute unless data storage fz:survival installed{datapack: 1b} unless data storage fz:survival installed{datapack: 0b} run function fz:install
#输出版本信息
execute unless data storage fz:survival {snapshot:1b} unless data storage fz:survival installed{datapack: 0b} run tellraw @a [{"text": "[版本信息]FZ's Datapack-","color": "#ffd900"},{"nbt":"version[0]","storage":"fz:survival","color": "#ffd900"},{"text":".","color": "#ffd900"},{"nbt":"version[1]","storage":"fz:survival","color": "#ffd900"},{"text": ".","color": "#ffd900"},{"nbt":"version[2]","storage":"fz:survival","color": "#ffd900"}]
execute if data storage fz:survival {snapshot:1b} unless data storage fz:survival installed{datapack: 0b} run tellraw @a [{"text": "[版本信息]FZ's Datapack-","color": "#ffd900"},{"nbt":"version[0]","storage":"fz:survival","color": "#ffd900"},{"text":".","color": "#ffd900"},{"nbt":"version[1]","storage":"fz:survival","color": "#ffd900"},{"text": ".","color": "#ffd900"},{"nbt":"version[2]","storage":"fz:survival","color": "#ffd900"},{"text": ".","color": "#ffd900"},{"nbt":"version[3]","storage":"fz:survival","color": "#ffd900"},{"text": "-SNAPSHOT","color": "red"}]