scoreboard players enable @a sgrave.list
scoreboard players enable @a sgrave.loot
scoreboard players enable @a sgrave.delete

execute store result score #immediate_respawn sgrave.rulesCheck run gamerule immediate_respawn

execute if score #immediate_respawn sgrave.rulesCheck matches 0..1 run function snapgrave:notifications/immediate_respawn

execute as @a unless score @s sgrave.day matches 0.. run function snapgrave:get/day/first_join/init

#execute as @e[type=marker,tag=sgrave] at @s run particle happy_villager ~ ~ ~ 0 0 0 0 1 normal


execute as @a[scores={sgrave.list=1..}] run function snapgrave:dialog/run

execute as @a[scores={sgrave.delete=1..}] run function snapgrave:dialog/delete/run

execute as @a[scores={sgrave.loot=1..}] run function snapgrave:dialog/loot/run

execute as @a[tag=sgrave.deleting] if score @s sgrave.deleting matches 1.. run scoreboard players remove @s sgrave.deleting 1
execute as @a[tag=sgrave.deleting] if score @s sgrave.deleting matches 10 run function snapgrave:dialog/delete/kill/init
execute as @a[tag=sgrave.deleting] if score @s sgrave.deleting matches 0 run function snapgrave:dialog/delete/unload/init
execute as @a[tag=sgrave.deleting] if score @s sgrave.deleting matches 0 run tag @s remove sgrave.deleting

execute if data storage sgrave:settings {looting:1} if data storage sgrave:settings {deleting:0} run data modify storage sgrave:settings deleting set value 1
execute if data storage sgrave:settings {Glowing:1} as @e[tag=sgrave.grave] at @s unless data entity @s {Glowing:1b} run data merge entity @s {Glowing:1b}
execute if data storage sgrave:settings {Glowing:0} as @e[tag=sgrave.grave] at @s unless data entity @s {Glowing:0b} run data merge entity @s {Glowing:0b}