diff --git a/FredBoat-Bootloader/pom.xml b/FredBoat-Bootloader/pom.xml index bd20413fa..a5844d026 100644 --- a/FredBoat-Bootloader/pom.xml +++ b/FredBoat-Bootloader/pom.xml @@ -24,17 +24,33 @@ ~ --> - + + + fredboat + FredBoat-Root + 1.0 + + 4.0.0 - com.frederikam FredBoat-Bootloader 1.0 jar + - UTF-8 - 1.8 - 1.8 + fredboat.bootloader.Bootloader + + + + + fredboat + Shared + 1.0 + + + @@ -51,7 +67,7 @@ - com.frederikam.fredboat.bootloader.Bootloader + fredboat.bootloader.Bootloader @@ -61,12 +77,4 @@ - - - org.json - json - 20170516 - jar - - - \ No newline at end of file + diff --git a/FredBoat-Bootloader/src/main/java/com/frederikam/fredboat/bootloader/ExitCodes.java b/FredBoat-Bootloader/src/main/java/com/frederikam/fredboat/bootloader/ExitCodes.java deleted file mode 100644 index 9c6a2d5a9..000000000 --- a/FredBoat-Bootloader/src/main/java/com/frederikam/fredboat/bootloader/ExitCodes.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Frederik Ar. Mikkelsen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -package com.frederikam.fredboat.bootloader; - -public class ExitCodes { - - public static final int EXIT_CODE_NORMAL = 0; - public static final int EXIT_CODE_UPDATE = 20; - public static final int EXIT_CODE_RESTART = 21; - -} diff --git a/FredBoat-Bootloader/src/main/java/com/frederikam/fredboat/bootloader/Bootloader.java b/FredBoat-Bootloader/src/main/java/fredboat/bootloader/Bootloader.java similarity index 93% rename from FredBoat-Bootloader/src/main/java/com/frederikam/fredboat/bootloader/Bootloader.java rename to FredBoat-Bootloader/src/main/java/fredboat/bootloader/Bootloader.java index d894a5af8..9aa926ff7 100644 --- a/FredBoat-Bootloader/src/main/java/com/frederikam/fredboat/bootloader/Bootloader.java +++ b/FredBoat-Bootloader/src/main/java/fredboat/bootloader/Bootloader.java @@ -1,4 +1,5 @@ /* + * * MIT License * * Copyright (c) 2017 Frederik Ar. Mikkelsen @@ -20,10 +21,13 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. - * */ -package com.frederikam.fredboat.bootloader; +package fredboat.bootloader; + +import fredboat.shared.constant.ExitCodes; +import org.json.JSONArray; +import org.json.JSONObject; import java.io.File; import java.io.FileInputStream; @@ -31,8 +35,6 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Scanner; -import org.json.JSONArray; -import org.json.JSONObject; public class Bootloader { @@ -40,7 +42,7 @@ public class Bootloader { private static String jarName; private static int recentBoots = 0; private static long lastBoot = 0L; - + public static void main(String[] args) throws IOException, InterruptedException { OUTER: while (true) { @@ -48,14 +50,14 @@ public static void main(String[] args) throws IOException, InterruptedException Scanner scanner = new Scanner(is); JSONObject json = new JSONObject(scanner.useDelimiter("\\A").next()); scanner.close(); - + command = json.getJSONArray("command"); jarName = json.getString("jarName"); Process process = boot(); process.waitFor(); System.out.println("[BOOTLOADER] Bot exited with code " + process.exitValue()); - + switch (process.exitValue()) { case ExitCodes.EXIT_CODE_UPDATE: System.out.println("[BOOTLOADER] Now updating..."); @@ -65,7 +67,7 @@ public static void main(String[] args) throws IOException, InterruptedException case ExitCodes.EXIT_CODE_NORMAL: System.out.println("[BOOTLOADER] Now shutting down..."); break OUTER; - //SIGINT received or clean exit + //SIGINT received or clean exit default: System.out.println("[BOOTLOADER] Now restarting.."); break; @@ -75,18 +77,18 @@ public static void main(String[] args) throws IOException, InterruptedException private static Process boot() throws IOException { //Check that we are not booting too quick (we could be stuck in a login loop) - if(System.currentTimeMillis() - lastBoot > 3000 * 1000){ + if (System.currentTimeMillis() - lastBoot > 3000 * 1000) { recentBoots = 0; } - + recentBoots++; lastBoot = System.currentTimeMillis(); - - if(recentBoots >= 4){ + + if (recentBoots >= 4) { System.out.println("[BOOTLOADER] Failed to restart 3 times, probably due to login errors. Exiting..."); System.exit(-1); } - + //ProcessBuilder pb = new ProcessBuilder(System.getProperty("java.home") + "/bin/java -jar "+new File("FredBoat-1.0.jar").getAbsolutePath()) ProcessBuilder pb = new ProcessBuilder() .inheritIO(); @@ -94,9 +96,9 @@ private static Process boot() throws IOException { command.forEach((Object str) -> { list.add((String) str); }); - + pb.command(list); - + Process process = pb.start(); return process; } diff --git a/FredBoat/pom.xml b/FredBoat/pom.xml index 080cb5414..87de39de7 100644 --- a/FredBoat/pom.xml +++ b/FredBoat/pom.xml @@ -24,207 +24,196 @@ ~ --> - + + + fredboat + FredBoat-Root + 1.0 + + 4.0.0 - fredboat FredBoat 1.0 jar + - UTF-8 - 1.8 - 1.8 fredboat.FredBoat + + + fredboat + Shared + 1.0 + + + net.dv8tion JDA 3.1.1_217 - + net.sf.trove4j trove4j 3.0.3 + org.apache.commons commons-collections4 4.1 compile + com.sedmelluq lavaplayer 1.2.39 + com.sedmelluq jda-nas 1.0.5 + frederikam JCA 1.0 + commons-io commons-io 2.5 - org.springframework.boot - spring-boot-starter-web - 1.5.4.RELEASE - - - org.slf4j - slf4j-api - 1.7.25 + + org.apache.commons + commons-lang3 + 3.6 + ch.qos.logback logback-classic 1.2.3 - org.apache.commons - commons-lang3 - 3.6 + + org.slf4j + slf4j-api + 1.7.25 + com.sparkjava spark-core 2.6.0 + org.yaml snakeyaml 1.18 - + net.sourceforge.htmlunit htmlunit 2.27 - + org.eclipse.jetty.websocket websocket-client - + it.unimi.dsi fastutil 8.1.0 - + org.hibernate hibernate-core 5.2.10.Final + org.hibernate hibernate-ehcache 5.2.10.Final + org.hibernate hibernate-hikaricp 5.2.10.Final + + org.springframework.boot + spring-boot-starter-web + 1.5.4.RELEASE + + + org.springframework spring-orm 4.3.9.RELEASE + org.postgresql postgresql 42.1.1 - org.junit.jupiter - junit-jupiter-api - 5.0.0-M4 - test - - - - + org.xerial sqlite-jdbc 3.19.3 - + com.github.gwenn sqlite-dialect 24970986d0 - - + com.jcraft jsch 0.1.54 - - + org.togglz togglz-core 2.4.1.Final + + + org.junit.jupiter + junit-jupiter-api + 5.0.0-M4 + test + - - - jcenter - jcenter-bintray - http://jcenter.bintray.com - - - - false - - bintray-frederikam-JCA - bintray - http://dl.bintray.com/frederikam/JCA - - - sedmelluq - sedmelluq - http://maven.sedmelluq.com/ - - - jitpack.io - https://jitpack.io - - + - - - maven-clean-plugin - 3.0.0 - - - auto-clean - initialize - - clean - - - - maven-surefire-plugin diff --git a/FredBoat/src/main/java/fredboat/Config.java b/FredBoat/src/main/java/fredboat/Config.java index d1573394d..35f7e28e6 100644 --- a/FredBoat/src/main/java/fredboat/Config.java +++ b/FredBoat/src/main/java/fredboat/Config.java @@ -26,8 +26,8 @@ package fredboat; import com.mashape.unirest.http.exceptions.UnirestException; +import fredboat.shared.constant.DistributionEnum; import fredboat.util.DiscordUtil; -import fredboat.util.constant.DistributionEnum; import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/FredBoat/src/main/java/fredboat/FredBoat.java b/FredBoat/src/main/java/fredboat/FredBoat.java index 601244027..879acc572 100644 --- a/FredBoat/src/main/java/fredboat/FredBoat.java +++ b/FredBoat/src/main/java/fredboat/FredBoat.java @@ -45,8 +45,8 @@ import fredboat.event.EventListenerSelf; import fredboat.event.ShardWatchdogListener; import fredboat.feature.I18n; +import fredboat.shared.constant.DistributionEnum; import fredboat.util.JDAUtil; -import fredboat.util.constant.DistributionEnum; import fredboat.util.log.SimpleLogToSLF4JAdapter; import frederikam.jca.JCA; import frederikam.jca.JCABuilder; diff --git a/FredBoat/src/main/java/fredboat/agent/ShardWatchdogAgent.java b/FredBoat/src/main/java/fredboat/agent/ShardWatchdogAgent.java index 73488d6af..f24a57470 100644 --- a/FredBoat/src/main/java/fredboat/agent/ShardWatchdogAgent.java +++ b/FredBoat/src/main/java/fredboat/agent/ShardWatchdogAgent.java @@ -28,7 +28,7 @@ import fredboat.Config; import fredboat.FredBoat; import fredboat.event.ShardWatchdogListener; -import fredboat.util.constant.DistributionEnum; +import fredboat.shared.constant.DistributionEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/FredBoat/src/main/java/fredboat/audio/AbstractPlayer.java b/FredBoat/src/main/java/fredboat/audio/AbstractPlayer.java index f91ab2d3f..a47f321fe 100644 --- a/FredBoat/src/main/java/fredboat/audio/AbstractPlayer.java +++ b/FredBoat/src/main/java/fredboat/audio/AbstractPlayer.java @@ -48,7 +48,7 @@ import fredboat.audio.queue.TrackEndMarkerHandler; import fredboat.audio.source.PlaylistImportSourceManager; import fredboat.audio.source.SpotifyPlaylistSourceManager; -import fredboat.util.constant.DistributionEnum; +import fredboat.shared.constant.DistributionEnum; import net.dv8tion.jda.core.audio.AudioSendHandler; import org.slf4j.LoggerFactory; diff --git a/FredBoat/src/main/java/fredboat/audio/MusicPersistenceHandler.java b/FredBoat/src/main/java/fredboat/audio/MusicPersistenceHandler.java index 99607d2ed..da0720919 100644 --- a/FredBoat/src/main/java/fredboat/audio/MusicPersistenceHandler.java +++ b/FredBoat/src/main/java/fredboat/audio/MusicPersistenceHandler.java @@ -34,8 +34,8 @@ import fredboat.audio.queue.RepeatMode; import fredboat.audio.queue.SplitAudioTrackContext; import fredboat.feature.I18n; -import fredboat.util.constant.DistributionEnum; -import fredboat.util.constant.ExitCodes; +import fredboat.shared.constant.DistributionEnum; +import fredboat.shared.constant.ExitCodes; import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.core.entities.VoiceChannel; diff --git a/FredBoat/src/main/java/fredboat/command/admin/BotRestartCommand.java b/FredBoat/src/main/java/fredboat/command/admin/BotRestartCommand.java index f1ec73197..3c379604d 100644 --- a/FredBoat/src/main/java/fredboat/command/admin/BotRestartCommand.java +++ b/FredBoat/src/main/java/fredboat/command/admin/BotRestartCommand.java @@ -30,7 +30,7 @@ import fredboat.commandmeta.abs.ICommand; import fredboat.commandmeta.abs.ICommandRestricted; import fredboat.perms.PermissionLevel; -import fredboat.util.constant.ExitCodes; +import fredboat.shared.constant.ExitCodes; import fredboat.util.TextUtils; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Member; diff --git a/FredBoat/src/main/java/fredboat/command/admin/ExitCommand.java b/FredBoat/src/main/java/fredboat/command/admin/ExitCommand.java index e85300a73..22d0393b0 100644 --- a/FredBoat/src/main/java/fredboat/command/admin/ExitCommand.java +++ b/FredBoat/src/main/java/fredboat/command/admin/ExitCommand.java @@ -30,7 +30,7 @@ import fredboat.commandmeta.abs.ICommand; import fredboat.commandmeta.abs.ICommandRestricted; import fredboat.perms.PermissionLevel; -import fredboat.util.constant.ExitCodes; +import fredboat.shared.constant.ExitCodes; import fredboat.util.TextUtils; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Member; diff --git a/FredBoat/src/main/java/fredboat/command/admin/UpdateCommand.java b/FredBoat/src/main/java/fredboat/command/admin/UpdateCommand.java index 3b0899373..db251f512 100644 --- a/FredBoat/src/main/java/fredboat/command/admin/UpdateCommand.java +++ b/FredBoat/src/main/java/fredboat/command/admin/UpdateCommand.java @@ -30,7 +30,7 @@ import fredboat.commandmeta.abs.ICommand; import fredboat.commandmeta.abs.ICommandRestricted; import fredboat.perms.PermissionLevel; -import fredboat.util.constant.ExitCodes; +import fredboat.shared.constant.ExitCodes; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.entities.Message; diff --git a/FredBoat/src/main/java/fredboat/command/moderation/PermissionsCommand.java b/FredBoat/src/main/java/fredboat/command/moderation/PermissionsCommand.java index 0f8a9ce19..8ab907eec 100644 --- a/FredBoat/src/main/java/fredboat/command/moderation/PermissionsCommand.java +++ b/FredBoat/src/main/java/fredboat/command/moderation/PermissionsCommand.java @@ -35,9 +35,9 @@ import fredboat.feature.togglz.FeatureFlags; import fredboat.perms.PermissionLevel; import fredboat.perms.PermsUtil; +import fredboat.shared.constant.BotConstants; import fredboat.util.ArgumentUtil; import fredboat.util.TextUtils; -import fredboat.util.constant.BotConstants; import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Guild; diff --git a/FredBoat/src/main/java/fredboat/command/music/info/NowplayingCommand.java b/FredBoat/src/main/java/fredboat/command/music/info/NowplayingCommand.java index abfaa80f3..d84210c53 100644 --- a/FredBoat/src/main/java/fredboat/command/music/info/NowplayingCommand.java +++ b/FredBoat/src/main/java/fredboat/command/music/info/NowplayingCommand.java @@ -41,7 +41,7 @@ import fredboat.commandmeta.abs.Command; import fredboat.commandmeta.abs.IMusicCommand; import fredboat.feature.I18n; -import fredboat.util.constant.BotConstants; +import fredboat.shared.constant.BotConstants; import fredboat.util.TextUtils; import fredboat.util.rest.YoutubeAPI; import fredboat.util.rest.YoutubeVideo; diff --git a/FredBoat/src/main/java/fredboat/command/util/ServerInfoCommand.java b/FredBoat/src/main/java/fredboat/command/util/ServerInfoCommand.java index e32a66aef..fd61c7f49 100644 --- a/FredBoat/src/main/java/fredboat/command/util/ServerInfoCommand.java +++ b/FredBoat/src/main/java/fredboat/command/util/ServerInfoCommand.java @@ -28,7 +28,7 @@ import fredboat.commandmeta.abs.Command; import fredboat.commandmeta.abs.IUtilCommand; import fredboat.feature.I18n; -import fredboat.util.constant.BotConstants; +import fredboat.shared.constant.BotConstants; import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.OnlineStatus; import net.dv8tion.jda.core.entities.Guild; diff --git a/FredBoat/src/main/java/fredboat/commandmeta/CommandManager.java b/FredBoat/src/main/java/fredboat/commandmeta/CommandManager.java index 27d27a20c..7eb738f91 100644 --- a/FredBoat/src/main/java/fredboat/commandmeta/CommandManager.java +++ b/FredBoat/src/main/java/fredboat/commandmeta/CommandManager.java @@ -34,10 +34,10 @@ import fredboat.feature.I18n; import fredboat.perms.PermissionLevel; import fredboat.perms.PermsUtil; +import fredboat.shared.constant.BotConstants; +import fredboat.shared.constant.DistributionEnum; import fredboat.util.DiscordUtil; import fredboat.util.TextUtils; -import fredboat.util.constant.BotConstants; -import fredboat.util.constant.DistributionEnum; import fredboat.util.rest.RestActionScheduler; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Guild; diff --git a/FredBoat/src/main/java/fredboat/commandmeta/init/MusicCommandInitializer.java b/FredBoat/src/main/java/fredboat/commandmeta/init/MusicCommandInitializer.java index 7e137998b..5a27e84ff 100644 --- a/FredBoat/src/main/java/fredboat/commandmeta/init/MusicCommandInitializer.java +++ b/FredBoat/src/main/java/fredboat/commandmeta/init/MusicCommandInitializer.java @@ -46,7 +46,7 @@ import fredboat.command.util.UserInfoCommand; import fredboat.commandmeta.CommandRegistry; import fredboat.perms.PermissionLevel; -import fredboat.util.constant.DistributionEnum; +import fredboat.shared.constant.DistributionEnum; import fredboat.util.rest.SearchUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/FredBoat/src/main/java/fredboat/util/DiscordUtil.java b/FredBoat/src/main/java/fredboat/util/DiscordUtil.java index cccde82e6..03d07ae90 100644 --- a/FredBoat/src/main/java/fredboat/util/DiscordUtil.java +++ b/FredBoat/src/main/java/fredboat/util/DiscordUtil.java @@ -29,7 +29,7 @@ import com.mashape.unirest.http.exceptions.UnirestException; import fredboat.Config; import fredboat.feature.I18n; -import fredboat.util.constant.BotConstants; +import fredboat.shared.constant.BotConstants; import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.core.OnlineStatus; import net.dv8tion.jda.core.entities.*; diff --git a/FredBoat/src/test/java/fredboat/ProvideJDASingleton.java b/FredBoat/src/test/java/fredboat/ProvideJDASingleton.java index 9eeec6638..99010a501 100644 --- a/FredBoat/src/test/java/fredboat/ProvideJDASingleton.java +++ b/FredBoat/src/test/java/fredboat/ProvideJDASingleton.java @@ -1,6 +1,6 @@ package fredboat; -import fredboat.util.constant.BotConstants; +import fredboat.shared.constant.BotConstants; import fredboat.util.TextUtils; import net.dv8tion.jda.core.AccountType; import net.dv8tion.jda.core.EmbedBuilder; diff --git a/Shared/pom.xml b/Shared/pom.xml new file mode 100644 index 000000000..911d791d9 --- /dev/null +++ b/Shared/pom.xml @@ -0,0 +1,47 @@ + + + + + + fredboat + FredBoat-Root + 1.0 + + + 4.0.0 + Shared + 1.0 + + + + org.json + json + 20170516 + + + \ No newline at end of file diff --git a/FredBoat/src/main/java/fredboat/util/constant/BotConstants.java b/Shared/src/main/java/fredboat/shared/constant/BotConstants.java similarity index 97% rename from FredBoat/src/main/java/fredboat/util/constant/BotConstants.java rename to Shared/src/main/java/fredboat/shared/constant/BotConstants.java index 8a1e1bc18..54a8ae3bd 100644 --- a/FredBoat/src/main/java/fredboat/util/constant/BotConstants.java +++ b/Shared/src/main/java/fredboat/shared/constant/BotConstants.java @@ -23,7 +23,7 @@ * */ -package fredboat.util.constant; +package fredboat.shared.constant; import java.awt.*; diff --git a/FredBoat/src/main/java/fredboat/util/constant/DistributionEnum.java b/Shared/src/main/java/fredboat/shared/constant/DistributionEnum.java similarity index 97% rename from FredBoat/src/main/java/fredboat/util/constant/DistributionEnum.java rename to Shared/src/main/java/fredboat/shared/constant/DistributionEnum.java index acbc684d0..f2b803186 100644 --- a/FredBoat/src/main/java/fredboat/util/constant/DistributionEnum.java +++ b/Shared/src/main/java/fredboat/shared/constant/DistributionEnum.java @@ -23,7 +23,7 @@ * */ -package fredboat.util.constant; +package fredboat.shared.constant; public enum DistributionEnum { MAIN("production", false), diff --git a/FredBoat/src/main/java/fredboat/util/constant/ExitCodes.java b/Shared/src/main/java/fredboat/shared/constant/ExitCodes.java similarity index 97% rename from FredBoat/src/main/java/fredboat/util/constant/ExitCodes.java rename to Shared/src/main/java/fredboat/shared/constant/ExitCodes.java index 4a7dffb59..100833eee 100644 --- a/FredBoat/src/main/java/fredboat/util/constant/ExitCodes.java +++ b/Shared/src/main/java/fredboat/shared/constant/ExitCodes.java @@ -23,7 +23,7 @@ * */ -package fredboat.util.constant; +package fredboat.shared.constant; public class ExitCodes { diff --git a/pom.xml b/pom.xml index 455496d6e..7b56b6393 100644 --- a/pom.xml +++ b/pom.xml @@ -24,15 +24,68 @@ ~ --> - + 4.0.0 fredboat - 1.0 FredBoat-Root + 1.0 pom FredBoat FredBoat-Bootloader + Shared - \ No newline at end of file + + + UTF-8 + 1.8 + 1.8 + + + + + jcenter + jcenter-bintray + http://jcenter.bintray.com + + + + false + + bintray-frederikam-JCA + bintray + http://dl.bintray.com/frederikam/JCA + + + sedmelluq + sedmelluq + http://maven.sedmelluq.com/ + + + jitpack.io + https://jitpack.io + + + + + + + + maven-clean-plugin + 3.0.0 + + + auto-clean + initialize + + clean + + + + + + +