From ccd38690657b767d06ccf2771183738b0a35654d Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Thu, 10 Mar 2022 21:08:52 -0500 Subject: Prevent crash from playing non .wav music --- src/main/java/me/Danker/features/CustomMusic.java | 25 +++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/main/java/me/Danker') diff --git a/src/main/java/me/Danker/features/CustomMusic.java b/src/main/java/me/Danker/features/CustomMusic.java index 1f609cc..5153f91 100644 --- a/src/main/java/me/Danker/features/CustomMusic.java +++ b/src/main/java/me/Danker/features/CustomMusic.java @@ -229,14 +229,23 @@ public class CustomMusic { public void start() throws UnsupportedAudioFileException, LineUnavailableException, IOException { - if (music == null) music = AudioSystem.getClip(); - if (!music.isRunning()) { - reset(); - shuffle(); - setVolume(volume); - cancelNotes = true; - music.setMicrosecondPosition(0); - music.start(); + try { + if (music == null) music = AudioSystem.getClip(); + if (!music.isRunning()) { + reset(); + shuffle(); + setVolume(volume); + cancelNotes = true; + music.setMicrosecondPosition(0); + music.start(); + } + } catch (UnsupportedAudioFileException ex) { + ex.printStackTrace(); + + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + if (player != null) { + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Attempted to play non .wav file. Please use a .wav converter instead of renaming the file.")); + } } } -- cgit