From e337bbb7a1d56c44b799ec57279a40829239214c Mon Sep 17 00:00:00 2001 From: Hyphen-ated Date: Sat, 4 Jul 2015 20:14:23 -0700 Subject: [PATCH] check for null in updateNowPlayingFile, oops. fixes #35 and #33 --- src/main/java/hyphenated/djbot/DjService.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/hyphenated/djbot/DjService.java b/src/main/java/hyphenated/djbot/DjService.java index cbe6bd5..1c92277 100644 --- a/src/main/java/hyphenated/djbot/DjService.java +++ b/src/main/java/hyphenated/djbot/DjService.java @@ -590,10 +590,16 @@ private void updatePlayedSongsFile() throws IOException { //go write to the filesystem so the user can overlay this text file on their stream if they want private void updateNowPlayingFile(SongEntry currentSong) { - String nowPlaying = conf.getNowPlayingPattern(); - nowPlaying = nowPlaying.replace("%title%", currentSong.getTitle()); - nowPlaying = nowPlaying.replace("%user%", currentSong.getUser()); - nowPlaying = nowPlaying.replace("%length%", currentSong.buildDurationStr()); + String nowPlaying; + if(currentSong != null) { + nowPlaying = conf.getNowPlayingPattern(); + nowPlaying = nowPlaying.replace("%title%", currentSong.getTitle()); + nowPlaying = nowPlaying.replace("%user%", currentSong.getUser()); + nowPlaying = nowPlaying.replace("%length%", currentSong.buildDurationStr()); + } else { + nowPlaying = ""; + } + try { FileUtils.writeStringToFile(new File(nowPlayingFilePath), nowPlaying, false); } catch (IOException e) {