From cc17eb0bd9050a3ba8d5b97e267ce1449535501a Mon Sep 17 00:00:00 2001 From: Nekojimi Date: Fri, 19 Nov 2021 19:55:32 +0000 Subject: [PATCH] Added "keep" flag to songs, which will stop them being deleted. --- src/main/java/moe/nekojimi/chords/MusicHandler.java | 3 ++- src/main/java/moe/nekojimi/chords/Song.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/moe/nekojimi/chords/MusicHandler.java b/src/main/java/moe/nekojimi/chords/MusicHandler.java index 62bde01..b0b6dc4 100644 --- a/src/main/java/moe/nekojimi/chords/MusicHandler.java +++ b/src/main/java/moe/nekojimi/chords/MusicHandler.java @@ -95,7 +95,8 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer } if (currentSong != null) { - currentSong.delete(); + if (!currentSong.isKept()) + currentSong.delete(); currentSong = null; } currentSong = songQueue.poll(); diff --git a/src/main/java/moe/nekojimi/chords/Song.java b/src/main/java/moe/nekojimi/chords/Song.java index 2a9557d..0cf134c 100644 --- a/src/main/java/moe/nekojimi/chords/Song.java +++ b/src/main/java/moe/nekojimi/chords/Song.java @@ -22,6 +22,7 @@ public class Song private String requestedBy; private String requestedIn; + private boolean kept = false; public Song(URL url) { @@ -100,6 +101,16 @@ public class Song this.requestedIn = requestedIn; } + public boolean isKept() + { + return kept; + } + + public void setKept(boolean kept) + { + this.kept = kept; + } + @Override public String toString() {