chomens_bot_nomusic

This commit is contained in:
ChomeNS 2023-02-28 12:39:24 +07:00
parent 41ea92943d
commit 4bf9a0a0ed

View file

@ -43,6 +43,8 @@ function inject (bot) {
const bossbarName = 'chomens_bot:music' // maybe make this in the config? const bossbarName = 'chomens_bot:music' // maybe make this in the config?
const selector = '@a[tag=!nomusic,tag=!chomens_bot_nomusic]'
const interval = setInterval(async () => { const interval = setInterval(async () => {
if (!bot.music.queue.length) return if (!bot.music.queue.length) return
bot.music.song = bot.music.queue[0] bot.music.song = bot.music.queue[0]
@ -52,7 +54,7 @@ function inject (bot) {
// is spamming commands in core as a self care a good idea? // is spamming commands in core as a self care a good idea?
// btw this is totallynotskidded™ from my song bot except the bossbarName (above) // btw this is totallynotskidded™ from my song bot except the bossbarName (above)
bot.core.run(`minecraft:bossbar add ${bossbarName} ""`) // is setting the name to "" as a placeholder a good idea? bot.core.run(`minecraft:bossbar add ${bossbarName} ""`) // is setting the name to "" as a placeholder a good idea?
bot.core.run(`minecraft:bossbar set ${bossbarName} players @a[tag=!nomusic]`) bot.core.run(`minecraft:bossbar set ${bossbarName} players ${selector}`)
bot.core.run(`minecraft:bossbar set ${bossbarName} name ${JSON.stringify(toComponent())}`) bot.core.run(`minecraft:bossbar set ${bossbarName} name ${JSON.stringify(toComponent())}`)
bot.core.run(`minecraft:bossbar set ${bossbarName} color yellow`) // should i use purple lol bot.core.run(`minecraft:bossbar set ${bossbarName} color yellow`) // should i use purple lol
bot.core.run(`minecraft:bossbar set ${bossbarName} visible true`) bot.core.run(`minecraft:bossbar set ${bossbarName} visible true`)
@ -62,7 +64,7 @@ function inject (bot) {
while (bot.music.song?.notes[noteIndex]?.time <= time) { while (bot.music.song?.notes[noteIndex]?.time <= time) {
const note = bot.music.song.notes[noteIndex] const note = bot.music.song.notes[noteIndex]
const floatingPitch = 2 ** ((note.pitch - 12) / 12.0) const floatingPitch = 2 ** ((note.pitch - 12) / 12.0)
bot.core.run(`minecraft:execute as @a[tag=!nomusic] at @s run playsound ${soundNames[note.instrument]} record @s ~ ~ ~ ${note.volume} ${floatingPitch}`) bot.core.run(`minecraft:execute as ${selector} at @s run playsound ${soundNames[note.instrument]} record @s ~ ~ ~ ${note.volume} ${floatingPitch}`)
noteIndex++ noteIndex++
if (noteIndex >= bot.music.song.notes.length) { if (noteIndex >= bot.music.song.notes.length) {
if (bot.music.loop === 1) { if (bot.music.loop === 1) {
@ -77,7 +79,7 @@ function inject (bot) {
} }
bot.music.queue.shift() bot.music.queue.shift()
if (!bot.music.queue[0]) { if (!bot.music.queue[0]) {
bot.tellraw('@a', { text: 'Finished playing every song in the queue' }) if (bot.music.queue.length === 0) bot.tellraw('@a', { text: 'Finished playing every song in the queue' })
bot.music.stop() bot.music.stop()
return return
} }