diff --git a/data/minecraft/tags/functions/load.json b/data/minecraft/tags/functions/load.json index efec2a0..369dfbf 100644 --- a/data/minecraft/tags/functions/load.json +++ b/data/minecraft/tags/functions/load.json @@ -1 +1 @@ -{"values": ["tct:load"]} \ No newline at end of file +{"values": ["tctvote:load"]} \ No newline at end of file diff --git a/data/minecraft/tags/functions/tick.json b/data/minecraft/tags/functions/tick.json index f486bab..2f76e3e 100644 --- a/data/minecraft/tags/functions/tick.json +++ b/data/minecraft/tags/functions/tick.json @@ -1 +1 @@ -{"values": ["tct:tick"]} \ No newline at end of file +{"values": ["tctvote:tick"]} \ No newline at end of file diff --git a/data/tct/functions/ayevote.mcfunction b/data/tct/functions/ayevote.mcfunction deleted file mode 100644 index 2cef076..0000000 --- a/data/tct/functions/ayevote.mcfunction +++ /dev/null @@ -1,2 +0,0 @@ -scoreboard players add AYE mt_vote_balance 1 -playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 2 \ No newline at end of file diff --git a/data/tct/functions/calc.mcfunction b/data/tct/functions/calc.mcfunction deleted file mode 100644 index 84f53a3..0000000 --- a/data/tct/functions/calc.mcfunction +++ /dev/null @@ -1,4 +0,0 @@ -execute as @a[scores={mt_vote_trigger=1}] run function tct:ayevote -execute as @a[scores={mt_vote_trigger=2}] run function tct:novote -execute as @a[scores={mt_vote_trigger=1..2}] run clear @s written_book{certified:votebook} 1 -execute as @a[scores={mt_vote_trigger=1..2}] run scoreboard players reset @s mt_vote_trigger \ No newline at end of file diff --git a/data/tct/functions/decrease.mcfunction b/data/tct/functions/decrease.mcfunction deleted file mode 100644 index 041af71..0000000 --- a/data/tct/functions/decrease.mcfunction +++ /dev/null @@ -1 +0,0 @@ -scoreboard players remove Remaining mt_vote_balance 1 \ No newline at end of file diff --git a/data/tct/functions/load.mcfunction b/data/tct/functions/load.mcfunction deleted file mode 100644 index 163ecc7..0000000 --- a/data/tct/functions/load.mcfunction +++ /dev/null @@ -1,2 +0,0 @@ -scoreboard objectives add mt_vote_balance dummy "Vote results" -scoreboard objectives add mt_vote_trigger trigger \ No newline at end of file diff --git a/data/tct/functions/notes/down_0.mcfunction b/data/tct/functions/notes/down_0.mcfunction deleted file mode 100644 index 133edcc..0000000 --- a/data/tct/functions/notes/down_0.mcfunction +++ /dev/null @@ -1,2 +0,0 @@ -playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 1.6 -schedule function tct:notes/down_1 5t \ No newline at end of file diff --git a/data/tct/functions/notes/down_1.mcfunction b/data/tct/functions/notes/down_1.mcfunction deleted file mode 100644 index 8b12826..0000000 --- a/data/tct/functions/notes/down_1.mcfunction +++ /dev/null @@ -1,2 +0,0 @@ -playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 1.2 -schedule function tct:notes/down_2 5t \ No newline at end of file diff --git a/data/tct/functions/notes/down_2.mcfunction b/data/tct/functions/notes/down_2.mcfunction deleted file mode 100644 index 2764419..0000000 --- a/data/tct/functions/notes/down_2.mcfunction +++ /dev/null @@ -1 +0,0 @@ -playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 0.8 \ No newline at end of file diff --git a/data/tct/functions/notes/up_0.mcfunction b/data/tct/functions/notes/up_0.mcfunction deleted file mode 100644 index 425699b..0000000 --- a/data/tct/functions/notes/up_0.mcfunction +++ /dev/null @@ -1,2 +0,0 @@ -playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 0.8 -schedule function tct:notes/up_1 5t \ No newline at end of file diff --git a/data/tct/functions/notes/up_1.mcfunction b/data/tct/functions/notes/up_1.mcfunction deleted file mode 100644 index e13f213..0000000 --- a/data/tct/functions/notes/up_1.mcfunction +++ /dev/null @@ -1,2 +0,0 @@ -playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 1.0 -schedule function tct:notes/up_2 5t \ No newline at end of file diff --git a/data/tct/functions/notes/up_2.mcfunction b/data/tct/functions/notes/up_2.mcfunction deleted file mode 100644 index eb9ba9b..0000000 --- a/data/tct/functions/notes/up_2.mcfunction +++ /dev/null @@ -1 +0,0 @@ -playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 1.6 \ No newline at end of file diff --git a/data/tct/functions/novote.mcfunction b/data/tct/functions/novote.mcfunction deleted file mode 100644 index 7f94a51..0000000 --- a/data/tct/functions/novote.mcfunction +++ /dev/null @@ -1,2 +0,0 @@ -scoreboard players add NO mt_vote_balance 1 -playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 1.6 \ No newline at end of file diff --git a/data/tct/functions/tick.mcfunction b/data/tct/functions/tick.mcfunction deleted file mode 100644 index ef89cbd..0000000 --- a/data/tct/functions/tick.mcfunction +++ /dev/null @@ -1 +0,0 @@ -execute as @a[scores={mt_vote_trigger=1..2}] run function tct:calc \ No newline at end of file diff --git a/data/tct/functions/vote_live.mcfunction b/data/tct/functions/vote_live.mcfunction deleted file mode 100644 index 360d462..0000000 --- a/data/tct/functions/vote_live.mcfunction +++ /dev/null @@ -1,39 +0,0 @@ -tellraw @a ["",{"text":"Vote >>","bold":true,"color":"dark_green"},{"text":" Vote using the voting book now!","bold":true,"color":"white"}] -scoreboard players reset * mt_vote_balance -scoreboard players reset * mt_vote_trigger -scoreboard players enable @a[tag=eligible] mt_vote_trigger -give @a[tag=eligible] minecraft:written_book{display:{Name:'{"text":"Voting Book","color":"white","bold":true}',Lore:['{"text":"Cast your vote now!"}']},certified:votebook,title:"Voting Book",author:"Kipje",pages:['[{"text":"Cast your vote!\\n Click AYE or NO below.\\n\\n\\n"},{"text":"AYE","color":"dark_green","bold":true,"hoverEvent":{"action":"show_text","contents":[{"text":"Click to vote AYE on this vote."}]},"clickEvent":{"action":"run_command","value":"/trigger mt_vote_trigger set 1"}},{"text":" | "},{"text":"NO","color":"red","bold":true,"hoverEvent":{"action":"show_text","contents":[{"text":"Click to vote NO on this vote."}]},"clickEvent":{"action":"run_command","value":"/trigger mt_vote_trigger set 2"}}]']} 1 -team add green "Green" -team modify green color dark_green -team add red "Red" -team modify red color red -team add yellow "Yellow" -team modify yellow color yellow -team join green AYE -team join red NO -team join yellow Remaining -scoreboard players set AYE mt_vote_balance 0 -scoreboard players set NO mt_vote_balance 0 -scoreboard players set Remaining mt_vote_balance 20 -scoreboard objectives setdisplay sidebar mt_vote_balance -schedule function tct:notes/up_0 5t -schedule function tct:decrease 1s append -schedule function tct:decrease 2s append -schedule function tct:decrease 3s append -schedule function tct:decrease 4s append -schedule function tct:decrease 5s append -schedule function tct:decrease 6s append -schedule function tct:decrease 7s append -schedule function tct:decrease 8s append -schedule function tct:decrease 9s append -schedule function tct:decrease 10s append -schedule function tct:decrease 11s append -schedule function tct:decrease 12s append -schedule function tct:decrease 13s append -schedule function tct:decrease 14s append -schedule function tct:decrease 15s append -schedule function tct:decrease 16s append -schedule function tct:decrease 17s append -schedule function tct:decrease 18s append -schedule function tct:decrease 19s append -schedule function tct:halt 20s \ No newline at end of file diff --git a/data/tct/functions/vote_nonlive.mcfunction b/data/tct/functions/vote_nonlive.mcfunction deleted file mode 100644 index 7b8a1a3..0000000 --- a/data/tct/functions/vote_nonlive.mcfunction +++ /dev/null @@ -1,38 +0,0 @@ -tellraw @a ["",{"text":"Vote >>","bold":true,"color":"dark_green"},{"text":" Vote using the voting book now!","bold":true,"color":"white"}] -scoreboard players reset * mt_vote_balance -scoreboard players reset * mt_vote_trigger -scoreboard players enable @a[tag=eligible] mt_vote_trigger -give @a[tag=eligible] minecraft:written_book{display:{Name:'{"text":"Voting Book","color":"white","bold":true}',Lore:['{"text":"Cast your vote now!"}']},certified:votebook,title:"Voting Book",author:"Kipje",pages:['[{"text":"Cast your vote!\\n Click AYE or NO below.\\n\\n\\n"},{"text":"AYE","color":"dark_green","bold":true,"hoverEvent":{"action":"show_text","contents":[{"text":"Click to vote AYE on this vote."}]},"clickEvent":{"action":"run_command","value":"/trigger mt_vote_trigger set 1"}},{"text":" | "},{"text":"NO","color":"red","bold":true,"hoverEvent":{"action":"show_text","contents":[{"text":"Click to vote NO on this vote."}]},"clickEvent":{"action":"run_command","value":"/trigger mt_vote_trigger set 2"}}]']} 1 -team add green "Green" -team modify green color dark_green -team add red "Red" -team modify red color red -team add yellow "Yellow" -team modify yellow color yellow -team join green AYE -team join red NO -team join yellow Remaining -scoreboard players set AYE mt_vote_balance 0 -scoreboard players set NO mt_vote_balance 0 -scoreboard players set Remaining mt_vote_balance 20 -schedule function tct:notes/up_0 5t -schedule function tct:decrease 1s append -schedule function tct:decrease 2s append -schedule function tct:decrease 3s append -schedule function tct:decrease 4s append -schedule function tct:decrease 5s append -schedule function tct:decrease 6s append -schedule function tct:decrease 7s append -schedule function tct:decrease 8s append -schedule function tct:decrease 9s append -schedule function tct:decrease 10s append -schedule function tct:decrease 11s append -schedule function tct:decrease 12s append -schedule function tct:decrease 13s append -schedule function tct:decrease 14s append -schedule function tct:decrease 15s append -schedule function tct:decrease 16s append -schedule function tct:decrease 17s append -schedule function tct:decrease 18s append -schedule function tct:decrease 19s append -schedule function tct:halt 20s \ No newline at end of file diff --git a/data/tctvote/functions/ayevote.mcfunction b/data/tctvote/functions/ayevote.mcfunction new file mode 100644 index 0000000..42906cd --- /dev/null +++ b/data/tctvote/functions/ayevote.mcfunction @@ -0,0 +1,2 @@ +scoreboard players add AYE mt_vote_balance 1 +execute if score @e[tag=mt_votestand,limit=1] mt_vote_anon matches 0 run execute at @e[type=minecraft:armor_stand,tag=mt_votestand,limit=1] run playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 2 \ No newline at end of file diff --git a/data/tctvote/functions/calc.mcfunction b/data/tctvote/functions/calc.mcfunction new file mode 100644 index 0000000..3c44211 --- /dev/null +++ b/data/tctvote/functions/calc.mcfunction @@ -0,0 +1,4 @@ +execute as @a[scores={mt_vote_trigger=1}] run function tctvote:ayevote +execute as @a[scores={mt_vote_trigger=2}] run function tctvote:novote +execute as @a[scores={mt_vote_trigger=1..2}] run clear @s written_book{certified:votebook} 1 +execute as @a[scores={mt_vote_trigger=1..2}] run scoreboard players reset @s mt_vote_trigger \ No newline at end of file diff --git a/data/tctvote/functions/countdownstart.mcfunction b/data/tctvote/functions/countdownstart.mcfunction new file mode 100644 index 0000000..8a830a7 --- /dev/null +++ b/data/tctvote/functions/countdownstart.mcfunction @@ -0,0 +1,20 @@ +schedule function tctvote:decrease 1s append +schedule function tctvote:decrease 2s append +schedule function tctvote:decrease 3s append +schedule function tctvote:decrease 4s append +schedule function tctvote:decrease 5s append +schedule function tctvote:decrease 6s append +schedule function tctvote:decrease 7s append +schedule function tctvote:decrease 8s append +schedule function tctvote:decrease 9s append +schedule function tctvote:decrease 10s append +schedule function tctvote:decrease 11s append +schedule function tctvote:decrease 12s append +schedule function tctvote:decrease 13s append +schedule function tctvote:decrease 14s append +schedule function tctvote:decrease 15s append +schedule function tctvote:shift 15s append +schedule function tctvote:decrease 16s append +schedule function tctvote:decrease 17s append +schedule function tctvote:decrease 18s append +schedule function tctvote:decrease 19s append \ No newline at end of file diff --git a/data/tctvote/functions/decrease.mcfunction b/data/tctvote/functions/decrease.mcfunction new file mode 100644 index 0000000..504174a --- /dev/null +++ b/data/tctvote/functions/decrease.mcfunction @@ -0,0 +1,3 @@ +scoreboard players remove @e[tag=mt_votestand] mt_countdown 1 +execute store result bossbar minecraft:votetimer value run scoreboard players get @e[tag=mt_votestand,limit=1] mt_countdown +execute at @e[type=minecraft:armor_stand,tag=mt_votestand,limit=1] run playsound minecraft:block.note_block.hat master @a ~ ~ ~ 100 1 \ No newline at end of file diff --git a/data/tct/functions/halt.mcfunction b/data/tctvote/functions/halt.mcfunction similarity index 53% rename from data/tct/functions/halt.mcfunction rename to data/tctvote/functions/halt.mcfunction index 823a604..c1094e0 100644 --- a/data/tct/functions/halt.mcfunction +++ b/data/tctvote/functions/halt.mcfunction @@ -1,10 +1,20 @@ +# Remove the scoreboard from the sidebar scoreboard objectives setdisplay sidebar -scoreboard players reset Remaining mt_vote_balance + +# Remove all VoteBooks execute as @a run clear @s written_book{certified:votebook} + +# Report the results tellraw @a ["",{"text":"Vote >>","bold":true,"color":"dark_green"},{"text":" AYES: ","bold":true,"color":"dark_green"},{"score":{"name":"AYE","objective":"mt_vote_balance"},"bold":true,"color":"white"},{"text":" "},{"text":" NOES: ","bold":true,"color":"red"},{"score":{"name":"NO","objective":"mt_vote_balance"},"bold":true,"color":"white"}] -scoreboard players reset * mt_vote_balance -scoreboard players reset * mt_vote_trigger + +# play the stop sound +schedule function tctvote:notes/down_0 1t + +# Remove the scores and teams +scoreboard objectives remove mt_vote_balance +scoreboard objectives remove mt_vote_trigger +scoreboard objectives remove mt_vote_anon +scoreboard objectives remove mt_countdown +bossbar remove votetimer team remove green -team remove red -team remove yellow -schedule function tct:notes/down_0 1t \ No newline at end of file +team remove red \ No newline at end of file diff --git a/data/tctvote/functions/load.mcfunction b/data/tctvote/functions/load.mcfunction new file mode 100644 index 0000000..739e85a --- /dev/null +++ b/data/tctvote/functions/load.mcfunction @@ -0,0 +1 @@ +scoreboard objectives add mt_vote_eligible dummy \ No newline at end of file diff --git a/data/tctvote/functions/notes/down_0.mcfunction b/data/tctvote/functions/notes/down_0.mcfunction new file mode 100644 index 0000000..bfe5f2c --- /dev/null +++ b/data/tctvote/functions/notes/down_0.mcfunction @@ -0,0 +1,2 @@ +execute at @e[type=minecraft:armor_stand,tag=mt_votestand,limit=1] run playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 1.6 +schedule function tctvote:notes/down_1 5t \ No newline at end of file diff --git a/data/tctvote/functions/notes/down_1.mcfunction b/data/tctvote/functions/notes/down_1.mcfunction new file mode 100644 index 0000000..1258cef --- /dev/null +++ b/data/tctvote/functions/notes/down_1.mcfunction @@ -0,0 +1,2 @@ +execute at @e[type=minecraft:armor_stand,tag=mt_votestand,limit=1] run playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 1.2 +schedule function tctvote:notes/down_2 5t \ No newline at end of file diff --git a/data/tctvote/functions/notes/down_2.mcfunction b/data/tctvote/functions/notes/down_2.mcfunction new file mode 100644 index 0000000..ef8c2ca --- /dev/null +++ b/data/tctvote/functions/notes/down_2.mcfunction @@ -0,0 +1,2 @@ +execute at @e[type=minecraft:armor_stand,tag=mt_votestand,limit=1] run playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 0.8 +kill @e[type=minecraft:armor_stand,tag=mt_votestand] \ No newline at end of file diff --git a/data/tctvote/functions/notes/up_0.mcfunction b/data/tctvote/functions/notes/up_0.mcfunction new file mode 100644 index 0000000..1bb013f --- /dev/null +++ b/data/tctvote/functions/notes/up_0.mcfunction @@ -0,0 +1,2 @@ +execute at @e[type=minecraft:armor_stand,tag=mt_votestand,limit=1] run playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 0.8 +schedule function tctvote:notes/up_1 5t \ No newline at end of file diff --git a/data/tctvote/functions/notes/up_1.mcfunction b/data/tctvote/functions/notes/up_1.mcfunction new file mode 100644 index 0000000..09091a4 --- /dev/null +++ b/data/tctvote/functions/notes/up_1.mcfunction @@ -0,0 +1,2 @@ +execute at @e[type=minecraft:armor_stand,tag=mt_votestand,limit=1] run playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 1.0 +schedule function tctvote:notes/up_2 5t \ No newline at end of file diff --git a/data/tctvote/functions/notes/up_2.mcfunction b/data/tctvote/functions/notes/up_2.mcfunction new file mode 100644 index 0000000..4793f07 --- /dev/null +++ b/data/tctvote/functions/notes/up_2.mcfunction @@ -0,0 +1 @@ +execute at @e[type=minecraft:armor_stand,tag=mt_votestand,limit=1] run playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 1.6 \ No newline at end of file diff --git a/data/tctvote/functions/novote.mcfunction b/data/tctvote/functions/novote.mcfunction new file mode 100644 index 0000000..80b01c1 --- /dev/null +++ b/data/tctvote/functions/novote.mcfunction @@ -0,0 +1,2 @@ +scoreboard players add NO mt_vote_balance 1 +execute if score @e[tag=mt_votestand,limit=1] mt_vote_anon matches 0 run execute at @e[type=minecraft:armor_stand,tag=mt_votestand,limit=1] run playsound minecraft:block.note_block.pling master @a ~ ~ ~ 100 1.6 \ No newline at end of file diff --git a/data/tctvote/functions/prepare.mcfunction b/data/tctvote/functions/prepare.mcfunction new file mode 100644 index 0000000..55d952d --- /dev/null +++ b/data/tctvote/functions/prepare.mcfunction @@ -0,0 +1,41 @@ +# Create scores, and teams +scoreboard objectives add mt_vote_balance dummy "Vote results" +scoreboard objectives add mt_vote_trigger trigger +scoreboard objectives add mt_vote_anon dummy +scoreboard objectives add mt_countdown dummy +bossbar add minecraft:votetimer "Vote time remaining" +bossbar set minecraft:votetimer max 20 +bossbar set minecraft:votetimer style notched_20 +bossbar set minecraft:votetimer color green +bossbar set minecraft:votetimer value 20 +bossbar set minecraft:votetimer players @a +team add green "Green" +team modify green color dark_green +team add red "Red" +team modify red color red +team join green AYE +team join red NO + +# Summon the VoteStand +summon minecraft:armor_stand ~ ~ ~ {NoGravity:1b,Invulnerable:1b,Small:1b,Marker:1b,Invisible:1b,Tags:["mt_votestand"]} +scoreboard players set @e[tag=mt_votestand] mt_countdown 20 + +# Announce the vote +tellraw @a ["",{"text":"Vote >>","bold":true,"color":"dark_green"},{"text":" Vote using the voting book now!","bold":true,"color":"white"}] + +# Enable the trigger +scoreboard players enable @a[scores={mt_vote_eligible=1}] mt_vote_trigger + +# Give the VoteBook +give @a[scores={mt_vote_eligible=1}] minecraft:written_book{display:{Name:'{"text":"Voting Book","color":"white","bold":true}',Lore:['{"text":"Cast your vote now!"}']},certified:votebook,title:"Voting Book",author:"Kipje",pages:['[{"text":"Cast your vote!\\n Click AYE or NO below.\\n\\n\\n"},{"text":"AYE","color":"dark_green","bold":true,"hoverEvent":{"action":"show_text","contents":[{"text":"Click to vote AYE on this vote."}]},"clickEvent":{"action":"run_command","value":"/trigger mt_vote_trigger set 1"}},{"text":" | "},{"text":"NO","color":"red","bold":true,"hoverEvent":{"action":"show_text","contents":[{"text":"Click to vote NO on this vote."}]},"clickEvent":{"action":"run_command","value":"/trigger mt_vote_trigger set 2"}}]']} 1 + +# Reset the scores +scoreboard players set AYE mt_vote_balance 0 +scoreboard players set NO mt_vote_balance 0 + +# Schedule the notes and countdown +schedule function tctvote:notes/up_0 1t +function tctvote:countdownstart + +# And start the countdown +schedule function tctvote:halt 20s \ No newline at end of file diff --git a/data/tctvote/functions/shift.mcfunction b/data/tctvote/functions/shift.mcfunction new file mode 100644 index 0000000..87b328b --- /dev/null +++ b/data/tctvote/functions/shift.mcfunction @@ -0,0 +1 @@ +bossbar set minecraft:votetimer color red \ No newline at end of file diff --git a/data/tctvote/functions/tick.mcfunction b/data/tctvote/functions/tick.mcfunction new file mode 100644 index 0000000..f96b8dd --- /dev/null +++ b/data/tctvote/functions/tick.mcfunction @@ -0,0 +1 @@ +execute as @a[scores={mt_vote_trigger=1..2}] run function tctvote:calc \ No newline at end of file diff --git a/data/tctvote/functions/vote.mcfunction b/data/tctvote/functions/vote.mcfunction new file mode 100644 index 0000000..681bda8 --- /dev/null +++ b/data/tctvote/functions/vote.mcfunction @@ -0,0 +1,3 @@ +function tctvote:prepare +scoreboard objectives setdisplay sidebar mt_vote_balance +scoreboard players set @e[tag=mt_votestand] mt_vote_anon 0 \ No newline at end of file diff --git a/data/tctvote/functions/vote_anon.mcfunction b/data/tctvote/functions/vote_anon.mcfunction new file mode 100644 index 0000000..0a8794a --- /dev/null +++ b/data/tctvote/functions/vote_anon.mcfunction @@ -0,0 +1,2 @@ +function tctvote:prepare +scoreboard players set @e[tag=mt_votestand] mt_vote_anon 1 \ No newline at end of file