diff --git a/build-number.txt b/build-number.txt index 21c21a97..e259f689 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -1861 \ No newline at end of file +1863 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java index cde67701..7caf8a38 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java @@ -81,61 +81,48 @@ public class MusicPlayerPlugin extends Bot.Listener { } public void loadSong (Path location, PlayerEntry sender) { - if (songQueue.size() > 500) return; - - loaderThread = new SongLoaderThread(location, bot, sender.profile.getName()); - - bot.chat.tellraw( - Component - .translatable( - "Loading %s", - Component.text(location.getFileName().toString(), ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) - ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) + startLoadingSong( + location.getFileName().toString(), + new SongLoaderThread(location, bot, sender.profile.getName()) ); - - loaderThread.start(); - } - - public void loadSong (URL location, PlayerEntry sender) { - if (songQueue.size() > 500) return; - - urlLimit++; - - if (urlLimit > bot.config.music.urlRatelimit.limit) { - bot.chat.tellraw(Component.text("ohio").color(NamedTextColor.RED)); - return; - } - - loaderThread = new SongLoaderThread(location, bot, sender.profile.getName()); - - bot.chat.tellraw( - Component - .translatable( - "Loading %s", - Component.text(location.toString(), ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) - ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) - ); - - loaderThread.start(); } public void loadSong (byte[] data, PlayerEntry sender) { + startLoadingSong( + sender.profile.getName() + "'s song item", + new SongLoaderThread(data, bot, sender.profile.getName()) + ); + } + + public void loadSong (URL location, PlayerEntry sender) { + if (urlLimit >= bot.config.music.urlRatelimit.limit) { + bot.chat.tellraw(Component.text("URL loading is being rate limited!").color(NamedTextColor.RED)); + return; + } + + urlLimit++; + + startLoadingSong( + location.toString(), + new SongLoaderThread(location, bot, sender.profile.getName()) + ); + } + + private void startLoadingSong (String songName, SongLoaderThread loaderThread) { if (songQueue.size() > 500) return; - loaderThread = new SongLoaderThread(data, bot, sender.profile.getName()); + this.loaderThread = loaderThread; bot.chat.tellraw( Component .translatable( "Loading %s", - Component.text(sender.profile.getName() + "'s song item", ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + Component.text(songName, ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) ) .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) ); - loaderThread.start(); + this.loaderThread.start(); } private void onCoreReady () {