- Added bossbar to vote

- Changed vote to require eligibility score instead of tag
- Performance optimizations
- Sounds now play from an armor stand summoned at the vote button
- Anonymous function works properly now
This commit is contained in:
2021-03-04 21:47:52 +01:00
parent b05ad4a0e3
commit 02ca44bb99
33 changed files with 107 additions and 105 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,20 @@
# Remove the scoreboard from the sidebar
scoreboard objectives setdisplay sidebar
# 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"}]
# 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

View File

@@ -0,0 +1 @@
scoreboard objectives add mt_vote_eligible dummy

View File

@@ -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

View File

@@ -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

View File

@@ -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]

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1 @@
bossbar set minecraft:votetimer color red

View File

@@ -0,0 +1 @@
execute as @a[scores={mt_vote_trigger=1..2}] run function tctvote:calc

View File

@@ -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

View File

@@ -0,0 +1,2 @@
function tctvote:prepare
scoreboard players set @e[tag=mt_votestand] mt_vote_anon 1