aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatt Kohls <mattkohls13@gmail.com>2018-10-30 14:21:09 -0400
committerMatt Kohls <mattkohls13@gmail.com>2018-10-30 14:21:09 -0400
commitb8e124c7ed303dfb1a3ad4295936abea79533101 (patch)
treebcadc7d4d3cbddf44bd0357e40c7bebcb55e6090 /src
parentc558cc3457dfd96089b459d34eaa43c7cc310eda (diff)
downloadSoundChan-b8e124c7ed303dfb1a3ad4295936abea79533101.tar.gz
SoundChan-b8e124c7ed303dfb1a3ad4295936abea79533101.tar.bz2
SoundChan-b8e124c7ed303dfb1a3ad4295936abea79533101.zip
Making the format prettier
Diffstat (limited to 'src')
-rw-r--r--src/main/java/soundchan/BotListener/BotListener.java23
1 files changed, 20 insertions, 3 deletions
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";
@@ -382,6 +386,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)
* @return True if it matches a value to enable, False otherwise