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

Commit

Permalink
Implement new sound Mission!
Browse files Browse the repository at this point in the history
New sound!!
  • Loading branch information
CiroZDP committed Apr 26, 2024
1 parent e45a2bb commit 389a00e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
29 changes: 25 additions & 4 deletions src/main/java/net/op/sound/SoundManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class SoundManager {

public static boolean MUSIC = false;
private static Thread currentSoundThread = null;

private SoundManager() {
}

Expand All @@ -21,9 +21,13 @@ public static void init() {
}

public static void update() {
if (!MUSIC)
if (!MUSIC) {
if (currentSoundThread != null)
stopSounds();

return;

}

if (currentSoundThread != null) {
if (currentSoundThread.isAlive())
return;
Expand All @@ -38,6 +42,23 @@ public static void update() {

}

@SuppressWarnings("deprecation")
public static void stopSounds() {
if (currentSoundThread == null)
return;

try {
currentSoundThread.stop();
} catch (Exception ignored) {
try {
currentSoundThread.interrupt();
} catch (Exception ignored2) {
}
}

currentSoundThread = null;
}

private static boolean mt_PlaySound(Sound sound) {
try {
Runnable soundRunnable = () -> {
Expand Down Expand Up @@ -68,7 +89,7 @@ public static boolean playSound(Sound sound, boolean multithreading) {

return state;
}

public static boolean playSound(Sound sound) {
return playSound(sound, true);
}
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/net/op/sound/Tracks.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ public class Tracks {
List<Sound> menu_sounds = new ArrayList<>();
menu_sounds.add(Sound.of()
.name("Menu 2")
.resource("opencraft.sound:menu_2")
.resource("opencraft:sounds.menu_2")
.path("/newmusic/menu2.ogg")
.build());

menu_sounds.add(Sound.of()
.name("Menu 3")
.resource("opencraft.sound:menu_3")
.resource("opencraft:sounds.menu_3")
.path("/newmusic/menu3.ogg")
.build());

menu_sounds.add(Sound.of()
.name("Mission")
.resource("opencraft:sounds.mission")
.path("/music/mission.ogg")
.build());

menu = new Track("Menu Sounds", menu_sounds);
}
Expand Down

0 comments on commit 389a00e

Please sign in to comment.