Skip to content

Commit

Permalink
refactor: 修改音乐播放暂停的触发机制
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSkidder committed Aug 10, 2024
1 parent 523f039 commit 3f3257f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
12 changes: 1 addition & 11 deletions shared/java/top/fpsmaster/features/GlobalSubmitter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,7 @@ class GlobalSubmitter {

@Subscribe
fun onTick(e: EventTick) {
if (time.delay(500)) {
if (Minecraft.getMinecraft().currentScreen is MainMenu) {
if (!MusicPlayer.playList.musics.isEmpty()) {
if (MusicPlayer.isPlaying) {
MusicPlayer.playList.pause()
}
}
}
}

if (musicSwitchTimer.delay(3000)) {
if (musicSwitchTimer.delay(1000)) {
if (MusicPlayer.isPlaying && MusicPlayer.playProgress > 0.999) {
MusicPlayer.playList.next()
}
Expand Down
6 changes: 6 additions & 0 deletions shared/java/top/fpsmaster/ui/screens/mainmenu/MainMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import net.minecraft.util.ResourceLocation
import org.lwjgl.input.Mouse
import top.fpsmaster.FPSMaster
import top.fpsmaster.interfaces.ProviderManager
import top.fpsmaster.modules.music.MusicPlayer
import top.fpsmaster.ui.screens.account.GuiWaiting
import top.fpsmaster.ui.screens.oobe.GuiLogin
import top.fpsmaster.ui.screens.plugins.GuiPlugins
Expand Down Expand Up @@ -51,6 +52,11 @@ class MainMenu : GuiScreen() {
*/
override fun initGui() {
ProviderManager.mainmenuProvider.initGui()
if (!MusicPlayer.playList.musics.isEmpty()) {
if (MusicPlayer.isPlaying) {
MusicPlayer.playList.pause()
}
}
}

/**
Expand Down

0 comments on commit 3f3257f

Please sign in to comment.