scoreboard players reset @a necromancer_count
scoreboard players set world Boss_Wave_Check 0
scoreboard players set world Boss_Death_Check 0
scoreboard players set world ongoing_run 0
scoreboard players set world Run_Active 0
scoreboard players set world NextWaveTimer 0
scoreboard players set world WaveCounter 0
scoreboard players set world teleport_countdown 0
scoreboard players set @a necromancer_summon_count 0
scoreboard players set @a necromancer_current_souls 0
scoreboard players reset @a class_ability_scoreboard
tag @a remove limitbreak_dead_player
tag @a remove eternium_set_second_wind_activated
tag @a remove limitbreak_non_melee_class
tag @a remove magus_tier_2_unlocked
tag @a remove magus_tier_3_unlocked
tag @a remove magus_unstable_check_tier_1
tag @a remove magus_unstable_check_tier_2
tag @a remove magus_unstable_check_tier_3
tag @a remove skill_window
tag @a remove flicker_strike_ready
tag @a remove flicker_striked
tag @a remove necromancer_max_armor
bossbar remove mana_bar
bossbar remove mana_bar2
bossbar remove mana_bar3
bossbar remove mana_bar4
bossbar remove mana_bar5
bossbar remove mana_bar6
bossbar remove mana_bar7
bossbar remove mana_bar8
bossbar remove mana_bar9
bossbar remove mana_bar10
bossbar remove soul_bar
bossbar remove soul_bar2
bossbar remove soul_bar3
bossbar remove soul_bar4
bossbar remove soul_bar5
bossbar remove soul_bar6
bossbar remove soul_bar7
bossbar remove soul_bar8
bossbar remove soul_bar9
bossbar remove soul_bar10
clear @a
xp set @a 0 levels
xp set @a 0 points
execute as @a at @s run function kiwi2:points/remove_all_milestones
execute as @a at @s run function kiwi2:upgrades/classes/class_modifiers_remove

scoreboard players reset @a PlayerJoined
gamemode survival @a
time set midnight
execute as @a at @s run scoreboard players operation @s credit_save_bank = @s Credits
execute as @a at @s run scoreboard players set @s Credits 0
execute as @a at @s run scoreboard objectives setdisplay list Points
scoreboard players set @a Points 0
scoreboard players set world ongoing_run 1
tellraw @a [{"text": "Remaining "},{"color":"#76BDF8","text": "⌬ Credits"},{"text": " have been put in your bank."}]
clear @a
scoreboard players enable @a EndRun
execute as @a[scores={limitbreak_chosen_class=1}] at @s run function kiwi2:upgrades/classes/slayer/slayer_class_give
execute as @a[scores={limitbreak_chosen_class=2}] at @s run function kiwi2:upgrades/classes/knight/knight_class_give
execute as @a[scores={limitbreak_chosen_class=3}] at @s run function kiwi2:upgrades/classes/hunter/hunter_class_give
execute as @a[scores={limitbreak_chosen_class=4}] at @s run function kiwi2:upgrades/classes/apothecary/apothecary_class_give
execute as @a[scores={limitbreak_chosen_class=5}] at @s run function kiwi2:upgrades/classes/magus/magus_class_give
execute as @a[scores={limitbreak_chosen_class=6}] at @s run function kiwi2:upgrades/classes/reaper/reaper_class_give
execute as @a[scores={limitbreak_chosen_class=7}] at @s run function kiwi2:upgrades/classes/monk/monk_class_give
execute as @a[scores={limitbreak_chosen_class=8}] at @s run function kiwi2:upgrades/classes/necromancer/necromancer_class_give
recipe give @a kiwi:charged_book
recipe give @a kiwi:colossal_book
recipe give @a kiwi:frostfire_book
recipe give @a kiwi:iron_strengthened_bow
recipe give @a kiwi:diamond_strengthened_bow
recipe give @a kiwi:netherite_strengthened_bow
recipe give @a kiwi:starred_book
recipe give @a kiwi:starred_weapon_book
give @a structure_block[item_model="minecraft:chest",custom_data={storage:1b},custom_name='{"bold":false,"color":"yellow","italic":false,"text":"Portable Storage"}'] 1
execute in kiwi2:limitbreak_run_dimension run kill @e[type=!player,tag=!limitbreak_starting_mob,distance=..9999]
scoreboard players set world RewardChestChance 20

# Starting Points
execute if score starting_points world_upgrades matches 1.. run function kiwi2:upgrades/world_upgrades/starting_points/starting_points_apply
# Reward Chest Chance
execute if score reward_chest_chance world_upgrades matches 1.. run function kiwi2:upgrades/world_upgrades/reward_chest_chance/reward_chest_chance_apply