From 012f8fc3eb83ff3bd651c12333d3446ec9dbf5cb Mon Sep 17 00:00:00 2001 From: Ryuuta Iwakura <33993422+ryuuta0217@users.noreply.github.com> Date: Wed, 11 Sep 2019 06:38:06 +0900 Subject: [PATCH 01/12] Updated Jenkinsfile --- Jenkinsfile | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8b1378917..07c9f6e8f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1 +1,20 @@ - +node { + def mvnHome + stage('下準備') { + git 'https://github.com/ryuuta0217/JMusicBot-JP.git' + mvnHome = tool 'M3' + } + stage('ビルド') { + withEnv(["MVN_HOME=$mvnHome"]) { + if (isUnix()) { + sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore -Dfile.encoding=UTF-8 clean package' + } else { + bat(/"%MVN_HOME%\bin\mvn" -Dmaven.test.failure.ignore -Dfile.encoding=UTF-8 clean package/) + } + } + } + stage('結果') { + junit '**/target/surefire-reports/TEST-*.xml' + archiveArtifacts 'target/*.jar' + } +} From 184b7255c8631cfa696f62e8d4fb51e82a494520 Mon Sep 17 00:00:00 2001 From: Ryuuta Iwakura <33993422+ryuuta0217@users.noreply.github.com> Date: Wed, 11 Sep 2019 06:43:51 +0900 Subject: [PATCH 02/12] Update Jenkinsfile --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 07c9f6e8f..6c1ff963f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,10 @@ node { def mvnHome - stage('下準備') { + stage('Prepare') { git 'https://github.com/ryuuta0217/JMusicBot-JP.git' - mvnHome = tool 'M3' + mvnHome = tool 'Maven 3.6.0' } - stage('ビルド') { + stage('build') { withEnv(["MVN_HOME=$mvnHome"]) { if (isUnix()) { sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore -Dfile.encoding=UTF-8 clean package' @@ -13,7 +13,7 @@ node { } } } - stage('結果') { + stage('result') { junit '**/target/surefire-reports/TEST-*.xml' archiveArtifacts 'target/*.jar' } From 60dbd0da7d322daeda114821ed2c9d0909719062 Mon Sep 17 00:00:00 2001 From: Ryuuta Iwakura <33993422+ryuuta0217@users.noreply.github.com> Date: Wed, 11 Sep 2019 07:03:17 +0900 Subject: [PATCH 03/12] Update Jenkinsfile --- Jenkinsfile | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6c1ff963f..6ac025573 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,20 +1,32 @@ -node { + +pipeline { + agent any def mvnHome - stage('Prepare') { - git 'https://github.com/ryuuta0217/JMusicBot-JP.git' - mvnHome = tool 'Maven 3.6.0' - } - stage('build') { - withEnv(["MVN_HOME=$mvnHome"]) { - if (isUnix()) { - sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore -Dfile.encoding=UTF-8 clean package' - } else { - bat(/"%MVN_HOME%\bin\mvn" -Dmaven.test.failure.ignore -Dfile.encoding=UTF-8 clean package/) + + stages { + stage('Prepare') { + steps { + git 'https://github.com/ryuuta0217/JMusicBot-JP.git' + mvnHome = tool 'Maven 3.6.0' + } + } + + stage('build') { + steps { + withEnv(["MVN_HOME=$mvnHome"]) { + if(isUnix()) { + sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore -Dfile.encoding=UTF-8 clean package' + } else { + bat(/"%MVN_HOME%\bin\mvn" -Dmaven.test.failure.ignore -Dfile.encoding=UTF-8 clean package/) + } + } + } + } + + stage('result') { + steps { + junit '**/target/surefire-reports/TEST-*.xml' } } - } - stage('result') { - junit '**/target/surefire-reports/TEST-*.xml' - archiveArtifacts 'target/*.jar' } } From 889a8d09ba53d51bd75704d91547878fd467b80b Mon Sep 17 00:00:00 2001 From: Ryuuta Iwakura <33993422+ryuuta0217@users.noreply.github.com> Date: Wed, 11 Sep 2019 07:12:03 +0900 Subject: [PATCH 04/12] Update Jenkinsfile --- Jenkinsfile | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6ac025573..6c1ff963f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,32 +1,20 @@ - -pipeline { - agent any +node { def mvnHome - - stages { - stage('Prepare') { - steps { - git 'https://github.com/ryuuta0217/JMusicBot-JP.git' - mvnHome = tool 'Maven 3.6.0' - } - } - - stage('build') { - steps { - withEnv(["MVN_HOME=$mvnHome"]) { - if(isUnix()) { - sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore -Dfile.encoding=UTF-8 clean package' - } else { - bat(/"%MVN_HOME%\bin\mvn" -Dmaven.test.failure.ignore -Dfile.encoding=UTF-8 clean package/) - } - } - } - } - - stage('result') { - steps { - junit '**/target/surefire-reports/TEST-*.xml' + stage('Prepare') { + git 'https://github.com/ryuuta0217/JMusicBot-JP.git' + mvnHome = tool 'Maven 3.6.0' + } + stage('build') { + withEnv(["MVN_HOME=$mvnHome"]) { + if (isUnix()) { + sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore -Dfile.encoding=UTF-8 clean package' + } else { + bat(/"%MVN_HOME%\bin\mvn" -Dmaven.test.failure.ignore -Dfile.encoding=UTF-8 clean package/) } } } + stage('result') { + junit '**/target/surefire-reports/TEST-*.xml' + archiveArtifacts 'target/*.jar' + } } From 8562bd848fd14718c3222bfcbc9443a2ff98849f Mon Sep 17 00:00:00 2001 From: ryuuta0217 Date: Wed, 11 Sep 2019 09:16:22 +0900 Subject: [PATCH 05/12] =?UTF-8?q?=E9=AB=98=E9=9F=B3=E8=B3=AA=E5=8C=96,=20?= =?UTF-8?q?=E8=AD=A6=E5=91=8A=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jagrosh/jmusicbot/audio/PlayerManager.java | 14 ++++++++++++++ .../jmusicbot/gui/TextAreaOutputStream.java | 12 ++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/audio/PlayerManager.java b/src/main/java/com/jagrosh/jmusicbot/audio/PlayerManager.java index 34dd65ebb..d0c2c27db 100644 --- a/src/main/java/com/jagrosh/jmusicbot/audio/PlayerManager.java +++ b/src/main/java/com/jagrosh/jmusicbot/audio/PlayerManager.java @@ -16,12 +16,15 @@ package com.jagrosh.jmusicbot.audio; import com.jagrosh.jmusicbot.Bot; +import com.sedmelluq.discord.lavaplayer.player.AudioConfiguration; import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager; import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; import com.sedmelluq.discord.lavaplayer.source.nico.NicoAudioSourceManager; import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager; import net.dv8tion.jda.core.entities.Guild; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -30,6 +33,7 @@ public class PlayerManager extends DefaultAudioPlayerManager { private final Bot bot; + private final Logger logger = LoggerFactory.getLogger(this.getClass()); public PlayerManager(Bot bot) { @@ -49,6 +53,16 @@ public void init() AudioSourceManagers.registerRemoteSources(this); AudioSourceManagers.registerLocalSource(this); source(YoutubeAudioSourceManager.class).setPlaylistPageCount(10); + + if(getConfiguration().getOpusEncodingQuality() != 10) { + logger.debug("OpusEncodingQuality is " + getConfiguration().getOpusEncodingQuality() + "(< 10)" + ", Setting Quality to 10."); + getConfiguration().setOpusEncodingQuality(10); + } + + if(getConfiguration().getResamplingQuality() != AudioConfiguration.ResamplingQuality.HIGH) { + logger.debug("ResamplingQuality is " + getConfiguration().getResamplingQuality().name() + "(not HIGH), Setting Quality to HIGH"); + getConfiguration().setResamplingQuality(AudioConfiguration.ResamplingQuality.HIGH); + } } public Bot getBot() diff --git a/src/main/java/com/jagrosh/jmusicbot/gui/TextAreaOutputStream.java b/src/main/java/com/jagrosh/jmusicbot/gui/TextAreaOutputStream.java index 83d6fff1d..9540301ea 100644 --- a/src/main/java/com/jagrosh/jmusicbot/gui/TextAreaOutputStream.java +++ b/src/main/java/com/jagrosh/jmusicbot/gui/TextAreaOutputStream.java @@ -136,19 +136,15 @@ private synchronized void clear() { @Override public synchronized void run() { if(clear) { textArea.setText(""); } - values.stream().map((val) -> { - curLength+=val.length(); - return val; - }).map((val) -> { + values.stream() + .peek((val) -> curLength+=val.length()) + .peek((val) -> { if(val.endsWith(EOL1) || val.endsWith(EOL2)) { if(lengths.size()>=maxLines) { textArea.replaceRange("",0,lengths.removeFirst()); } lengths.addLast(curLength); curLength=0; } - return val; - }).forEach((val) -> { - textArea.append(val); - }); + }).forEach(textArea::append); values.clear(); clear =false; queue =true; From 962ea61da58fb14ce7f9e89e715f4b2301ee8e03 Mon Sep 17 00:00:00 2001 From: ryuuta0217 Date: Wed, 11 Sep 2019 10:59:45 +0900 Subject: [PATCH 06/12] =?UTF-8?q?=E5=92=8C=E8=A8=B3=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java index cac86cc2f..2c6ba3192 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java @@ -32,7 +32,7 @@ public class SetvcCmd extends AdminCommand public SetvcCmd() { this.name = "setvc"; - this.help = "音楽を再生するための音声チャンネルを設定します。"; + this.help = "再生に使用する音声チャンネルを固定します。"; this.arguments = "<チャンネル名|NONE|なし>"; } @@ -60,7 +60,7 @@ else if (list.size()>1) else { s.setVoiceChannel(list.get(0)); - event.reply(event.getClient().getSuccess()+"音楽は**"+list.get(0).getName()+"**でのみ再生します。"); + event.reply(event.getClient().getSuccess()+"音楽は**"+list.get(0).getName()+"**でのみ再生できるようになりました。"); } } } From 21b103e90f57cde3010c4de6163fdb9fb123a73b Mon Sep 17 00:00:00 2001 From: ryuuta0217 Date: Sat, 21 Sep 2019 16:27:50 +0900 Subject: [PATCH 07/12] =?UTF-8?q?=E5=92=8C=E8=A8=B3=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jagrosh/jmusicbot/commands/music/LyricsCmd.java | 2 +- .../jagrosh/jmusicbot/commands/music/PlayCmd.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java index a85848e7f..1b81ee0d0 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java @@ -66,7 +66,7 @@ public void doCommand(CommandEvent event) .setTitle(lyrics.getTitle(), lyrics.getURL()); if(lyrics.getContent().length()>15000) { - event.replyWarning(" `" + title + "` の歌詞の曲が見つかりましたが、正しくない可能性が高いです!: " + lyrics.getURL()); + event.replyWarning(" `" + title + "` の歌詞の曲が見つかりましたが、正しくないかもしれません: " + lyrics.getURL()); } else if(lyrics.getContent().length()>2000) { diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java index c158a23d9..72e92fcbf 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java @@ -76,7 +76,7 @@ public void doCommand(CommandEvent event) if(!isDJ && dj!=null) isDJ = event.getMember().getRoles().contains(dj); if(!isDJ) - event.replyError("DJだけがプレーヤーを一時停止解除できます。"); + event.replyError("DJだけが一時停止を解除できます。"); else { handler.getPlayer().setPaused(false); @@ -84,9 +84,9 @@ public void doCommand(CommandEvent event) } return; } - StringBuilder builder = new StringBuilder(event.getClient().getWarning()+" Play Commands:\n"); - builder.append("\n`").append(event.getClient().getPrefix()).append(name).append(" ` - YouTubeから最初の結果を再生"); - builder.append("\n`").append(event.getClient().getPrefix()).append(name).append(" ` - 指定された曲、プレイリスト、またはストリームを再生します"); + StringBuilder builder = new StringBuilder(event.getClient().getWarning()+" Play コマンド:\n"); + builder.append("\n`").append(event.getClient().getPrefix()).append(name).append(" <曲名>` - YouTubeから最初の結果を再生"); + builder.append("\n`").append(event.getClient().getPrefix()).append(name).append(" ` - 指定された曲、再生リスト、またはストリームを再生します"); for(Command cmd: children) builder.append("\n`").append(event.getClient().getPrefix()).append(name).append(" ").append(cmd.getName()).append(" ").append(cmd.getArguments()).append("` - ").append(cmd.getHelp()); event.reply(builder.toString()); @@ -115,8 +115,8 @@ private void loadSingle(AudioTrack track, AudioPlaylist playlist) { if(bot.getConfig().isTooLong(track)) { - m.editMessage(FormatUtil.filter(event.getClient().getWarning()+" このトラック (**"+track.getInfo().title+"**) は許可されている最大長よりも長いです: `" - +FormatUtil.formatTime(track.getDuration())+"` > `"+FormatUtil.formatTime(bot.getConfig().getMaxSeconds()*1000)+"`")).queue(); + m.editMessage(FormatUtil.filter(event.getClient().getWarning()+ + " **"+track.getInfo().title+"**`(" + FormatUtil.formatTime(track.getDuration()) + ")` は設定された長さ`(" + FormatUtil.formatTime(bot.getConfig().getMaxSeconds()*1000) + ")` を超えています。")).queue(); return; } AudioHandler handler = (AudioHandler)event.getGuild().getAudioManager().getSendingHandler(); From fe5000c98ed04215cfda8eaa2e347fcda98b1cfb Mon Sep 17 00:00:00 2001 From: Ryuuta Iwakura <33993422+ryuuta0217@users.noreply.github.com> Date: Sun, 22 Sep 2019 01:31:07 +0900 Subject: [PATCH 08/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 36392c5a7..209d33538 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Discord](https://discordapp.com/api/guilds/497317844191805450/widget.png)](https://discord.gg/RBpkHxf)
# JMusicBotJP -Discordミュージックボットは、シンプルでかつ操作性の良いUIを使用しています。セットアップも起動も簡単です。 +JMusicBotは、シンプルでかつ操作性の良いUIを使用しています。セットアップも起動も簡単です。 [![Setup](http://i.imgur.com/VvXYp5j.png)](https://www.cosgy.jp/2019/09/06/jmusicbot-setup/) From 08836309ef6f704a6304fffb41ee80ae344a4d04 Mon Sep 17 00:00:00 2001 From: ryuuta0217 Date: Sun, 22 Sep 2019 20:27:48 +0900 Subject: [PATCH 09/12] UTF-8 Compile Override Removed --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2a0050915..dc6f10c51 100644 --- a/pom.xml +++ b/pom.xml @@ -108,7 +108,6 @@ - UTF-8 1.8 1.8 From 4cb9f641e4dce5397e45de7ee4e81711f1d9b580 Mon Sep 17 00:00:00 2001 From: ryuuta0217 Date: Sun, 22 Sep 2019 20:32:30 +0900 Subject: [PATCH 10/12] Revert "UTF-8 Compile Override Removed" This reverts commit 08836309ef6f704a6304fffb41ee80ae344a4d04. --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index dc6f10c51..2a0050915 100644 --- a/pom.xml +++ b/pom.xml @@ -108,6 +108,7 @@ + UTF-8 1.8 1.8 From a3c242a75e83a848fd488c25c3b26d58a7bf64a0 Mon Sep 17 00:00:00 2001 From: ryuuta0217 Date: Mon, 23 Sep 2019 08:37:48 +0900 Subject: [PATCH 11/12] Version 0.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正されたバグ: Windows環境下において、設定ファイルが文字化けしてしまう問題を修正 設定ファイルの文字化けによりニコニコ動画が再生できない問題を修正 コードの変更: インポートを最適化しました その他の変更: 和訳修正などなど。 Apache Commons IO v2.6を依存関係として追加しました。 --- pom.xml | 7 +++- .../examples/command/AboutCommand.java | 2 +- .../examples/command/PingCommand.java | 3 +- src/main/java/com/jagrosh/jmusicbot/Bot.java | 7 ++-- .../java/com/jagrosh/jmusicbot/BotConfig.java | 34 ++++++++----------- .../java/com/jagrosh/jmusicbot/JMusicBot.java | 19 +++++++---- .../java/com/jagrosh/jmusicbot/Listener.java | 6 ++-- .../jagrosh/jmusicbot/audio/AudioHandler.java | 17 +++++----- .../jmusicbot/audio/NowplayingHandler.java | 9 ++--- .../jagrosh/jmusicbot/audio/QueuedTrack.java | 2 +- .../jmusicbot/commands/MusicCommand.java | 2 +- .../jmusicbot/commands/admin/SetdjCmd.java | 3 +- .../jmusicbot/commands/admin/SettcCmd.java | 3 +- .../jmusicbot/commands/admin/SetvcCmd.java | 3 +- .../jmusicbot/commands/music/LyricsCmd.java | 2 -- .../jmusicbot/commands/music/PlayCmd.java | 13 +++---- .../commands/music/PlaylistsCmd.java | 3 +- .../jmusicbot/commands/music/QueueCmd.java | 5 +-- .../jmusicbot/commands/music/SearchCmd.java | 13 +++---- .../jmusicbot/commands/owner/EvalCmd.java | 5 +-- .../jmusicbot/commands/owner/PlaylistCmd.java | 6 ++-- .../commands/owner/SetavatarCmd.java | 5 +-- .../jmusicbot/commands/owner/SetnameCmd.java | 1 - .../jagrosh/jmusicbot/entities/Prompt.java | 5 +-- .../jagrosh/jmusicbot/gui/ConsolePanel.java | 7 ++-- .../java/com/jagrosh/jmusicbot/gui/GUI.java | 7 ++-- .../jmusicbot/gui/TextAreaOutputStream.java | 10 +++--- .../jmusicbot/playlist/PlaylistLoader.java | 1 + .../jmusicbot/settings/SettingsManager.java | 9 ++--- .../jagrosh/jmusicbot/utils/FormatUtil.java | 8 ++--- .../jagrosh/jmusicbot/utils/OtherUtil.java | 34 ++++++++++++++----- 31 files changed, 141 insertions(+), 110 deletions(-) diff --git a/pom.xml b/pom.xml index 2a0050915..ea1e44627 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.jagrosh JMusicBot - 0.2.0 + 0.2.1 jar @@ -51,6 +51,11 @@ config 1.3.2 + + commons-io + commons-io + 2.6 + junit junit diff --git a/src/main/java/com/jagrosh/jdautilities/examples/command/AboutCommand.java b/src/main/java/com/jagrosh/jdautilities/examples/command/AboutCommand.java index 8b8390243..c1e5b74ab 100644 --- a/src/main/java/com/jagrosh/jdautilities/examples/command/AboutCommand.java +++ b/src/main/java/com/jagrosh/jdautilities/examples/command/AboutCommand.java @@ -15,9 +15,9 @@ */ package com.jagrosh.jdautilities.examples.command; -import com.jagrosh.jdautilities.commons.JDAUtilitiesInfo; import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; +import com.jagrosh.jdautilities.commons.JDAUtilitiesInfo; import com.jagrosh.jdautilities.doc.standard.CommandInfo; import com.jagrosh.jdautilities.examples.doc.Author; import net.dv8tion.jda.bot.entities.ApplicationInfo; diff --git a/src/main/java/com/jagrosh/jdautilities/examples/command/PingCommand.java b/src/main/java/com/jagrosh/jdautilities/examples/command/PingCommand.java index 914302825..b6fec40db 100644 --- a/src/main/java/com/jagrosh/jdautilities/examples/command/PingCommand.java +++ b/src/main/java/com/jagrosh/jdautilities/examples/command/PingCommand.java @@ -15,12 +15,13 @@ */ package com.jagrosh.jdautilities.examples.command; -import java.time.temporal.ChronoUnit; import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.doc.standard.CommandInfo; import com.jagrosh.jdautilities.examples.doc.Author; +import java.time.temporal.ChronoUnit; + /** * * @author John Grosh (jagrosh) diff --git a/src/main/java/com/jagrosh/jmusicbot/Bot.java b/src/main/java/com/jagrosh/jmusicbot/Bot.java index 2beff8696..85200187a 100644 --- a/src/main/java/com/jagrosh/jmusicbot/Bot.java +++ b/src/main/java/com/jagrosh/jmusicbot/Bot.java @@ -15,8 +15,6 @@ */ package com.jagrosh.jmusicbot; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; import com.jagrosh.jdautilities.commons.waiter.EventWaiter; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.audio.NowplayingHandler; @@ -24,11 +22,14 @@ import com.jagrosh.jmusicbot.gui.GUI; import com.jagrosh.jmusicbot.playlist.PlaylistLoader; import com.jagrosh.jmusicbot.settings.SettingsManager; -import java.util.Objects; import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.core.entities.Game; import net.dv8tion.jda.core.entities.Guild; +import java.util.Objects; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; + /** * * @author Cosgy Dev (info@cosgy.jp) diff --git a/src/main/java/com/jagrosh/jmusicbot/BotConfig.java b/src/main/java/com/jagrosh/jmusicbot/BotConfig.java index 52b4bdd29..357e7381d 100644 --- a/src/main/java/com/jagrosh/jmusicbot/BotConfig.java +++ b/src/main/java/com/jagrosh/jmusicbot/BotConfig.java @@ -19,13 +19,17 @@ import com.jagrosh.jmusicbot.utils.FormatUtil; import com.jagrosh.jmusicbot.utils.OtherUtil; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; -import com.typesafe.config.*; +import com.typesafe.config.Config; +import com.typesafe.config.ConfigException; +import com.typesafe.config.ConfigFactory; +import net.dv8tion.jda.core.OnlineStatus; +import net.dv8tion.jda.core.entities.Game; +import org.apache.commons.io.FileUtils; + import java.io.IOException; -import java.nio.file.Files; +import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; -import net.dv8tion.jda.core.OnlineStatus; -import net.dv8tion.jda.core.entities.Game; public class BotConfig { @@ -148,34 +152,26 @@ public void load() if(write) { String original = OtherUtil.loadResource(this, "/reference.conf"); - byte[] bytes; + String mod; if(original==null) { - bytes = ("token = "+token+"\r\nowner = "+owner).getBytes(); + mod = ("token = "+token+"\r\nowner = "+owner); } else { - bytes = original.substring(original.indexOf(START_TOKEN)+START_TOKEN.length(), original.indexOf(END_TOKEN)) + mod = original.substring(original.indexOf(START_TOKEN)+START_TOKEN.length(), original.indexOf(END_TOKEN)) .replace("BOT_TOKEN_HERE", token).replace("Botトークンをここに貼り付け", token) .replace("0 // OWNER ID", Long.toString(owner)).replace("所有者IDをここに貼り付け", Long.toString(owner)) - .trim().getBytes(); - } - try - { - Files.write(path, bytes); - } - catch(IOException ex) - { - prompt.alert(Prompt.Level.WARNING, CONTEXT, "新しい設定を書き込めませんでした: "+ex - + "\nファイルがデスクトップまたはその他の制限された領域にないことを確認してください。\n\n設定ファイルの場所: " - + path.toAbsolutePath().toString()); + .trim(); } + + FileUtils.writeStringToFile(path.toFile(), mod, StandardCharsets.UTF_8); } // if we get through the whole config, it's good to go valid = true; } - catch (ConfigException ex) + catch (ConfigException | IOException ex) { prompt.alert(Prompt.Level.ERROR, CONTEXT, ex + ": " + ex.getMessage() + "\n\n設定ファイルの場所: " + path.toAbsolutePath().toString()); } diff --git a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java index 68b103eba..25aa8205c 100644 --- a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java +++ b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java @@ -18,23 +18,29 @@ import com.jagrosh.jdautilities.command.CommandClient; import com.jagrosh.jdautilities.command.CommandClientBuilder; import com.jagrosh.jdautilities.commons.waiter.EventWaiter; -import com.jagrosh.jdautilities.examples.command.*; -import com.jagrosh.jmusicbot.commands.admin.*; +import com.jagrosh.jdautilities.examples.command.AboutCommand; +import com.jagrosh.jdautilities.examples.command.PingCommand; +import com.jagrosh.jmusicbot.commands.admin.SetdjCmd; +import com.jagrosh.jmusicbot.commands.admin.SettcCmd; +import com.jagrosh.jmusicbot.commands.admin.SetvcCmd; import com.jagrosh.jmusicbot.commands.dj.*; -import com.jagrosh.jmusicbot.commands.general.*; +import com.jagrosh.jmusicbot.commands.general.AboutJPCmd; +import com.jagrosh.jmusicbot.commands.general.SettingsCmd; import com.jagrosh.jmusicbot.commands.music.*; import com.jagrosh.jmusicbot.commands.owner.*; import com.jagrosh.jmusicbot.entities.Prompt; import com.jagrosh.jmusicbot.gui.GUI; import com.jagrosh.jmusicbot.settings.SettingsManager; import com.jagrosh.jmusicbot.utils.OtherUtil; -import java.awt.Color; -import javax.security.auth.login.LoginException; import net.dv8tion.jda.core.*; import net.dv8tion.jda.core.entities.Game; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.security.auth.login.LoginException; +import java.awt.*; +import java.io.IOException; + /** * * @author John Grosh (jagrosh) @@ -50,8 +56,7 @@ public class JMusicBot /** * @param args the command line arguments */ - public static void main(String[] args) - { + public static void main(String[] args) throws IOException { // startup log Logger log = LoggerFactory.getLogger("Startup"); diff --git a/src/main/java/com/jagrosh/jmusicbot/Listener.java b/src/main/java/com/jagrosh/jmusicbot/Listener.java index 5ddd25e5a..271dd41ec 100644 --- a/src/main/java/com/jagrosh/jmusicbot/Listener.java +++ b/src/main/java/com/jagrosh/jmusicbot/Listener.java @@ -16,19 +16,17 @@ package com.jagrosh.jmusicbot; import com.jagrosh.jmusicbot.utils.OtherUtil; -import java.util.concurrent.TimeUnit; -import net.dv8tion.jda.core.JDA; -import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.User; import net.dv8tion.jda.core.entities.VoiceChannel; import net.dv8tion.jda.core.events.ReadyEvent; import net.dv8tion.jda.core.events.ShutdownEvent; -import net.dv8tion.jda.core.events.guild.GuildJoinEvent; import net.dv8tion.jda.core.events.message.guild.GuildMessageDeleteEvent; import net.dv8tion.jda.core.hooks.ListenerAdapter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.concurrent.TimeUnit; + /** * * @author Cosgy Dev (info@cosgy.jp) diff --git a/src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java b/src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java index a15a7bc6b..4fb0404a4 100644 --- a/src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java +++ b/src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java @@ -17,19 +17,15 @@ import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.playlist.PlaylistLoader.Playlist; +import com.jagrosh.jmusicbot.queue.FairQueue; +import com.jagrosh.jmusicbot.settings.Settings; +import com.jagrosh.jmusicbot.utils.FormatUtil; import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter; +import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason; import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import com.jagrosh.jmusicbot.queue.FairQueue; -import com.jagrosh.jmusicbot.settings.Settings; -import com.jagrosh.jmusicbot.utils.FormatUtil; -import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack; import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.core.MessageBuilder; @@ -38,6 +34,11 @@ import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.entities.User; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + /** * * @author Cosgy Dev (info@cosgy.jp) diff --git a/src/main/java/com/jagrosh/jmusicbot/audio/NowplayingHandler.java b/src/main/java/com/jagrosh/jmusicbot/audio/NowplayingHandler.java index 4d49da5c6..477e2e987 100644 --- a/src/main/java/com/jagrosh/jmusicbot/audio/NowplayingHandler.java +++ b/src/main/java/com/jagrosh/jmusicbot/audio/NowplayingHandler.java @@ -19,10 +19,6 @@ import com.jagrosh.jmusicbot.entities.Pair; import com.jagrosh.jmusicbot.settings.Settings; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.TimeUnit; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Game; import net.dv8tion.jda.core.entities.Guild; @@ -30,6 +26,11 @@ import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.core.exceptions.PermissionException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.TimeUnit; + /** * * @author Cosgy Dev (info@cosgy.jp) diff --git a/src/main/java/com/jagrosh/jmusicbot/audio/QueuedTrack.java b/src/main/java/com/jagrosh/jmusicbot/audio/QueuedTrack.java index 22af75028..a12e016f7 100644 --- a/src/main/java/com/jagrosh/jmusicbot/audio/QueuedTrack.java +++ b/src/main/java/com/jagrosh/jmusicbot/audio/QueuedTrack.java @@ -15,9 +15,9 @@ */ package com.jagrosh.jmusicbot.audio; -import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.jagrosh.jmusicbot.queue.Queueable; import com.jagrosh.jmusicbot.utils.FormatUtil; +import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import net.dv8tion.jda.core.entities.User; /** diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java b/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java index 7f48a7070..c6fcfb3ad 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java @@ -18,8 +18,8 @@ import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.audio.AudioHandler; +import com.jagrosh.jmusicbot.settings.Settings; import net.dv8tion.jda.core.entities.GuildVoiceState; import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.core.entities.VoiceChannel; diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetdjCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetdjCmd.java index 42624431d..579cc5c80 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetdjCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetdjCmd.java @@ -15,7 +15,6 @@ */ package com.jagrosh.jmusicbot.commands.admin; -import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; import com.jagrosh.jmusicbot.commands.AdminCommand; @@ -23,6 +22,8 @@ import com.jagrosh.jmusicbot.utils.FormatUtil; import net.dv8tion.jda.core.entities.Role; +import java.util.List; + /** * * @author John Grosh diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java index 9d3a67990..ae2f454aa 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java @@ -15,7 +15,6 @@ */ package com.jagrosh.jmusicbot.commands.admin; -import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; import com.jagrosh.jmusicbot.commands.AdminCommand; @@ -23,6 +22,8 @@ import com.jagrosh.jmusicbot.utils.FormatUtil; import net.dv8tion.jda.core.entities.TextChannel; +import java.util.List; + /** * * @author John Grosh diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java index 2c6ba3192..2ff834724 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java @@ -15,7 +15,6 @@ */ package com.jagrosh.jmusicbot.commands.admin; -import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; import com.jagrosh.jmusicbot.commands.AdminCommand; @@ -23,6 +22,8 @@ import com.jagrosh.jmusicbot.utils.FormatUtil; import net.dv8tion.jda.core.entities.VoiceChannel; +import java.util.List; + /** * * @author John Grosh diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java index 1b81ee0d0..be0824366 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java @@ -16,12 +16,10 @@ package com.jagrosh.jmusicbot.commands.music; import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.jlyrics.Lyrics; import com.jagrosh.jlyrics.LyricsClient; import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.MusicCommand; -import java.util.concurrent.ExecutionException; import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.Permission; diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java index 72e92fcbf..9140723a0 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java @@ -15,11 +15,6 @@ */ package com.jagrosh.jmusicbot.commands.music; -import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; -import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; -import com.sedmelluq.discord.lavaplayer.tools.FriendlyException.Severity; -import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; -import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.menu.ButtonMenu; @@ -30,12 +25,18 @@ import com.jagrosh.jmusicbot.playlist.PlaylistLoader.Playlist; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.FormatUtil; -import java.util.concurrent.TimeUnit; +import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; +import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; +import com.sedmelluq.discord.lavaplayer.tools.FriendlyException.Severity; +import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; +import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.entities.Role; import net.dv8tion.jda.core.exceptions.PermissionException; +import java.util.concurrent.TimeUnit; + /** * * @author John Grosh diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlaylistsCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlaylistsCmd.java index cac8ff6a5..2b7c74292 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlaylistsCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlaylistsCmd.java @@ -15,11 +15,12 @@ */ package com.jagrosh.jmusicbot.commands.music; -import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.MusicCommand; +import java.util.List; + /** * * @author John Grosh diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java index 46239f913..68d776e2c 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java @@ -15,8 +15,6 @@ */ package com.jagrosh.jmusicbot.commands.music; -import java.util.List; -import java.util.concurrent.TimeUnit; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.menu.Paginator; import com.jagrosh.jmusicbot.Bot; @@ -31,6 +29,9 @@ import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.exceptions.PermissionException; +import java.util.List; +import java.util.concurrent.TimeUnit; + /** * * @author John Grosh diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/SearchCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/SearchCmd.java index 7c989e230..bf944a4a7 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/SearchCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/SearchCmd.java @@ -15,12 +15,6 @@ */ package com.jagrosh.jmusicbot.commands.music; -import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; -import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; -import com.sedmelluq.discord.lavaplayer.tools.FriendlyException.Severity; -import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; -import com.sedmelluq.discord.lavaplayer.track.AudioTrack; -import java.util.concurrent.TimeUnit; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.menu.OrderedMenu; import com.jagrosh.jmusicbot.Bot; @@ -28,9 +22,16 @@ import com.jagrosh.jmusicbot.audio.QueuedTrack; import com.jagrosh.jmusicbot.commands.MusicCommand; import com.jagrosh.jmusicbot.utils.FormatUtil; +import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; +import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; +import com.sedmelluq.discord.lavaplayer.tools.FriendlyException.Severity; +import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; +import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Message; +import java.util.concurrent.TimeUnit; + /** * * @author John Grosh diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java index e4c9d3379..f5eb3187c 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java @@ -15,12 +15,13 @@ */ package com.jagrosh.jmusicbot.commands.owner; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.OwnerCommand; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; + /** * * @author John Grosh (jagrosh) diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/PlaylistCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/PlaylistCmd.java index fbce30158..915b95edd 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/PlaylistCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/PlaylistCmd.java @@ -15,15 +15,15 @@ */ package com.jagrosh.jmusicbot.commands.owner; -import java.io.IOException; -import java.util.List; import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.OwnerCommand; -import com.jagrosh.jmusicbot.commands.owner.AutoplaylistCmd; import com.jagrosh.jmusicbot.playlist.PlaylistLoader.Playlist; +import java.io.IOException; +import java.util.List; + /** * * @author John Grosh diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetavatarCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetavatarCmd.java index 529a86ad1..e411764ce 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetavatarCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetavatarCmd.java @@ -15,13 +15,14 @@ */ package com.jagrosh.jmusicbot.commands.owner; -import java.io.IOException; -import java.io.InputStream; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.commands.OwnerCommand; import com.jagrosh.jmusicbot.utils.OtherUtil; import net.dv8tion.jda.core.entities.Icon; +import java.io.IOException; +import java.io.InputStream; + /** * * @author John Grosh diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetnameCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetnameCmd.java index 047b454e6..9d00cd3fc 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetnameCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetnameCmd.java @@ -16,7 +16,6 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import net.dv8tion.jda.core.exceptions.RateLimitedException; diff --git a/src/main/java/com/jagrosh/jmusicbot/entities/Prompt.java b/src/main/java/com/jagrosh/jmusicbot/entities/Prompt.java index 15dff24bf..f73ecabbe 100644 --- a/src/main/java/com/jagrosh/jmusicbot/entities/Prompt.java +++ b/src/main/java/com/jagrosh/jmusicbot/entities/Prompt.java @@ -15,11 +15,12 @@ */ package com.jagrosh.jmusicbot.entities; -import java.util.Scanner; -import javax.swing.JOptionPane; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.swing.*; +import java.util.Scanner; + /** * * @author John Grosh (john.a.grosh@gmail.com) diff --git a/src/main/java/com/jagrosh/jmusicbot/gui/ConsolePanel.java b/src/main/java/com/jagrosh/jmusicbot/gui/ConsolePanel.java index 6bd4c6115..b0139c2d9 100644 --- a/src/main/java/com/jagrosh/jmusicbot/gui/ConsolePanel.java +++ b/src/main/java/com/jagrosh/jmusicbot/gui/ConsolePanel.java @@ -15,12 +15,9 @@ */ package com.jagrosh.jmusicbot.gui; -import java.awt.Dimension; -import java.awt.GridLayout; +import javax.swing.*; +import java.awt.*; import java.io.PrintStream; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; /** * diff --git a/src/main/java/com/jagrosh/jmusicbot/gui/GUI.java b/src/main/java/com/jagrosh/jmusicbot/gui/GUI.java index e5e999963..c89600e76 100644 --- a/src/main/java/com/jagrosh/jmusicbot/gui/GUI.java +++ b/src/main/java/com/jagrosh/jmusicbot/gui/GUI.java @@ -15,12 +15,11 @@ */ package com.jagrosh.jmusicbot.gui; +import com.jagrosh.jmusicbot.Bot; + +import javax.swing.*; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; -import javax.swing.JFrame; -import javax.swing.JTabbedPane; -import javax.swing.WindowConstants; -import com.jagrosh.jmusicbot.Bot; /** diff --git a/src/main/java/com/jagrosh/jmusicbot/gui/TextAreaOutputStream.java b/src/main/java/com/jagrosh/jmusicbot/gui/TextAreaOutputStream.java index 9540301ea..bf008e49e 100644 --- a/src/main/java/com/jagrosh/jmusicbot/gui/TextAreaOutputStream.java +++ b/src/main/java/com/jagrosh/jmusicbot/gui/TextAreaOutputStream.java @@ -15,11 +15,13 @@ */ package com.jagrosh.jmusicbot.gui; +import javax.swing.*; import java.awt.*; -import java.io.*; -import java.util.*; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; -import javax.swing.*; /** * * @author Lawrence Dol @@ -77,7 +79,7 @@ public synchronized void write(byte[] ba,int str,int len) { //@edu.umd.cs.findbugs.annotations.SuppressWarnings("DM_DEFAULT_ENCODING") static private String bytesToString(byte[] ba, int str, int len) { try { - return new String(ba,str,len,"UTF-8"); + return new String(ba,str,len,System.getProperty("file.encoding")); } catch(UnsupportedEncodingException thr) { return new String(ba,str,len); } // all JVMs are required to support UTF-8 diff --git a/src/main/java/com/jagrosh/jmusicbot/playlist/PlaylistLoader.java b/src/main/java/com/jagrosh/jmusicbot/playlist/PlaylistLoader.java index 75379d2ed..e0af9d502 100644 --- a/src/main/java/com/jagrosh/jmusicbot/playlist/PlaylistLoader.java +++ b/src/main/java/com/jagrosh/jmusicbot/playlist/PlaylistLoader.java @@ -21,6 +21,7 @@ import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; + import java.io.File; import java.io.IOException; import java.nio.file.Files; diff --git a/src/main/java/com/jagrosh/jmusicbot/settings/SettingsManager.java b/src/main/java/com/jagrosh/jmusicbot/settings/SettingsManager.java index cad996f87..799856f7a 100644 --- a/src/main/java/com/jagrosh/jmusicbot/settings/SettingsManager.java +++ b/src/main/java/com/jagrosh/jmusicbot/settings/SettingsManager.java @@ -16,15 +16,16 @@ package com.jagrosh.jmusicbot.settings; import com.jagrosh.jdautilities.command.GuildSettingsManager; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.HashMap; import net.dv8tion.jda.core.entities.Guild; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; + /** * * @author John Grosh (john.a.grosh@gmail.com) diff --git a/src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java b/src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java index b0690200a..eb5637bd2 100644 --- a/src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java +++ b/src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java @@ -15,14 +15,14 @@ */ package com.jagrosh.jmusicbot.utils; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.io.Writer; -import java.util.List; import net.dv8tion.jda.core.entities.Role; import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.core.entities.VoiceChannel; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.List; + /** * * @author John Grosh diff --git a/src/main/java/com/jagrosh/jmusicbot/utils/OtherUtil.java b/src/main/java/com/jagrosh/jmusicbot/utils/OtherUtil.java index 1ca1ef856..e60fe71eb 100644 --- a/src/main/java/com/jagrosh/jmusicbot/utils/OtherUtil.java +++ b/src/main/java/com/jagrosh/jmusicbot/utils/OtherUtil.java @@ -17,16 +17,24 @@ import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.entities.Prompt; -import java.io.*; -import java.net.URL; -import java.net.URLConnection; import net.dv8tion.jda.core.OnlineStatus; import net.dv8tion.jda.core.entities.Game; -import okhttp3.*; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; import org.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.StandardCharsets; + /** * * @author John Grosh @@ -40,17 +48,25 @@ public class OtherUtil public static String loadResource(Object clazz, String name) { - try(BufferedReader reader = new BufferedReader(new InputStreamReader(clazz.getClass().getResourceAsStream(name)))) + try { - StringBuilder sb = new StringBuilder(); - reader.lines().forEach(line -> sb.append("\r\n").append(line)); - return sb.toString().trim(); + return readString(clazz.getClass().getResourceAsStream(name)); } - catch(IOException ex) + catch(Exception ex) { return null; } } + + public static String readString(InputStream inputStream) throws IOException { + ByteArrayOutputStream into = new ByteArrayOutputStream(); + byte[] buf = new byte[32768]; + for (int n; 0 < (n = inputStream.read(buf));) { + into.write(buf, 0, n); + } + into.close(); + return new String(into.toByteArray(), StandardCharsets.UTF_8); + } public static InputStream imageFromUrl(String url) { From e277c0e71bb80ad808adea172ce9e953a1ffba61 Mon Sep 17 00:00:00 2001 From: Ryuuta Iwakura <33993422+ryuuta0217@users.noreply.github.com> Date: Mon, 23 Sep 2019 08:39:34 +0900 Subject: [PATCH 12/12] Update Jenkinsfile --- Jenkinsfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6c1ff963f..2a688c6a5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ node { git 'https://github.com/ryuuta0217/JMusicBot-JP.git' mvnHome = tool 'Maven 3.6.0' } - stage('build') { + stage('Build') { withEnv(["MVN_HOME=$mvnHome"]) { if (isUnix()) { sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore -Dfile.encoding=UTF-8 clean package' @@ -13,8 +13,7 @@ node { } } } - stage('result') { - junit '**/target/surefire-reports/TEST-*.xml' + stage('Result') { archiveArtifacts 'target/*.jar' } }