play folders LoL
This commit is contained in:
parent
6acc76171a
commit
b7751a5467
1 changed files with 30 additions and 6 deletions
|
@ -26,6 +26,8 @@ public class SongLoaderRunnable implements Runnable {
|
||||||
|
|
||||||
private final boolean isUrl;
|
private final boolean isUrl;
|
||||||
|
|
||||||
|
private boolean isFolder = false;
|
||||||
|
|
||||||
public SongLoaderRunnable(URL location, Bot bot) {
|
public SongLoaderRunnable(URL location, Bot bot) {
|
||||||
this.bot = bot;
|
this.bot = bot;
|
||||||
isUrl = true;
|
isUrl = true;
|
||||||
|
@ -39,10 +41,27 @@ public class SongLoaderRunnable implements Runnable {
|
||||||
isUrl = false;
|
isUrl = false;
|
||||||
songPath = location.toFile();
|
songPath = location.toFile();
|
||||||
|
|
||||||
|
isFolder = songPath.isDirectory();
|
||||||
|
|
||||||
fileName = location.getFileName().toString();
|
fileName = location.getFileName().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run () {
|
public void run () {
|
||||||
|
if (isFolder && !isUrl) {
|
||||||
|
final File[] files = songPath.listFiles();
|
||||||
|
|
||||||
|
if (files != null) {
|
||||||
|
for (File file : files) {
|
||||||
|
songPath = file;
|
||||||
|
processFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
showAddedToQueue();
|
||||||
|
}
|
||||||
|
} else processFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processFile () {
|
||||||
byte[] bytes;
|
byte[] bytes;
|
||||||
String name;
|
String name;
|
||||||
try {
|
try {
|
||||||
|
@ -81,6 +100,12 @@ public class SongLoaderRunnable implements Runnable {
|
||||||
failed();
|
failed();
|
||||||
} else {
|
} else {
|
||||||
bot.music.songQueue.add(song);
|
bot.music.songQueue.add(song);
|
||||||
|
|
||||||
|
if (!isFolder) showAddedToQueue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAddedToQueue () {
|
||||||
bot.chat.tellraw(
|
bot.chat.tellraw(
|
||||||
Component.translatable(
|
Component.translatable(
|
||||||
"Added %s to the song queue",
|
"Added %s to the song queue",
|
||||||
|
@ -88,7 +113,6 @@ public class SongLoaderRunnable implements Runnable {
|
||||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void failed() {
|
private void failed() {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
|
|
Loading…
Reference in a new issue