mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
no more try-catch
This commit is contained in:
parent
6225eef683
commit
8d738dd21d
1 changed files with 31 additions and 33 deletions
|
@ -40,41 +40,39 @@ function inject (bot) {
|
|||
}
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
try {
|
||||
if (!bot.music.queue.length) return
|
||||
bot.music.song = bot.music.queue[0]
|
||||
time = Date.now() - startTime
|
||||
bot.core.run('minecraft:title @a[tag=!nomusic] actionbar ' + JSON.stringify(toComponent()))
|
||||
while (bot.music.song.notes[noteIndex]?.time <= time) {
|
||||
const note = bot.music.song.notes[noteIndex]
|
||||
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}`)
|
||||
noteIndex++
|
||||
if (noteIndex >= bot.music.song.notes.length) {
|
||||
if (bot.music.loop === 1) {
|
||||
resetTime()
|
||||
return
|
||||
}
|
||||
if (bot.music.loop === 2) {
|
||||
resetTime()
|
||||
bot.music.queue.push(bot.music.queue.shift())
|
||||
bot.music.play(bot.music.queue[0])
|
||||
return
|
||||
}
|
||||
bot.music.queue.shift()
|
||||
if (!bot.music.queue[0]) {
|
||||
bot.tellraw('@a', { text: 'Finished playing every song in the queue' })
|
||||
bot.music.stop()
|
||||
return
|
||||
}
|
||||
if (bot.music.queue[0].notes.length > 0) {
|
||||
if (bot.music.queue.length !== 1) resetTime()
|
||||
bot.music.play(bot.music.queue[0])
|
||||
return
|
||||
}
|
||||
if (!bot.music.queue.length) return
|
||||
bot.music.song = bot.music.queue[0]
|
||||
time = Date.now() - startTime
|
||||
bot.core.run('minecraft:title @a[tag=!nomusic] actionbar ' + JSON.stringify(toComponent()))
|
||||
while (bot.music.song?.notes[noteIndex]?.time <= time) {
|
||||
const note = bot.music.song.notes[noteIndex]
|
||||
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}`)
|
||||
noteIndex++
|
||||
if (noteIndex >= bot.music.song.notes.length) {
|
||||
if (bot.music.loop === 1) {
|
||||
resetTime()
|
||||
return
|
||||
}
|
||||
if (bot.music.loop === 2) {
|
||||
resetTime()
|
||||
bot.music.queue.push(bot.music.queue.shift())
|
||||
bot.music.play(bot.music.queue[0])
|
||||
return
|
||||
}
|
||||
bot.music.queue.shift()
|
||||
if (!bot.music.queue[0]) {
|
||||
bot.tellraw('@a', { text: 'Finished playing every song in the queue' })
|
||||
bot.music.stop()
|
||||
return
|
||||
}
|
||||
if (bot.music.queue[0].notes.length > 0) {
|
||||
if (bot.music.queue.length !== 1) resetTime()
|
||||
bot.music.play(bot.music.queue[0])
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch (e) {} // not the best fix
|
||||
}
|
||||
}, 50)
|
||||
|
||||
bot.on('end', () => {
|
||||
|
|
Loading…
Reference in a new issue