
# -> Reset adv trigger
advancement revoke @s only overly_realistic:items/use_diamond_ring

# -> Get amount of players online
scoreboard players set #or.global OverlyRealistic.General.ArbitraryData 0
execute store result score #or.global OverlyRealistic.General.ArbitraryData \
    if entity @a[tag=OverlyRealistic.Player.IsGhost,x=0]

# -> If there are no players online then return
execute if score #or.global OverlyRealistic.General.ArbitraryData matches ..0 run \
    return run \
        function overly_realistic:players/revive/revive_warning_no_players

# -> Spawn a player
execute as @p[gamemode=spectator,tag=OverlyRealistic.Player.IsGhost] run \
    function overly_realistic:players/revive/revive_player

# -> Particles
particle heart ~ ~1 ~ 0.3 0.3 0.3 0.1 10 normal @a

# -> Sound
playsound entity.experience_orb.pickup player @a ~ ~ ~ 0.35 2

# -> Remove item
execute if items entity @s weapon.mainhand poisonous_potato[custom_data~{IsDiamondRing:true}] run \
    return run \
        item replace entity @s weapon.mainhand with air
item replace entity @s weapon.offhand with air