#Reset click detection when player click on the wrong villager
scoreboard players reset @a[x=518,y=89,z=467,rm=6] BarClick

#Reset click detection when the barman is already making the coffee
execute @e[name=Marc,type=armor_stand,score_BarAnimation_min=100] ~ ~ ~ tellraw @a[score_BarClick_min=1] ["",{"text":"Barman:","bold":true,"color":"dark_aqua"},{"text":" "},{"text":"Come back in a second, I am busy right now.","color":"aqua"}]
execute @e[name=Marc,type=armor_stand,score_BarAnimation_min=100] ~ ~ ~ scoreboard players reset @a[score_BarClick_min=1] BarClick

#Already talking with someone
execute @a[tag=DrinkSelection] ~ ~ ~ tellraw @a[score_BarClick_min=1,tag=!DrinkSelection] ["",{"text":"Barman:","bold":true,"color":"dark_aqua"},{"text":" I am already talking with someone. Come back in a second.","color":"aqua"}]
tellraw @a[score_BarClick_min=1,tag=DrinkSelection] ["",{"text":"Barman:","bold":true,"color":"dark_aqua"},{"text":" Please answer my question by clicking on","color":"aqua"},{"text":" "},{"text":"[","color":"dark_aqua","clickEvent":{"action":"run_command","value":"/trigger SelectedDrink set 1"}},{"text":"Yes","color":"aqua","clickEvent":{"action":"run_command","value":"/trigger SelectedDrink set 1"}},{"text":"]","color":"dark_aqua","clickEvent":{"action":"run_command","value":"/trigger SelectedDrink set 1"}},{"text":" "},{"text":"or","color":"aqua"},{"text":" "},{"text":"[","color":"dark_aqua","clickEvent":{"action":"run_command","value":"/trigger SelectedDrink set 2"}},{"text":"No","color":"aqua","clickEvent":{"action":"run_command","value":"/trigger SelectedDrink set 2"}},{"text":"]","color":"dark_aqua","clickEvent":{"action":"run_command","value":"/trigger SelectedDrink set 2"}},{"text":".","color":"aqua"}]
execute @a[tag=DrinkSelection] ~ ~ ~ playsound minecraft:entity.villager.trading master @a[score_BarClick_min=1,tag=DrinkSelection]
execute @a[tag=DrinkSelection] ~ ~ ~ scoreboard players reset @a[score_BarClick_min=1] BarClick

#Tags
scoreboard players tag @a[score_BarClick_min=1,tag=!DrinkSelection,c=1] add InitDrinkSelection

scoreboard players tag @a[tag=InitDrinkSelection] add DrinkSelection
scoreboard players reset @a[score_BarClick_min=1] BarClick

#Tellraw of selection
execute @a[tag=InitDrinkSelection] ~ ~ ~ playsound entity.experience_orb.pickup master @s
execute @a[tag=InitDrinkSelection] ~ ~ ~ scoreboard players set @e[name=Marc,type=armor_stand,tag=!MarcCamera] BarAnimation 1
scoreboard players set @a[tag=InitDrinkSelection] BarAnimation 160
tellraw @a[tag=InitDrinkSelection] ["",{"text":"Barman:","bold":true,"color":"dark_aqua"},{"text":" "},{"text":"Hey there! Would you want a cup of coffee?","color":"aqua"},{"text":"\n"},{"text":"[","color":"dark_aqua","clickEvent":{"action":"run_command","value":"/trigger SelectedDrink set 1"}},{"text":"Yes","color":"aqua","clickEvent":{"action":"run_command","value":"/trigger SelectedDrink set 1"}},{"text":"]","color":"dark_aqua","clickEvent":{"action":"run_command","value":"/trigger SelectedDrink set 1"}},{"text":" ","color":"dark_aqua"},{"text":"-","color":"aqua"},{"text":" ","color":"dark_aqua"},{"text":"[","color":"dark_aqua","clickEvent":{"action":"run_command","value":"/trigger SelectedDrink set 2"}},{"text":"No","color":"aqua","clickEvent":{"action":"run_command","value":"/trigger SelectedDrink set 2"}},{"text":"]","color":"dark_aqua","clickEvent":{"action":"run_command","value":"/trigger SelectedDrink set 2"}}]
scoreboard players tag @a[tag=InitDrinkSelection] remove InitDrinkSelection