Version verification

The **version verification** system guarantees that all modules are using the same Nexus version, that the Nexus is installed, and that any dependencies are installed. If any errors are found, they will be sent in the chat with download links to the needed data packs and instructions for how to correct duplicate modules.

## The main verification function

The version verification system starts with the function `nexus:verify/main` which is found in the Nexus and every module, and is identical for all of them. It is listed in the function tag `#minecraft:load` and is the first function in the Nexus network of data packs to execute. The function prepares a storage array and runs two function tags, `#nexus:verify/version` which makes each data pack add a compound to the array which contains the ID and version of the data pack, and `#nexus:verify/check` which makes each data pack check to make sure that all the data packs that it has a dependency for exist. Because the main function exists in every data pack, the Nexus does not actually need to be installed for the system to function.

If issues are found, it will schedule itself to run again in 3 seconds to ensure that the player sees the error message, even if they miss the first one.

If no issues are found, the setup procedure is activated.

```
nexus:verify/main

```

```
# Create scoreboard objective

scoreboard objectives add nexus.value dummy

# Initialize scores

scoreboard players set #doms_nexus_error_boolean nexus.value 0

# Verify modules

data modify storage nexus:data modules set value []
function #nexus:verify/version
function #nexus:verify/check

# Setup Nexus

execute if score #doms_nexus_error_boolean nexus.value matches 1 run tellraw @a ["",{"text":"[","color":"red"},{"text":"Dom's Nexus","color":"blue"},{"text":"]","color":"red"}," ",{"text":"Nexus and modules were unable to install.","color":"red"}]
execute if score #doms_nexus_error_boolean nexus.value matches 1 run schedule function nexus:verify/main 3s replace
execute if score #doms_nexus_error_boolean nexus.value matches 0 run schedule clear nexus:verify/main
execute if score #doms_nexus_error_boolean nexus.value matches 0 run function nexus:setup/main

```

## Module version verification

The two function tags executed in `nexus:verify/main` reference functions in each of the data packs. These functions are contained in `<namespace>:verify/<version>/<version/check>`. References to the functions will be from the Template Module.

### Version

The version function adds a compound to the storage array which contains the module ID and version of the data pack.

```
temp:verify/1_3_1/version

```

```
# Add pack version ID to module list

data modify storage nexus:data modules append value {id:"template_module",version:{major:1,minor:3,patch:0}}

```

### Check

The check function scans the compiled array for specific compounds to make sure that all the data packs that it has a dependency for are present, that only one of each of these exist, and that duplicates of itself do not exist. It uses the semver versioning system, MAJOR.MINOR.PATCH, where MAJOR is used for breaking changes, MINOR is used for adjustments that require small fixes, and PATCH adds new features that don't require updating the modules. This way, the Nexus or a library module can be updated independently of a module. If any issues are found, it will send an error in the chat and will set the error boolean so that the Nexus will not setup.

```
temp:verify/1_3_1/check

```

