From b8e124c7ed303dfb1a3ad4295936abea79533101 Mon Sep 17 00:00:00 2001 From: Matt Kohls Date: Tue, 30 Oct 2018 14:21:09 -0400 Subject: Making the format prettier --- .../java/soundchan/BotListener/BotListener.java | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/soundchan/BotListener/BotListener.java b/src/main/java/soundchan/BotListener/BotListener.java index a120a14..6e928e6 100644 --- a/src/main/java/soundchan/BotListener/BotListener.java +++ b/src/main/java/soundchan/BotListener/BotListener.java @@ -268,9 +268,13 @@ public class BotListener extends ListenerAdapter{ if(currentlyPlaying != null) { message = "Currently Playing: " + currentlyPlaying.getInfo().title + " by " + currentlyPlaying.getInfo().author; if(printStatus) { - message += ( "\nTime : " + currentlyPlaying.getPosition() + " | " + currentlyPlaying.getDuration() - + "\nPaused = " + musicManager.player.isPaused() - + "\nVolume = " + musicManager.player.getVolume() + "%"); + message += ( "\nTime : " + genTimeStamp(currentlyPlaying.getPosition()) + " | " + genTimeStamp(currentlyPlaying.getDuration()) ); + if(musicManager.player.isPaused()) { + message += "\n**Paused**"; + } else { + message += "\n*Playing*"; + } + message += ( "\nVolume = " + musicManager.player.getVolume() + "%"); } } else { message = "Nothing currently playing"; @@ -381,6 +385,19 @@ public class BotListener extends ListenerAdapter{ } } + /** + * Creates a timestamp string from a number of milliseconds + * @param durationInMillis Number of milliseconds to turn into timestamp + * @return Timestamp in form HH:MM:ss:SSSS + */ + private static String genTimeStamp(long durationInMillis) { + long millis = durationInMillis % 1000; + long second = (durationInMillis / 1000) % 60; + long minute = (durationInMillis / (1000 * 60)) % 60; + long hour = (durationInMillis / (1000 * 60 * 60)) % 24; + return String.format("%02d:%02d:%02d.%d", hour, minute, second, millis); + } + /** * Checks the string for some reason to enable/disable a setting. * @param value A string (probably read in from config file) -- cgit v1.2.3