scoreboard players reset @s garbage.common.collected
scoreboard players reset @s garbage.uncommon.collected
scoreboard players reset @s garbage.epic.collected
scoreboard players reset @s garbage.legendary.collected

scoreboard players add @s[scores={weight.level=..14}] scavenger.debuff 1
scoreboard players set @s[scores={weight.level=15..}] scavenger.debuff 0
function ws:misc/stats/scavengerdebuff

title @s actionbar " "

execute store result score @s garbage.common.collected run random value 2..4
scoreboard players operation @s garbage.common += @s garbage.common.collected

execute store result score @s garbage.roll run random value 1..1000
execute if score @s garbage.roll matches ..150 store result score @s garbage.uncommon.collected run random value 1..2
scoreboard players operation @s garbage.uncommon += @s garbage.uncommon.collected

execute store result score @s garbage.roll run random value 1..1000
execute if score @s garbage.roll matches ..70 store result score @s garbage.epic.collected run random value 1..2
scoreboard players operation @s garbage.epic += @s garbage.epic.collected

execute store result score @s garbage.roll run random value 1..1000
execute if score @s garbage.roll matches ..10 store result score @s garbage.legendary.collected run random value 1..2
scoreboard players operation @s garbage.legendary += @s garbage.legendary.collected

tellraw @s [{"bold":true,"color":"aqua","translate":"scavenger.collected"}]
tellraw @s [{"color":"aqua","bold":true,"text":"> "},{"color":"gray","bold":false,"hoverEvent":{"action":"show_text","value":[{"translate":"scavenger.total","color":"gray"},{"score":{"name":"@s","objective":"garbage.common"}}]},"translate":"scavenger.common","underlined":true},": ",{"color":"gray","bold":true,"score":{"name":"@s","objective":"garbage.common.collected"}}]
execute if score @s garbage.uncommon.collected matches 1.. run tellraw @s [{"color":"aqua","bold":true,"text":"> "},{"color":"green","bold":false,"hoverEvent":{"action":"show_text","value":[{"translate":"scavenger.total","color":"green"},{"score":{"name":"@s","objective":"garbage.uncommon"}}]},"translate":"scavenger.uncommon","underlined":true},": ",{"color":"green","bold":true,"score":{"name":"@s","objective":"garbage.uncommon.collected"}}]
execute if score @s garbage.epic.collected matches 1.. run tellraw @s [{"color":"aqua","bold":true,"text":"> "},{"color":"dark_purple","bold":false,"hoverEvent":{"action":"show_text","value":[{"translate":"scavenger.total","color":"dark_purple"},{"score":{"name":"@s","objective":"garbage.epic"}}]},"translate":"scavenger.epic","underlined":true},": ",{"color":"dark_purple","bold":true,"score":{"name":"@s","objective":"garbage.epic.collected"}}]
execute if score @s garbage.legendary.collected matches 1.. run tellraw @s [{"color":"aqua","bold":true,"text":"> "},{"color":"gold","bold":true,"hoverEvent":{"action":"show_text","value":[{"translate":"scavenger.total","color":"gold","bold":true},{"score":{"name":"@s","objective":"garbage.legendary"}}]},"translate":"scavenger.legendary","underlined":true},": ",{"color":"gold","bold":true,"score":{"name":"@s","objective":"garbage.legendary.collected"}}]
tellraw @s [{"text":"\n"},{"translate":"scavenger.hover"}]
tellraw @s[scores={weight.level=..14}] [{"text":"\n\n"},{"translate":"scavenger.debuff","color":"gray"}]

execute at @s run playsound minecraft:block.ender_chest.open player @s ~ ~ ~ 1 1
execute if score @s garbage.legendary.collected matches 1.. at @s run return run playsound minecraft:ui.toast.challenge_complete player @s ~ ~ ~ 1 1
execute if score @s garbage.epic.collected matches 1.. at @s run return run playsound minecraft:block.enchantment_table.use player @s ~ ~ ~ 1 0
execute if score @s garbage.uncommon.collected matches 1.. at @s run return run playsound minecraft:entity.experience_orb.pickup player @s ~ ~ ~ 1 0