Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Some changes in SoundManager
Browse files Browse the repository at this point in the history
  • Loading branch information
CiroZDP committed Apr 26, 2024
1 parent e8c97c3 commit 77809a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/main/java/net/op/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,8 @@ public void stop(boolean force) {
// Save settings
Config.save();

// Stop all the sounds
SoundManager.MUSIC = false;
SoundManager.stopSounds();
// Disable soundManager
SoundManager.shutdown();

// Destroy display
destroyDisplay();
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/net/op/sound/SoundManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ public static void update() {

int r = (int) (System.currentTimeMillis() / 1000 % TIMEOUT);
if (r == 0) {
List<Sound> sounds = Tracks.get("Menu Sounds").getSounds().toList();
int index = new Random().nextInt(sounds.size());
playSound(sounds.get(index));
playRandomSound();
}

}

public static void playRandomSound() {
List<Sound> sounds = Tracks.get("Menu Sounds").getSounds().toList();
int index = new Random().nextInt(sounds.size());
playSound(sounds.get(index));
}

@SuppressWarnings("deprecation")
public static void stopSounds() {
if (currentSoundThread == null)
Expand Down Expand Up @@ -96,10 +100,12 @@ public static boolean playSound(Sound sound) {

public static void enable() {
MUSIC = true;
SoundManager.playRandomSound();
}

public static void disable() {
public static void shutdown() {
MUSIC = false;
SoundManager.stopSounds();
}

}

0 comments on commit 77809a9

Please sign in to comment.