execute as @a[team=friends] at @s run scoreboard players add @s timer 1

execute as @a[team=friends] at @s if score @s timer matches 20.. run scoreboard players add @s seconds 1
execute as @a[team=friends] at @s if score @s timer matches 20.. run scoreboard players set @s timer 0


execute as @a[team=friends] at @s if score @s seconds matches 60.. run scoreboard players add @s minutes 1
execute as @a[team=friends] at @s if score @s seconds matches 60.. run scoreboard players set @s seconds 0

execute as @a[team=friends] at @s if score @s minutes matches 60.. run scoreboard players add @s hours 1
execute as @a[team=friends] at @s if score @s minutes matches 60.. run scoreboard players set @s minutes 0



# Skip Level Give
execute as @a at @s unless entity @s[nbt={Inventory:[{Slot:7b}]}] if score @s level matches 94 run item replace entity @s hotbar.7 with minecraft:carrot_on_a_stick{SkipLevel:1b,display:{Name:'{"text":"Skip Level","color":"green","italic":"false"}'}}

execute as @a at @s unless entity @s[nbt={Inventory:[{Slot:7b}]}] if score @s level matches 75 run item replace entity @s hotbar.7 with minecraft:carrot_on_a_stick{SkipLevel:1b,display:{Name:'{"text":"Skip Level","color":"green","italic":"false"}'}}

execute as @a at @s unless entity @s[nbt={Inventory:[{Slot:7b}]}] if score @s level matches 64 run item replace entity @s hotbar.7 with minecraft:carrot_on_a_stick{SkipLevel:1b,display:{Name:'{"text":"Skip Level","color":"green","italic":"false"}'}}

execute as @a at @s unless entity @s[nbt={Inventory:[{Slot:7b}]}] if score @s level matches 65 run item replace entity @s hotbar.7 with minecraft:carrot_on_a_stick{SkipLevel:1b,display:{Name:'{"text":"Skip Level","color":"green","italic":"false"}'}}

execute as @a at @s unless entity @s[nbt={Inventory:[{Slot:7b}]}] if score @s level matches 62 run item replace entity @s hotbar.7 with minecraft:carrot_on_a_stick{SkipLevel:1b,display:{Name:'{"text":"Skip Level","color":"green","italic":"false"}'}}

execute as @a at @s unless entity @s[nbt={Inventory:[{Slot:7b}]}] if score @s level matches 57 run item replace entity @s hotbar.7 with minecraft:carrot_on_a_stick{SkipLevel:1b,display:{Name:'{"text":"Skip Level","color":"green","italic":"false"}'}}


# -

execute as @a[nbt={SelectedItem:{tag:{GoToCheckpoint:1b}}},scores={click=1..}] at @s run function ps:go_to_checkpoint

execute as @a[nbt={SelectedItem:{tag:{SetCheckpoint:1b}}},scores={click=1..}] at @s if block ~ ~ ~ air run function ps:set_checkpoint_2

execute as @a[nbt={SelectedItem:{tag:{SetCheckpoint:1b}}},scores={click=1..}] at @s if block ~ ~ ~ air run tellraw @s {"text":"Checkpoint set!","color":"green"}

execute as @a[nbt={SelectedItem:{tag:{SetCheckpoint:1b}}},scores={click=1..}] at @s unless block ~ ~ ~ air run tellraw @s {"text":"Cannot set checkpoint here!","color":"red"}


# Set SpawnPoint
execute as @a at @s if entity @s if block ~ 255 ~ minecraft:dropper if predicate ps:in_on_map run function ps:set_checkpoint


# Go to checkpoint give
execute as @a at @s unless entity @s[nbt={Inventory:[{Slot:8b}]}] run item replace entity @s hotbar.8 with minecraft:carrot_on_a_stick{GoToCheckpoint:1b,display:{Name:'{"text":"Go to checkpoint","color":"aqua","italic":"false"}'}}





# Set Checkpoint clear
execute as @a at @s unless score @s level matches 70 unless score @s level matches 50 run clear @s minecraft:carrot_on_a_stick{SetCheckpoint:1b}



# Skip level clear
execute as @a at @s unless score @s level matches 94 unless score @s level matches 75 unless score @s level matches 64 unless score @s level matches 65 unless score @s level matches 57 unless score @s level matches 62 run clear @s minecraft:carrot_on_a_stick{SkipLevel:1b}







#Skip level Tp
execute as @a[scores={click=1..},nbt={SelectedItem:{tag:{SkipLevel:1b}}}] at @s if score @s level matches 57 run tp @s 40 -51 80
execute as @a[scores={click=1..},nbt={SelectedItem:{tag:{SkipLevel:1b}}}] at @s if score @s level matches 62 run tp @s 24 -51 91
execute as @a[scores={click=1..},nbt={SelectedItem:{tag:{SkipLevel:1b}}}] at @s if score @s level matches 64 run tp @s 56 -47 96
execute as @a[scores={click=1..},nbt={SelectedItem:{tag:{SkipLevel:1b}}}] at @s if score @s level matches 65 run tp @s 72 -51 101
execute as @a[scores={click=1..},nbt={SelectedItem:{tag:{SkipLevel:1b}}}] at @s if score @s level matches 75 run tp @s 55 -47 117
execute as @a[scores={click=1..},nbt={SelectedItem:{tag:{SkipLevel:1b}}}] at @s if score @s level matches 94 run tp @s 88 -52 144

# Set checkpoint give
execute as @a at @s unless entity @s[nbt={Inventory:[{Slot:7b}]}] if score @s level matches 50 run item replace entity @s hotbar.7 with minecraft:carrot_on_a_stick{SetCheckpoint:1b,display:{Name:'{"text":"Set checkpoint","color":"yellow","italic":"false"}'}}

execute as @a at @s unless entity @s[nbt={Inventory:[{Slot:7b}]}] if score @s level matches 70 run item replace entity @s hotbar.7 with minecraft:carrot_on_a_stick{SetCheckpoint:1b,display:{Name:'{"text":"Set checkpoint","color":"yellow","italic":"false"}'}}






scoreboard players reset @a click