```
# Throw error if "Dom's Nexus" is not installed properly

execute store result score #module_count nexus.value if data storage nexus:data modules[{id:"doms_nexus"}]
execute unless score #module_count nexus.value matches 1 run scoreboard players set #doms_nexus_error_boolean nexus.value 1
execute if score #module_count nexus.value matches 000 run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Dom's Nexus","color":"blue"},{"text":" is not installed.","color":"red"}," ",{"text":"Click here to download.","color":"red","underlined":true,"hoverEvent":{"action":"show_text","value":[{"text":"Dom's Nexus","color":"blue"},{"text":" download","color":"gray"}]},"clickEvent":{"action":"open_url","value":"https://github.com/Dominexis/Doms-Nexus/releases"}}]
execute if score #module_count nexus.value matches 2.. run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Multiple copies of ","color":"red"},{"text":"Dom's Nexus","color":"blue"},{"text":" exist. Remove all outdated versions.","color":"red"}]

scoreboard players set #expected_major nexus.value 2
scoreboard players set #expected_minor nexus.value 0
scoreboard players set #expected_patch nexus.value 0
scoreboard players set #installed_major nexus.value 0
scoreboard players set #installed_minor nexus.value 0
scoreboard players set #installed_patch nexus.value 0

execute if score #module_count nexus.value matches 1 store result score #installed_major nexus.value run data get storage nexus:data modules[{id:"doms_nexus"}].version.major
execute if score #module_count nexus.value matches 1 store result score #installed_minor nexus.value run data get storage nexus:data modules[{id:"doms_nexus"}].version.minor
execute if score #module_count nexus.value matches 1 store result score #installed_patch nexus.value run data get storage nexus:data modules[{id:"doms_nexus"}].version.patch
execute if score #module_count nexus.value matches 1 unless score #installed_major nexus.value = #expected_major nexus.value run scoreboard players set #doms_nexus_error_boolean nexus.value 1
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value < #expected_major nexus.value run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Dom's Nexus","color":"blue"}," ",{"score":{"name":"#installed_major","objective":"nexus.value"},"color":"gold"},{"text":".x.x","color":"gold"},{"text":" is too old, update it to the latest version.","color":"red"}," ",{"text":"Click here to download.","color":"red","underlined":true,"hoverEvent":{"action":"show_text","value":[{"text":"Dom's Nexus","color":"blue"},{"text":" download","color":"gray"}]},"clickEvent":{"action":"open_url","value":"https://github.com/Dominexis/Doms-Nexus/releases"}}]
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value > #expected_major nexus.value run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Dom's Nexus","color":"blue"}," ",{"score":{"name":"#installed_major","objective":"nexus.value"},"color":"gold"},{"text":".x.x","color":"gold"},{"text":" is too new, update ","color":"red"},{"text":"Template Module","color":"gold"},{"text":" to the latest version.","color":"red"}," ",{"text":"Click here to download.","color":"red","underlined":true,"hoverEvent":{"action":"show_text","value":[{"text":"Template Module","color":"gold"},{"text":" download","color":"gray"}]},"clickEvent":{"action":"open_url","value":"https://github.com/Dominexis/Template-Module/releases"}}]
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value = #expected_major nexus.value unless score #installed_minor nexus.value = #expected_minor nexus.value run scoreboard players set #doms_nexus_error_boolean nexus.value 1
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value = #expected_major nexus.value if score #installed_minor nexus.value < #expected_minor nexus.value run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Dom's Nexus","color":"blue"}," ",{"score":{"name":"#installed_major","objective":"nexus.value"},"color":"gold"},{"text":".","color":"gold"},{"score":{"name":"#installed_minor","objective":"nexus.value"},"color":"gold"},{"text":".x","color":"gold"},{"text":" is too old, update it to the latest version.","color":"red"}," ",{"text":"Click here to download.","color":"red","underlined":true,"hoverEvent":{"action":"show_text","value":[{"text":"Dom's Nexus","color":"blue"},{"text":" download","color":"gray"}]},"clickEvent":{"action":"open_url","value":"https://github.com/Dominexis/Doms-Nexus/releases"}}]
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value = #expected_major nexus.value if score #installed_minor nexus.value > #expected_minor nexus.value run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Dom's Nexus","color":"blue"}," ",{"score":{"name":"#installed_major","objective":"nexus.value"},"color":"gold"},{"text":".","color":"gold"},{"score":{"name":"#installed_minor","objective":"nexus.value"},"color":"gold"},{"text":".x","color":"gold"},{"text":" is too new, update ","color":"red"},{"text":"Template Module","color":"gold"},{"text":" to the latest version.","color":"red"}," ",{"text":"Click here to download.","color":"red","underlined":true,"hoverEvent":{"action":"show_text","value":[{"text":"Template Module","color":"gold"},{"text":" download","color":"gray"}]},"clickEvent":{"action":"open_url","value":"https://github.com/Dominexis/Template-Module/releases"}}]
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value = #expected_major nexus.value if score #installed_minor nexus.value = #expected_minor nexus.value unless score #installed_patch nexus.value >= #expected_patch nexus.value run scoreboard players set #doms_nexus_error_boolean nexus.value 1
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value = #expected_major nexus.value if score #installed_minor nexus.value = #expected_minor nexus.value if score #installed_patch nexus.value < #expected_patch nexus.value run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Dom's Nexus","color":"blue"}," ",{"score":{"name":"#installed_major","objective":"nexus.value"},"color":"gold"},{"text":".","color":"gold"},{"score":{"name":"#installed_minor","objective":"nexus.value"},"color":"gold"},{"text":".","color":"gold"},{"score":{"name":"#installed_patch","objective":"nexus.value"},"color":"gold"},{"text":" is too old, update it to the latest version.","color":"red"}," ",{"text":"Click here to download.","color":"red","underlined":true,"hoverEvent":{"action":"show_text","value":[{"text":"Dom's Nexus","color":"blue"},{"text":" download","color":"gray"}]},"clickEvent":{"action":"open_url","value":"https://github.com/Dominexis/Doms-Nexus/releases"}}]

# Throw error if "Function Tree Library" is not installed properly

execute store result score #module_count nexus.value if data storage nexus:data modules[{id:"function_tree_library"}]
execute unless score #module_count nexus.value matches 1 run scoreboard players set #doms_nexus_error_boolean nexus.value 1
execute if score #module_count nexus.value matches 000 run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Function Tree Library","color":"gold"},{"text":" is not installed.","color":"red"}," ",{"text":"Click here to download.","color":"red","underlined":true,"hoverEvent":{"action":"show_text","value":[{"text":"Function Tree Library","color":"gold"},{"text":" download","color":"gray"}]},"clickEvent":{"action":"open_url","value":"https://github.com/Dominexis/Function-Tree-Library/releases"}}]
execute if score #module_count nexus.value matches 2.. run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Multiple copies of ","color":"red"},{"text":"Function Tree Library","color":"gold"},{"text":" exist. Remove all outdated versions.","color":"red"}]

scoreboard players set #expected_major nexus.value 1
scoreboard players set #expected_minor nexus.value 2
scoreboard players set #expected_patch nexus.value 0
scoreboard players set #installed_major nexus.value 0
scoreboard players set #installed_minor nexus.value 0
scoreboard players set #installed_patch nexus.value 0

execute if score #module_count nexus.value matches 1 store result score #installed_major nexus.value run data get storage nexus:data modules[{id:"function_tree_library"}].version.major
execute if score #module_count nexus.value matches 1 store result score #installed_minor nexus.value run data get storage nexus:data modules[{id:"function_tree_library"}].version.minor
execute if score #module_count nexus.value matches 1 store result score #installed_patch nexus.value run data get storage nexus:data modules[{id:"function_tree_library"}].version.patch
execute if score #module_count nexus.value matches 1 unless score #installed_major nexus.value = #expected_major nexus.value run scoreboard players set #doms_nexus_error_boolean nexus.value 1
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value < #expected_major nexus.value run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Function Tree Library","color":"gold"}," ",{"score":{"name":"#installed_major","objective":"nexus.value"},"color":"gold"},{"text":".x.x","color":"gold"},{"text":" is too old, update it to the latest version.","color":"red"}," ",{"text":"Click here to download.","color":"red","underlined":true,"hoverEvent":{"action":"show_text","value":[{"text":"Function Tree Library","color":"gold"},{"text":" download","color":"gray"}]},"clickEvent":{"action":"open_url","value":"https://github.com/Dominexis/Function-Tree-Library/releases"}}]
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value > #expected_major nexus.value run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Function Tree Library","color":"gold"}," ",{"score":{"name":"#installed_major","objective":"nexus.value"},"color":"gold"},{"text":".x.x","color":"gold"},{"text":" is too new, update ","color":"red"},{"text":"Template Module","color":"gold"},{"text":" to the latest version.","color":"red"}," ",{"text":"Click here to download.","color":"red","underlined":true,"hoverEvent":{"action":"show_text","value":[{"text":"Template Module","color":"gold"},{"text":" download","color":"gray"}]},"clickEvent":{"action":"open_url","value":"https://github.com/Dominexis/Template-Module/releases"}}]
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value = #expected_major nexus.value unless score #installed_minor nexus.value = #expected_minor nexus.value run scoreboard players set #doms_nexus_error_boolean nexus.value 1
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value = #expected_major nexus.value if score #installed_minor nexus.value < #expected_minor nexus.value run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Function Tree Library","color":"gold"}," ",{"score":{"name":"#installed_major","objective":"nexus.value"},"color":"gold"},{"text":".","color":"gold"},{"score":{"name":"#installed_minor","objective":"nexus.value"},"color":"gold"},{"text":".x","color":"gold"},{"text":" is too old, update it to the latest version.","color":"red"}," ",{"text":"Click here to download.","color":"red","underlined":true,"hoverEvent":{"action":"show_text","value":[{"text":"Function Tree Library","color":"gold"},{"text":" download","color":"gray"}]},"clickEvent":{"action":"open_url","value":"https://github.com/Dominexis/Function-Tree-Library/releases"}}]
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value = #expected_major nexus.value if score #installed_minor nexus.value > #expected_minor nexus.value run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Function Tree Library","color":"gold"}," ",{"score":{"name":"#installed_major","objective":"nexus.value"},"color":"gold"},{"text":".","color":"gold"},{"score":{"name":"#installed_minor","objective":"nexus.value"},"color":"gold"},{"text":".x","color":"gold"},{"text":" is too new, update ","color":"red"},{"text":"Template Module","color":"gold"},{"text":" to the latest version.","color":"red"}," ",{"text":"Click here to download.","color":"red","underlined":true,"hoverEvent":{"action":"show_text","value":[{"text":"Template Module","color":"gold"},{"text":" download","color":"gray"}]},"clickEvent":{"action":"open_url","value":"https://github.com/Dominexis/Template-Module/releases"}}]
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value = #expected_major nexus.value if score #installed_minor nexus.value = #expected_minor nexus.value unless score #installed_patch nexus.value >= #expected_patch nexus.value run scoreboard players set #doms_nexus_error_boolean nexus.value 1
execute if score #module_count nexus.value matches 1 if score #installed_major nexus.value = #expected_major nexus.value if score #installed_minor nexus.value = #expected_minor nexus.value if score #installed_patch nexus.value < #expected_patch nexus.value run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Function Tree Library","color":"gold"}," ",{"score":{"name":"#installed_major","objective":"nexus.value"},"color":"gold"},{"text":".","color":"gold"},{"score":{"name":"#installed_minor","objective":"nexus.value"},"color":"gold"},{"text":".","color":"gold"},{"score":{"name":"#installed_patch","objective":"nexus.value"},"color":"gold"},{"text":" is too old, update it to the latest version.","color":"red"}," ",{"text":"Click here to download.","color":"red","underlined":true,"hoverEvent":{"action":"show_text","value":[{"text":"Function Tree Library","color":"gold"},{"text":" download","color":"gray"}]},"clickEvent":{"action":"open_url","value":"https://github.com/Dominexis/Function-Tree-Library/releases"}}]

# Throw error if multiple copies of the module are loaded

execute store result score #module_count nexus.value if data storage nexus:data modules[{id:"template_module"}]
execute if score #module_count nexus.value matches 2.. run scoreboard players set #doms_nexus_error_boolean nexus.value 1
execute if score #module_count nexus.value matches 2.. run tellraw @a ["",{"text":"[","color":"red"},{"text":"Template Module","color":"gold"},{"text":"]","color":"red"}," ",{"text":"Error: ","color":"dark_red"},{"text":"Multiple copies of ","color":"red"},{"text":"Template Module","color":"gold"},{"text":" exist. Remove all outdated versions.","color":"red"}]

```

## Module Manager

The version verification system can be quite tedious to put together and maintain manually. The Module Manager exists to maintain this and more automatically.

## History

 1.7.0
 1.8.0
 1.9.0
 1.9.1
 1.10.0
 2.0.0
 2.0.1
Changed the format of the error messages to make the download link easier to find.

## See also

* Module
* Setup
* Generic functions
* Concepts