├── .gitignore ├── LICENSE.md ├── README.md ├── app ├── .editorconfig ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ ├── java │ └── com │ │ └── senither │ │ └── hypixel │ │ ├── AppInfo.java │ │ ├── Constants.java │ │ ├── Main.java │ │ ├── SkyblockAssistant.java │ │ ├── blacklist │ │ ├── Blacklist.java │ │ ├── BlacklistEntity.java │ │ ├── Rate.java │ │ └── Ratelimit.java │ │ ├── chat │ │ ├── DefaultPlaceholders.java │ │ ├── MessageFactory.java │ │ ├── MessageType.java │ │ ├── PlaceholderMessage.java │ │ ├── PlaceholderType.java │ │ └── SimplePaginator.java │ │ ├── commands │ │ ├── CategoryIcons.java │ │ ├── CommandContainer.java │ │ ├── CommandManager.java │ │ ├── ThrottleContainer.java │ │ ├── administration │ │ │ ├── BanLogCommand.java │ │ │ ├── DonationCommand.java │ │ │ ├── GuildRankScanCommand.java │ │ │ ├── GuildSetupCommand.java │ │ │ ├── MessageCommand.java │ │ │ ├── RankCheckCommand.java │ │ │ ├── RankRequirementCommand.java │ │ │ ├── SettingsCommand.java │ │ │ ├── SplashCommand.java │ │ │ └── settings │ │ │ │ ├── AutoRenameCommand.java │ │ │ │ ├── BanLogCommand.java │ │ │ │ ├── DefaultRoleCommand.java │ │ │ │ ├── DonationTrackerCommand.java │ │ │ │ ├── GuildMemberRoleCommand.java │ │ │ │ └── SplashTrackerCommand.java │ │ ├── calculators │ │ │ ├── PetsCalculatorCommand.java │ │ │ ├── SkillsCalculatorCommand.java │ │ │ ├── SkillsExperienceCalculatorCommand.java │ │ │ └── WeightCalculatorCommand.java │ │ ├── general │ │ │ ├── AmIBanned.java │ │ │ ├── HelpCommand.java │ │ │ └── VerifyCommand.java │ │ ├── middlewares │ │ │ ├── BlacklistMiddleware.java │ │ │ ├── ThrottleMiddleware.java │ │ │ └── VerificationMiddleware.java │ │ ├── misc │ │ │ ├── BoopCommand.java │ │ │ ├── BoopOptCommand.java │ │ │ ├── BotStatsCommand.java │ │ │ ├── InformationCommand.java │ │ │ └── PingCommand.java │ │ └── statistics │ │ │ ├── AuctionHouseCommand.java │ │ │ ├── AuctionHouseStatisticsCommand.java │ │ │ ├── BankBalanceCommand.java │ │ │ ├── BazaarCommand.java │ │ │ ├── CatacombsCommand.java │ │ │ ├── GuildExperienceLeaderboardCommand.java │ │ │ ├── LeaderboardCommand.java │ │ │ ├── PetsCommand.java │ │ │ ├── PlayerLeaderboardCommand.java │ │ │ ├── PlayerOverviewCommand.java │ │ │ ├── SkillsCommand.java │ │ │ ├── SlayerCommand.java │ │ │ ├── SplashCostCommand.java │ │ │ └── TalismansCommand.java │ │ ├── config │ │ ├── Configuration.java │ │ └── ConfigurationLoader.java │ │ ├── contracts │ │ ├── blacklist │ │ │ └── PunishmentLevel.java │ │ ├── chat │ │ │ ├── Paginator.java │ │ │ ├── PaginatorClosure.java │ │ │ ├── PlaceholderFunction.java │ │ │ └── Restable.java │ │ ├── commands │ │ │ ├── CalculatorCommand.java │ │ │ ├── Command.java │ │ │ ├── DonationAdditionFunction.java │ │ │ ├── GetWeightCalculator.java │ │ │ ├── Middleware.java │ │ │ ├── SetCalculatableSkill.java │ │ │ ├── SettingsSubCommand.java │ │ │ └── SkillCommand.java │ │ ├── database │ │ │ ├── CollectionEach.java │ │ │ ├── DatabaseConnection.java │ │ │ └── Migration.java │ │ ├── hypixel │ │ │ ├── PlayerStatConversionFunction.java │ │ │ └── Response.java │ │ ├── inventory │ │ │ ├── InventoryDecoder.java │ │ │ └── Searchable.java │ │ ├── rank │ │ │ ├── ItemRequirement.java │ │ │ ├── ObjectClosure.java │ │ │ ├── RankCommandHandler.java │ │ │ ├── RankRequirementChecker.java │ │ │ └── WeaponCondition.java │ │ ├── scheduler │ │ │ └── Job.java │ │ ├── servlet │ │ │ └── SparkRoute.java │ │ └── statistics │ │ │ ├── CanCalculateWeight.java │ │ │ ├── Checker.java │ │ │ ├── DungeonWeightRelationFunction.java │ │ │ ├── HasLevel.java │ │ │ ├── Jsonable.java │ │ │ ├── SkillWeightRelationFunction.java │ │ │ ├── SlayerFunction.java │ │ │ ├── SlayerWeightRelationFunction.java │ │ │ └── StatisticsResponse.java │ │ ├── database │ │ ├── DatabaseManager.java │ │ ├── MigrationManager.java │ │ ├── MySQLConnection.java │ │ ├── collection │ │ │ ├── Collection.java │ │ │ └── DataRow.java │ │ ├── controller │ │ │ ├── GuildController.java │ │ │ └── PlayerDonationController.java │ │ └── migrations │ │ │ ├── AddAutoRenameColumnToGuildsTableMigration.java │ │ │ ├── AddBanLogRoleColumnToGuildsTableMigration.java │ │ │ ├── AddDefaultRoleColumnToGuildsTableMigration.java │ │ │ ├── AddDonationNotificationChannelColumnToGuildsTableMigration.java │ │ │ ├── AddDonationsChannelColumnToGuildsTableMigration.java │ │ │ ├── AddDonationsColumnsToGuildsTableMigration.java │ │ │ ├── AddGuildMemberRoleColumnToGuildsTableMigration.java │ │ │ ├── AddLastCheckedColumnToUuidsTableMigration.java │ │ │ ├── AddLastDonatedAtColumnToDonationsTableMigration.java │ │ │ ├── AddLastUpdatedAtColumnToProfileAndPlayerTableMigration.java │ │ │ ├── AddRankRequirementsColumnToGuildsTableMigration.java │ │ │ ├── AddSplashManagementRoleColumnToGuildsTableMigration.java │ │ │ ├── AddSplashPointsColumnToGuildsTableMigration.java │ │ │ ├── AddSplashesColumnsToGuildsTableMigration.java │ │ │ ├── CreateBanLogTableMigration.java │ │ │ ├── CreateBlacklistTableMigration.java │ │ │ ├── CreateBoopOptTableMigration.java │ │ │ ├── CreateDonationPointsTableMigration.java │ │ │ ├── CreateGuildsTableMigration.java │ │ │ ├── CreateMessagesTableMigration.java │ │ │ ├── CreatePlayersTableMigration.java │ │ │ ├── CreateProfilesTableMigration.java │ │ │ ├── CreateReportsTableMigration.java │ │ │ ├── CreateSplashesTableMigration.java │ │ │ └── CreateUUIDsTableMigration.java │ │ ├── exceptions │ │ ├── CommandAlreadyRegisteredException.java │ │ ├── FriendlyException.java │ │ ├── InvalidFormatException.java │ │ ├── InvalidRequestURIException.java │ │ └── NoRankRequirementException.java │ │ ├── hypixel │ │ ├── ClientContainer.java │ │ ├── Hypixel.java │ │ ├── HypixelRank.java │ │ ├── MojangPlayerUUID.java │ │ ├── SkyBlockSkill.java │ │ ├── bazaar │ │ │ ├── BazaarProduct.java │ │ │ └── BazaarProductReply.java │ │ ├── leaderboard │ │ │ ├── LeaderboardPlayer.java │ │ │ └── LeaderboardType.java │ │ └── response │ │ │ ├── AuctionHouseResponse.java │ │ │ ├── GuildLeaderboardResponse.java │ │ │ ├── GuildMetricsResponse.java │ │ │ ├── LeaderboardStatsResponse.java │ │ │ └── PlayerLeaderboardResponse.java │ │ ├── inventory │ │ ├── Inventory.java │ │ ├── Item.java │ │ ├── ItemRarity.java │ │ └── ItemType.java │ │ ├── listeners │ │ ├── GenericEventListener.java │ │ ├── MemberActivityEventListener.java │ │ ├── MessageEventListener.java │ │ └── ReactionEventListener.java │ │ ├── metrics │ │ ├── Metrics.java │ │ └── PrometheusMetricsServlet.java │ │ ├── rank │ │ ├── RankCheckResponse.java │ │ ├── RankRequirementType.java │ │ ├── checkers │ │ │ ├── ArmorChecker.java │ │ │ ├── AverageSkillsChecker.java │ │ │ ├── BankChecker.java │ │ │ ├── FairySoulsChecker.java │ │ │ ├── PowerOrbsChecker.java │ │ │ ├── SlayerChecker.java │ │ │ ├── TalismansChecker.java │ │ │ └── WeaponsChecker.java │ │ ├── handler │ │ │ ├── CustomObjectValueHandler.java │ │ │ ├── DoubleObjectValueHandler.java │ │ │ ├── IntegerValueHandler.java │ │ │ └── ItemValueHandler.java │ │ └── items │ │ │ ├── Armor.java │ │ │ ├── ArmorSet.java │ │ │ ├── Collection.java │ │ │ ├── PowerOrb.java │ │ │ └── Weapon.java │ │ ├── reports │ │ ├── PlayerReport.java │ │ ├── Report.java │ │ ├── ReportService.java │ │ └── UnfinishedPlayerReport.java │ │ ├── scheduler │ │ ├── ScheduleManager.java │ │ └── jobs │ │ │ ├── DecayDonationPointsJob.java │ │ │ ├── DrainReportQueueJob.java │ │ │ ├── GarbageCollectorJob.java │ │ │ ├── HypixelRankSynchronizeJob.java │ │ │ ├── SplashQueueJob.java │ │ │ ├── SyncMetricsJob.java │ │ │ └── UpdateGuildDataJob.java │ │ ├── servlet │ │ ├── WebServlet.java │ │ ├── filters │ │ │ └── HttpFilter.java │ │ ├── handlers │ │ │ ├── NotFoundRouteHandler.java │ │ │ └── SparkExceptionHandler.java │ │ └── routes │ │ │ ├── GetGuildRoute.java │ │ │ ├── GetMetrics.java │ │ │ ├── GetProfileRoute.java │ │ │ ├── GetReportRoute.java │ │ │ └── GetUsernameRoute.java │ │ ├── splash │ │ ├── SplashContainer.java │ │ └── SplashManager.java │ │ ├── statistics │ │ ├── StatisticsChecker.java │ │ ├── checker │ │ │ ├── DungeonChecker.java │ │ │ ├── PetsChecker.java │ │ │ ├── SkillsChecker.java │ │ │ └── SlayerChecker.java │ │ ├── responses │ │ │ ├── DungeonResponse.java │ │ │ ├── PetsResponse.java │ │ │ ├── SkillsResponse.java │ │ │ └── SlayerResponse.java │ │ └── weight │ │ │ ├── DungeonWeight.java │ │ │ ├── SkillWeight.java │ │ │ ├── SlayerWeight.java │ │ │ └── Weight.java │ │ ├── time │ │ ├── Carbon.java │ │ ├── Day.java │ │ ├── Formats.java │ │ ├── Month.java │ │ └── Time.java │ │ └── utils │ │ ├── CheckPermissionUtil.java │ │ ├── NumberUtil.java │ │ ├── RestActionUtil.java │ │ └── StringReplacementUtil.java │ └── resources │ ├── app.properties │ ├── config.json │ ├── logback.xml │ └── logback_debug.xml └── web ├── .editorconfig ├── .gitignore ├── assets ├── js │ ├── app.js │ ├── components │ │ ├── FullscreenHeroStatus.vue │ │ └── PlayerReport.vue │ ├── config.js │ └── views │ │ ├── App.vue │ │ ├── LoadingReport.vue │ │ └── Report.vue └── sass │ ├── _variables.scss │ ├── app.scss │ └── pages │ └── report.scss ├── package.json ├── public ├── .htaccess └── index.html ├── webpack.mix.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.todo 3 | -------------------------------------------------------------------------------- /app/.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | root = true 3 | end_of_line = lf 4 | insert_final_newline = true 5 | indent_style = space 6 | indent_size = 4 7 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | # Package Files # 2 | *.jar 3 | !gradle-wrapper.jar 4 | *.war 5 | *.ear 6 | 7 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 8 | hs_err_pid* 9 | 10 | # Editor settings 11 | .idea/ 12 | .ideaDataSources/ 13 | /*.iws 14 | /*.ipr 15 | /*.iml 16 | /*.iml 17 | 18 | # Compile location 19 | HypixelSkyblockAssistant.jar 20 | .gradle/* 21 | target/ 22 | build/ 23 | out/ 24 | 25 | # Runtime output 26 | /config.json 27 | storage/logs 28 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'application' 3 | id 'com.github.johnrengelman.shadow' version '2.0.2' 4 | } 5 | 6 | apply plugin: 'java' 7 | apply plugin: 'idea' 8 | 9 | group 'com.senither' 10 | version '0.1-SNAPSHOT' 11 | mainClassName = 'com.senither.hypixel.Main' 12 | 13 | sourceCompatibility = 11 14 | targetCompatibility = 11 15 | 16 | ext { 17 | moduleName = 'Hypixel Skyblock Assistant' 18 | } 19 | 20 | shadowJar { 21 | archiveName = "HypixelSkyblockAssistant.jar" 22 | 23 | doLast { 24 | copy { 25 | from 'build/libs/HypixelSkyblockAssistant.jar' 26 | into '.' 27 | } 28 | } 29 | } 30 | 31 | tasks.withType(JavaCompile) { 32 | dependsOn 'clean' 33 | options.encoding = 'UTF-8' 34 | options.compilerArgs << "-Xlint:-unchecked" 35 | } 36 | 37 | task fatJar(type: Jar) { 38 | manifest { 39 | attributes 'Implementation-Title': 'HypixelSkyblockAssistant: Discord Bot', 40 | 'Implementation-Version': version, 41 | 'Main-Class': mainClassName 42 | } 43 | 44 | baseName = project.name 45 | 46 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } 47 | with jar 48 | } 49 | 50 | repositories { 51 | mavenCentral() 52 | jcenter() 53 | maven { url "https://jitpack.io" } 54 | 55 | // Used for pulling down JDA 56 | maven { 57 | name 'm2-dv8tion' 58 | url 'https://m2.dv8tion.net/releases' 59 | } 60 | } 61 | 62 | dependencies { 63 | compile group: 'net.dv8tion', name: 'JDA', version: '4.2.1_269' 64 | compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6' 65 | compile group: 'com.github.Senither.PublicAPI', name: 'Example', version: '6cacdeed8a' 66 | compile group: 'com.github.Steveice10', name: 'OpenNBT', version: '1.3' 67 | compile group: 'com.sparkjava', name: 'spark-core', version: '2.8.0' 68 | compile group: 'io.prometheus', name: 'simpleclient', version: '0.1.0' 69 | compile group: 'io.prometheus', name: 'simpleclient_servlet', version: '0.1.0' 70 | compile group: 'io.prometheus', name: 'simpleclient_logback', version: '0.1.0' 71 | compile group: 'io.prometheus', name: 'simpleclient_hotspot', version: '0.1.0' 72 | compile group: 'io.prometheus', name: 'simpleclient_guava', version: '0.1.0' 73 | compile group: 'com.google.guava', name: 'guava', version: '20.0' 74 | compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.18' 75 | compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' 76 | compile group: 'org.reflections', name: 'reflections', version: '0.9.11' 77 | testCompile group: 'junit', name: 'junit', version: '4.12' 78 | } 79 | 80 | import org.apache.tools.ant.filters.ReplaceTokens 81 | 82 | processResources { 83 | filesMatching("**/app.properties") { 84 | filter ReplaceTokens, tokens: [ 85 | "project.version" : project.version, 86 | "project.groupId" : project.group, 87 | "project.artifactId": project.ext.moduleName 88 | ] 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /app/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Senither/Hypixel-Skyblock-Assistant/925a2ce73730fbc7ae030b2a1aaa4f26ce193a32/app/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue May 12 17:22:46 CEST 2020 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /app/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'HypixelSkyblockAssistant' 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/AppInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel; 23 | 24 | import java.io.IOException; 25 | import java.util.Properties; 26 | 27 | public class AppInfo { 28 | 29 | private static AppInfo instance; 30 | 31 | public final String version; 32 | public final String groupId; 33 | public final String artifactId; 34 | 35 | protected final Properties properties = new Properties(); 36 | 37 | private AppInfo() { 38 | try { 39 | properties.load(getClass().getClassLoader().getResourceAsStream("app.properties")); 40 | } catch (IOException e) { 41 | throw new RuntimeException("Failed to load app.properties", e); 42 | } 43 | 44 | this.version = properties.getProperty("version"); 45 | this.groupId = properties.getProperty("groupId"); 46 | this.artifactId = properties.getProperty("artifactId"); 47 | } 48 | 49 | public static AppInfo getAppInfo() { 50 | if (instance == null) { 51 | instance = new AppInfo(); 52 | } 53 | return instance; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel; 23 | 24 | import ch.qos.logback.classic.util.ContextInitializer; 25 | 26 | import javax.security.auth.login.LoginException; 27 | import java.io.IOException; 28 | 29 | public class Main { 30 | 31 | public static void main(String[] args) throws LoginException, IOException { 32 | if (args.length > 0 && args[0].equalsIgnoreCase("--debug")) { 33 | System.setProperty(ContextInitializer.CONFIG_FILE_PROPERTY, "logback_debug.xml"); 34 | } 35 | new SkyblockAssistant(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/blacklist/BlacklistEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018. 3 | * 4 | * This file is part of AvaIre. 5 | * 6 | * AvaIre is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * AvaIre is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with AvaIre. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.blacklist; 23 | 24 | import com.senither.hypixel.time.Carbon; 25 | 26 | import javax.annotation.Nullable; 27 | 28 | @SuppressWarnings("WeakerAccess") 29 | public class BlacklistEntity { 30 | 31 | private final long id; 32 | private final Carbon expiresIn; 33 | private final String reason; 34 | 35 | /** 36 | * Create a new blacklist entity with the given id, and expires time. 37 | * 38 | * @param id The ID that the blacklist entity should be linked to. 39 | * @param reason The reason the entity was blacklisted. 40 | * @param expiresIn The carbon time instance for when the blacklist entity should expire. 41 | */ 42 | BlacklistEntity(long id, @Nullable String reason, @Nullable Carbon expiresIn) { 43 | this.id = id; 44 | this.reason = reason; 45 | this.expiresIn = expiresIn; 46 | } 47 | 48 | /** 49 | * Create a new blacklist entity with the given and id. The blacklist 50 | * entity will be created with a null expire time, making 51 | * the blacklist entity last forever. 52 | * 53 | * @param id The ID that the blacklist entity should be linked to. 54 | * @param reason The reason the entity was blacklisted. 55 | */ 56 | public BlacklistEntity(long id, @Nullable String reason) { 57 | this(id, reason, null); 58 | } 59 | 60 | /** 61 | * The ID that the blacklist entity is linked to. 62 | * 63 | * @return The ID that the blacklist entity is linked to. 64 | */ 65 | public long getId() { 66 | return id; 67 | } 68 | 69 | /** 70 | * Checks if the blacklist entity is still blacklisted. 71 | * 72 | * @return True if the user is still blacklisted, False otherwise. 73 | */ 74 | public boolean isBlacklisted() { 75 | return expiresIn == null || expiresIn.isFuture(); 76 | } 77 | 78 | /** 79 | * Gets the reason the entity was blacklist form, or null. 80 | * 81 | * @return Possibly-null, the reason the entity was blacklisted for. 82 | */ 83 | @Nullable 84 | public String getReason() { 85 | return reason; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/blacklist/Rate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018. 3 | * 4 | * This file is part of AvaIre. 5 | * 6 | * AvaIre is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * AvaIre is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with AvaIre. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.blacklist; 23 | 24 | import javax.annotation.Nullable; 25 | 26 | public class Rate { 27 | 28 | /** 29 | * The ID of the user that the rate instance was created for. 30 | */ 31 | private final long userId; 32 | 33 | /** 34 | * The current rate index for the {@link #timestamps}. 35 | */ 36 | private int index; 37 | 38 | /** 39 | * The array that holds the last timestamps for when the rate 40 | * was hit, the array should always be the same length as 41 | * the {@link Ratelimit#hitLimit hit limit}. 42 | */ 43 | private Long[] timestamps; 44 | 45 | /** 46 | * Creates a new rate instance for the given user ID. 47 | * 48 | * @param userId The ID of the user to create the rate instance for. 49 | */ 50 | public Rate(long userId) { 51 | this.userId = userId; 52 | this.index = 0; 53 | this.timestamps = new Long[Ratelimit.hitLimit]; 54 | } 55 | 56 | /** 57 | * Hits the rate, creating a timestamp for the current {@link #index}. 58 | */ 59 | void hit() { 60 | timestamps[index++] = System.currentTimeMillis(); 61 | if (index >= Ratelimit.hitLimit) { 62 | index = 0; 63 | } 64 | } 65 | 66 | /** 67 | * Gets the amount of valid hits by comparing the time from the {@link #timestamps} 68 | * and the {@link Ratelimit#hitTime rate limit time}. 69 | * 70 | * @return The amount of valid hits currently in the rate instance. 71 | */ 72 | int getHits() { 73 | int hits = 0; 74 | for (Long time : timestamps) { 75 | if (time != null && (time + Ratelimit.hitTime) > System.currentTimeMillis()) { 76 | hits++; 77 | } 78 | } 79 | return hits; 80 | } 81 | 82 | /** 83 | * Gets the last timestamp for the current rate instance. 84 | * 85 | * @return Possibly-null, the last timestamp for the current rate. 86 | */ 87 | @Nullable 88 | Long getLast() { 89 | int i = index - 1; 90 | if (i < 0) { 91 | i = Ratelimit.hitLimit - 1; 92 | } 93 | return timestamps[i]; 94 | } 95 | 96 | @Override 97 | public int hashCode() { 98 | return Long.hashCode(userId); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/chat/MessageType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.chat; 23 | 24 | import java.awt.*; 25 | 26 | public enum MessageType { 27 | 28 | ERROR("#EF5350"), 29 | WARNING("#FAA61A"), 30 | SUCCESS("#43B581"), 31 | INFO("#3A71C1"); 32 | 33 | private final String color; 34 | 35 | MessageType(String color) { 36 | this.color = color; 37 | } 38 | 39 | public Color getColor() { 40 | return Color.decode(this.color); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/chat/PlaceholderType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018. 3 | * 4 | * This file is part of AvaIre. 5 | * 6 | * AvaIre is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * AvaIre is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with AvaIre. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.chat; 23 | 24 | import com.senither.hypixel.contracts.chat.PlaceholderFunction; 25 | 26 | public enum PlaceholderType { 27 | 28 | ALL, 29 | GUILD(DefaultPlaceholders::toGuild), 30 | CHANNEL(DefaultPlaceholders::toChannel), 31 | USER(DefaultPlaceholders::toUser); 32 | 33 | private final PlaceholderFunction function; 34 | 35 | PlaceholderType(PlaceholderFunction function) { 36 | this.function = function; 37 | } 38 | 39 | PlaceholderType() { 40 | this.function = null; 41 | } 42 | 43 | public PlaceholderFunction getFunction() { 44 | return function; 45 | } 46 | 47 | public String parse(Object object, String message) { 48 | return DefaultPlaceholders.parse(this, object, message); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/chat/SimplePaginator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018. 3 | * 4 | * This file is part of AvaIre. 5 | * 6 | * AvaIre is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * AvaIre is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with AvaIre. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.chat; 23 | 24 | import com.senither.hypixel.contracts.chat.Paginator; 25 | 26 | import java.util.Iterator; 27 | import java.util.List; 28 | import java.util.Map; 29 | 30 | public class SimplePaginator extends Paginator { 31 | 32 | private static final String defaultFooterNote = "Page **{0}** out of **{1}** pages.\n`{2} [page]`"; 33 | 34 | public SimplePaginator(Map items, int perPage, int currentPage) { 35 | super(items, perPage, currentPage); 36 | } 37 | 38 | public SimplePaginator(Map items, int perPage, String currentPage) { 39 | super(items, perPage, currentPage); 40 | } 41 | 42 | public SimplePaginator(Map items, int perPage) { 43 | super(items, perPage, 1); 44 | } 45 | 46 | public SimplePaginator(List items, int perPage, int currentPage) { 47 | super(items, perPage, currentPage); 48 | } 49 | 50 | public SimplePaginator(List items, int perPage, String currentPage) { 51 | super(items, perPage, currentPage); 52 | } 53 | 54 | public SimplePaginator(List items, int perPage) { 55 | super(items, perPage, 1); 56 | } 57 | 58 | public SimplePaginator(Iterator iterator, int perPage, int currentPage) { 59 | super(iterator, perPage, currentPage); 60 | } 61 | 62 | public SimplePaginator(Iterator iterator, int perPage) { 63 | this(iterator, perPage, 1); 64 | } 65 | 66 | public String generateFooter(String command) { 67 | return String.format("Page **%s** out of **%s** pages.\n`%s [page]`", 68 | getCurrentPage(), 69 | getPages(), 70 | command 71 | ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/commands/CategoryIcons.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.commands; 23 | 24 | public enum CategoryIcons { 25 | 26 | ADMINISTRATION("\u2699"), 27 | CALCULATORS("\uD83C\uDFB2"), 28 | GENERAL("\uD83D\uDEE0"), 29 | MISC("\uD83D\uDD0E"), 30 | STATISTICS("\uD83D\uDEE1"); 31 | 32 | private final String icon; 33 | 34 | CategoryIcons(String icon) { 35 | this.icon = icon; 36 | } 37 | 38 | public static CategoryIcons fromName(String name) { 39 | for (CategoryIcons icon : values()) { 40 | if (icon.name().equalsIgnoreCase(name)) { 41 | return icon; 42 | } 43 | } 44 | return null; 45 | } 46 | 47 | public String getIcon() { 48 | return icon; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/commands/CommandContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.commands; 23 | 24 | import com.senither.hypixel.contracts.commands.Command; 25 | 26 | import java.util.List; 27 | 28 | public class CommandContainer { 29 | 30 | private final Command command; 31 | private final String category; 32 | 33 | CommandContainer(Command command) { 34 | this.command = command; 35 | 36 | String[] parts = command.getClass().getTypeName().split("\\."); 37 | String categoryPackage = parts[parts.length - 2]; 38 | 39 | category = categoryPackage.substring(0, 1).toUpperCase() + categoryPackage.substring(1, categoryPackage.length()).toLowerCase(); 40 | } 41 | 42 | public Command getCommand() { 43 | return command; 44 | } 45 | 46 | public CategoryIcons getCategoryIcon() { 47 | return CategoryIcons.fromName(getCategory()); 48 | } 49 | 50 | public String getCategory() { 51 | return category; 52 | } 53 | 54 | public String getName() { 55 | return command.getName(); 56 | } 57 | 58 | public List getDescription() { 59 | return command.getDescription(); 60 | } 61 | 62 | public List getTriggers() { 63 | return command.getTriggers(); 64 | } 65 | 66 | public boolean isVisible() { 67 | return command.isVisible(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/commands/ThrottleContainer.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.commands; 2 | 3 | public class ThrottleContainer { 4 | 5 | private final int maxAttempts; 6 | private final int decaySeconds; 7 | 8 | public ThrottleContainer(int maxAttempts, int decaySeconds) { 9 | this.maxAttempts = maxAttempts; 10 | this.decaySeconds = decaySeconds; 11 | } 12 | 13 | public int getMaxAttempts() { 14 | return maxAttempts; 15 | } 16 | 17 | public int getDecaySeconds() { 18 | return decaySeconds; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/commands/middlewares/BlacklistMiddleware.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.commands.middlewares; 2 | 3 | import com.senither.hypixel.SkyblockAssistant; 4 | import com.senither.hypixel.contracts.commands.Command; 5 | import com.senither.hypixel.contracts.commands.Middleware; 6 | import net.dv8tion.jda.api.events.message.MessageReceivedEvent; 7 | 8 | import javax.annotation.Nonnull; 9 | 10 | public class BlacklistMiddleware extends Middleware { 11 | 12 | @Override 13 | public boolean handle(@Nonnull SkyblockAssistant app, @Nonnull MessageReceivedEvent event, @Nonnull Command command) throws Exception { 14 | return !app.getBlacklist().isBlacklisted(event.getAuthor()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/commands/middlewares/VerificationMiddleware.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.commands.middlewares; 2 | 3 | import com.google.common.cache.Cache; 4 | import com.google.common.cache.CacheBuilder; 5 | import com.senither.hypixel.Constants; 6 | import com.senither.hypixel.SkyblockAssistant; 7 | import com.senither.hypixel.chat.MessageFactory; 8 | import com.senither.hypixel.contracts.commands.Command; 9 | import com.senither.hypixel.contracts.commands.Middleware; 10 | import net.dv8tion.jda.api.entities.User; 11 | import net.dv8tion.jda.api.events.message.MessageReceivedEvent; 12 | 13 | import javax.annotation.Nonnull; 14 | import java.sql.SQLException; 15 | import java.util.Arrays; 16 | import java.util.concurrent.TimeUnit; 17 | 18 | public class VerificationMiddleware extends Middleware { 19 | 20 | public static final Cache cache = CacheBuilder.newBuilder() 21 | .expireAfterAccess(30, TimeUnit.MINUTES) 22 | .recordStats() 23 | .build(); 24 | 25 | public static void clearVerificationCacheFor(User user) { 26 | cache.invalidate(user.getIdLong()); 27 | } 28 | 29 | @Override 30 | public boolean handle(@Nonnull SkyblockAssistant app, @Nonnull MessageReceivedEvent event, @Nonnull Command command) throws Exception { 31 | if (!command.isVerificationRequired() || isUserVerified(app, event.getAuthor())) { 32 | return true; 33 | } 34 | 35 | MessageFactory.makeError(event.getMessage(), String.join("\n", Arrays.asList( 36 | "You must verify your account with the bot to use this command, you can do this by", 37 | "running `:prefixverify `, where your username is your in-game Minecraft", 38 | "username that has your Discord account linked on Hypixel.net", 39 | "", 40 | "If you haven't already linked your Discord account on Hypixel you can login to", 41 | "the server, go to your Hypixel social settings, click on Discord, and set", 42 | "your username to `:user`" 43 | ))) 44 | .set("prefix", Constants.COMMAND_PREFIX) 45 | .set("user", event.getAuthor().getAsTag()) 46 | .setTitle("Missing verification") 47 | .queue(); 48 | 49 | return false; 50 | } 51 | 52 | private boolean isUserVerified(SkyblockAssistant app, User user) { 53 | Boolean verificationState = cache.getIfPresent(user.getIdLong()); 54 | if (verificationState != null) { 55 | return verificationState; 56 | } 57 | 58 | try { 59 | boolean result = app.getHypixel().getUUIDFromUser(user) != null; 60 | 61 | cache.put(user.getIdLong(), result); 62 | return result; 63 | } catch (SQLException ignored) { 64 | return false; 65 | } 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/commands/misc/PingCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.commands.misc; 23 | 24 | import com.senither.hypixel.SkyblockAssistant; 25 | import com.senither.hypixel.chat.MessageFactory; 26 | import com.senither.hypixel.contracts.commands.Command; 27 | import net.dv8tion.jda.api.events.message.MessageReceivedEvent; 28 | 29 | import java.util.Arrays; 30 | import java.util.Collections; 31 | import java.util.List; 32 | 33 | public class PingCommand extends Command { 34 | 35 | public PingCommand(SkyblockAssistant app) { 36 | super(app); 37 | } 38 | 39 | @Override 40 | public String getName() { 41 | return "Ping"; 42 | } 43 | 44 | @Override 45 | public List getDescription() { 46 | return Arrays.asList( 47 | "Gets the latency between Discord and the bot, this should help", 48 | "determine how quickly the bot will respond to commands, not", 49 | "counting computing time for commands, the command can also", 50 | "just be used to check if the bot is online" 51 | ); 52 | } 53 | 54 | @Override 55 | public List getUsageInstructions() { 56 | return Collections.singletonList("`:command` - Returns the latency of the bot."); 57 | } 58 | 59 | @Override 60 | public List getExampleUsage() { 61 | return Collections.singletonList("`:command`"); 62 | } 63 | 64 | @Override 65 | public List getTriggers() { 66 | return Collections.singletonList("ping"); 67 | } 68 | 69 | @Override 70 | public void onCommand(MessageReceivedEvent event, String[] args) { 71 | event.getJDA().getRestPing().queue(ping -> { 72 | MessageFactory.makeInfo(event.getMessage(), "Pong! Time taken :ping ms, websocket heartbeat :gateway ms.") 73 | .set("gateway", event.getJDA().getGatewayPing()) 74 | .set("ping", String.valueOf(ping)) 75 | .queue(); 76 | }); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/blacklist/PunishmentLevel.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (c) 2018. 4 | * 5 | * This file is part of AvaIre. 6 | * 7 | * AvaIre is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * AvaIre is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with AvaIre. If not, see . 19 | * 20 | * 21 | */ 22 | 23 | package com.senither.hypixel.contracts.blacklist; 24 | 25 | import com.senither.hypixel.time.Carbon; 26 | 27 | public interface PunishmentLevel { 28 | 29 | /** 30 | * The method is used for generating the time for the current punishment 31 | * level, the method should return a modified {@link Carbon carbon} 32 | * instance for the punishment duration. 33 | * 34 | * @return The modified {@link Carbon carbon} instance for the punishment duration. 35 | */ 36 | Carbon generateTime(); 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/chat/PaginatorClosure.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018. 3 | * 4 | * This file is part of AvaIre. 5 | * 6 | * AvaIre is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * AvaIre is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with AvaIre. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.chat; 23 | 24 | public interface PaginatorClosure { 25 | 26 | /** 27 | * Pagination closure, this method is invoked for each entry in 28 | * the paginator while looping over the items for the current 29 | * page via the {@link Paginator#forEach(PaginatorClosure)} method. 30 | * 31 | * @param index The index of the entry. 32 | * @param key The key for the item. 33 | * @param val The value of the item. 34 | */ 35 | void run(int index, Object key, T val); 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/chat/PlaceholderFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018. 3 | * 4 | * This file is part of AvaIre. 5 | * 6 | * AvaIre is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * AvaIre is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with AvaIre. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.chat; 23 | 24 | import net.dv8tion.jda.api.entities.Message; 25 | 26 | @FunctionalInterface 27 | public interface PlaceholderFunction { 28 | 29 | /** 30 | * Parses the placeholder type for the given message object. 31 | * 32 | * @param message The object that should be checked to see if the placeholder can be parsed. 33 | * @param string The message that should be parsed with the placeholders. 34 | * @return The parsed message. 35 | */ 36 | String parse(Message message, String string); 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/commands/DonationAdditionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.commands; 23 | 24 | public interface DonationAdditionFunction { 25 | 26 | void handle(); 27 | 28 | long getAuthorId(); 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/commands/GetWeightCalculator.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.contracts.commands; 2 | 3 | import com.senither.hypixel.statistics.weight.Weight; 4 | 5 | @FunctionalInterface 6 | public interface GetWeightCalculator { 7 | 8 | Weight getWeight(double experience); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/commands/Middleware.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.contracts.commands; 2 | 3 | import com.google.common.cache.Cache; 4 | import com.google.common.cache.CacheBuilder; 5 | import com.senither.hypixel.SkyblockAssistant; 6 | import net.dv8tion.jda.api.events.message.MessageReceivedEvent; 7 | 8 | import javax.annotation.Nonnull; 9 | import java.util.concurrent.Callable; 10 | import java.util.concurrent.TimeUnit; 11 | 12 | public abstract class Middleware { 13 | 14 | public static final Cache messageCache = CacheBuilder.newBuilder() 15 | .recordStats() 16 | .expireAfterWrite(2500, TimeUnit.MILLISECONDS) 17 | .build(); 18 | 19 | public abstract boolean handle(@Nonnull SkyblockAssistant app, @Nonnull MessageReceivedEvent event, @Nonnull Command command) throws Exception; 20 | 21 | protected boolean runMessageCheck(long userId, @Nonnull Callable callback) throws Exception { 22 | return messageCache.get(userId, callback); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/commands/SetCalculatableSkill.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.contracts.commands; 2 | 3 | import com.senither.hypixel.contracts.statistics.StatisticsResponse; 4 | 5 | @FunctionalInterface 6 | public interface SetCalculatableSkill { 7 | 8 | T setCalculateableSkill(T response, double level, double experience); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/commands/SettingsSubCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.commands; 23 | 24 | import com.senither.hypixel.SkyblockAssistant; 25 | import com.senither.hypixel.database.controller.GuildController; 26 | import net.dv8tion.jda.api.events.message.MessageReceivedEvent; 27 | 28 | public abstract class SettingsSubCommand extends Command { 29 | 30 | public SettingsSubCommand(SkyblockAssistant app) { 31 | super(app); 32 | } 33 | 34 | @Override 35 | public void onCommand(MessageReceivedEvent event, String[] args) { 36 | // 37 | } 38 | 39 | public void onCommand(MessageReceivedEvent event, GuildController.GuildEntry guildEntry, String[] args) { 40 | onCommand(event, args); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/database/CollectionEach.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018. 3 | * 4 | * This file is part of AvaIre. 5 | * 6 | * AvaIre is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * AvaIre is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with AvaIre. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.database; 23 | 24 | import com.senither.hypixel.database.collection.Collection; 25 | import com.senither.hypixel.database.collection.DataRow; 26 | 27 | public interface CollectionEach { 28 | 29 | /** 30 | * This is called by by the {@link Collection#each(CollectionEach)}} 31 | * method, used to loops through every entity in the Collection and parses the key and 32 | * {@link com.senither.hypixel.database.collection.DataRow} object to the consumer. 33 | * 34 | * @param key The key for the element 35 | * @param value The data row linked to the key 36 | */ 37 | void forEach(int key, DataRow value); 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/database/Migration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.database; 23 | 24 | import com.senither.hypixel.database.DatabaseManager; 25 | 26 | import java.sql.SQLException; 27 | 28 | public interface Migration { 29 | 30 | boolean up(DatabaseManager databaseManager) throws SQLException; 31 | 32 | boolean down(DatabaseManager databaseManager) throws SQLException; 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/hypixel/PlayerStatConversionFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.hypixel; 23 | 24 | import com.senither.hypixel.hypixel.leaderboard.LeaderboardPlayer; 25 | 26 | @FunctionalInterface 27 | public interface PlayerStatConversionFunction { 28 | 29 | double getStat(LeaderboardPlayer player); 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/hypixel/Response.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.hypixel; 23 | 24 | import com.senither.hypixel.time.Carbon; 25 | 26 | import java.text.ParseException; 27 | import java.text.SimpleDateFormat; 28 | import java.util.Date; 29 | import java.util.Locale; 30 | 31 | @SuppressWarnings("WeakerAccess") 32 | public abstract class Response { 33 | 34 | public static final SimpleDateFormat ISO_8601_DateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.UK); 35 | 36 | protected int status; 37 | 38 | protected static Carbon timestampToCarbonInstance(String timestamp) { 39 | try { 40 | Date date = Response.ISO_8601_DateFormat.parse(timestamp 41 | .replace("Z", "0") 42 | .replace(".", "+") 43 | ); 44 | 45 | return Carbon.now().setTimestamp(date.getTime() / 1000); 46 | } catch (ParseException e) { 47 | return null; 48 | } 49 | } 50 | 51 | public boolean isSuccess() { 52 | return getStatus() == 200; 53 | } 54 | 55 | public int getStatus() { 56 | return status; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/inventory/InventoryDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.inventory; 23 | 24 | import com.github.steveice10.opennbt.NBTIO; 25 | import com.github.steveice10.opennbt.tag.builtin.ByteArrayTag; 26 | import com.github.steveice10.opennbt.tag.builtin.CompoundTag; 27 | import com.github.steveice10.opennbt.tag.builtin.Tag; 28 | import com.google.common.io.ByteSource; 29 | 30 | import java.io.ByteArrayInputStream; 31 | import java.io.IOException; 32 | import java.util.Base64; 33 | import java.util.zip.GZIPInputStream; 34 | 35 | public interface InventoryDecoder { 36 | 37 | default Tag decodeInventoryString(String inventory) throws IOException { 38 | final byte[] decodedInventory = Base64.getDecoder().decode(inventory); 39 | if (decodedInventory == null || decodedInventory.length == 0) { 40 | throw new IOException("Failed to decode inventory, inventory can't be empty or null!"); 41 | } 42 | 43 | if (!isCompressed(decodedInventory)) { 44 | return NBTIO.readTag(ByteSource.wrap(decodedInventory).openStream()); 45 | } 46 | return NBTIO.readTag(new GZIPInputStream(new ByteArrayInputStream(decodedInventory))); 47 | } 48 | 49 | default ByteArrayTag getInventoryDataFromAttributes(CompoundTag tag) { 50 | for (String key : tag.getValue().keySet()) { 51 | if (key.endsWith("_backpack_data")) { 52 | return tag.get(key); 53 | } 54 | } 55 | return null; 56 | } 57 | 58 | default boolean isCompressed(final byte[] compressed) { 59 | return (compressed[0] == (byte) (GZIPInputStream.GZIP_MAGIC)) 60 | && (compressed[1] == (byte) (GZIPInputStream.GZIP_MAGIC >> 8)); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/inventory/Searchable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.inventory; 23 | 24 | public interface Searchable { 25 | 26 | boolean hasItem(String name); 27 | 28 | default boolean hasItems(String... names) { 29 | for (String name : names) { 30 | if (!hasItem(name)) { 31 | return false; 32 | } 33 | } 34 | return true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/rank/ItemRequirement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.rank; 23 | 24 | import java.util.List; 25 | 26 | public interface ItemRequirement { 27 | 28 | String getName(); 29 | 30 | List getAliases(); 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/rank/ObjectClosure.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.rank; 23 | 24 | import com.senither.hypixel.database.controller.GuildController; 25 | 26 | @FunctionalInterface 27 | public interface ObjectClosure { 28 | 29 | void run(GuildController.GuildEntry.RankRequirement requirement, T value); 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/rank/WeaponCondition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.rank; 23 | 24 | import com.senither.hypixel.inventory.Item; 25 | 26 | @FunctionalInterface 27 | public interface WeaponCondition { 28 | 29 | boolean matches(Item item); 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/scheduler/Job.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.scheduler; 23 | 24 | import com.senither.hypixel.SkyblockAssistant; 25 | 26 | import java.util.TimerTask; 27 | import java.util.concurrent.TimeUnit; 28 | 29 | public abstract class Job extends TimerTask { 30 | 31 | protected final SkyblockAssistant app; 32 | 33 | private final long delay; 34 | private final long period; 35 | private final TimeUnit unit; 36 | 37 | public Job(SkyblockAssistant app) { 38 | this(app, 0); 39 | } 40 | 41 | public Job(SkyblockAssistant app, long delay) { 42 | this(app, delay, 1); 43 | } 44 | 45 | public Job(SkyblockAssistant app, long delay, long period) { 46 | this(app, delay, period, TimeUnit.MINUTES); 47 | } 48 | 49 | public Job(SkyblockAssistant app, long delay, long period, TimeUnit unit) { 50 | this.app = app; 51 | 52 | this.delay = delay; 53 | this.period = period; 54 | this.unit = unit; 55 | } 56 | 57 | public long getDelay() { 58 | return delay; 59 | } 60 | 61 | public long getPeriod() { 62 | return period; 63 | } 64 | 65 | public TimeUnit getUnit() { 66 | return unit; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/servlet/SparkRoute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.servlet; 23 | 24 | import com.google.gson.JsonObject; 25 | import com.senither.hypixel.SkyblockAssistant; 26 | import spark.Request; 27 | import spark.Response; 28 | import spark.Route; 29 | 30 | public abstract class SparkRoute implements Route { 31 | 32 | protected final SkyblockAssistant app; 33 | 34 | public SparkRoute(SkyblockAssistant app) { 35 | this.app = app; 36 | } 37 | 38 | protected JsonObject buildResponse(Response response, int code, String message) { 39 | return buildResponse(response, code, message, null); 40 | } 41 | 42 | protected JsonObject buildResponse(Response response, int code, String message, JsonObject data) { 43 | response.status(code); 44 | 45 | JsonObject root = new JsonObject(); 46 | 47 | root.addProperty("status", code); 48 | root.addProperty(code >= 200 && code < 400 ? "message" : "reason", message); 49 | 50 | if (data != null) { 51 | root.add("data", data); 52 | } 53 | 54 | return root; 55 | } 56 | 57 | protected JsonObject buildDataResponse(Response response, int code, JsonObject object) { 58 | response.status(code); 59 | 60 | JsonObject root = new JsonObject(); 61 | 62 | root.addProperty("status", code); 63 | root.add("data", object); 64 | 65 | return root; 66 | } 67 | 68 | protected boolean isAuthorized(Request request) { 69 | String authorization = request.headers("Authorization"); 70 | 71 | return authorization != null 72 | && authorization.startsWith("Bearer ") 73 | && authorization.substring(7, authorization.length()).trim() 74 | .equals(app.getConfiguration().getServlet().getAccessToken()); 75 | 76 | } 77 | 78 | protected JsonObject generateUnauthornizedResponse(Response response) { 79 | return buildResponse(response, 401, "Unauthorized request, invalid or missing access token!"); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/statistics/CanCalculateWeight.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.contracts.statistics; 2 | 3 | import com.senither.hypixel.statistics.weight.Weight; 4 | 5 | public interface CanCalculateWeight extends HasLevel { 6 | 7 | Weight calculateWeight(); 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/statistics/Checker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.statistics; 23 | 24 | import com.google.gson.JsonObject; 25 | import net.hypixel.api.reply.PlayerReply; 26 | import net.hypixel.api.reply.skyblock.SkyBlockProfileReply; 27 | 28 | import javax.annotation.Nullable; 29 | 30 | public abstract class Checker { 31 | 32 | public abstract T checkUser(@Nullable PlayerReply playerReply, SkyBlockProfileReply profileReply, JsonObject member); 33 | 34 | protected double getDoubleFromObject(JsonObject object, String name) { 35 | try { 36 | return object.get(name).getAsDouble(); 37 | } catch (Exception e) { 38 | return 0D; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/statistics/DungeonWeightRelationFunction.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.contracts.statistics; 2 | 3 | import com.senither.hypixel.statistics.responses.DungeonResponse; 4 | 5 | @FunctionalInterface 6 | public interface DungeonWeightRelationFunction { 7 | 8 | CanCalculateWeight getWeight(DungeonResponse response); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/statistics/HasLevel.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.contracts.statistics; 2 | 3 | public interface HasLevel { 4 | 5 | /** 6 | * Gets the skill level calculated from the total XP. 7 | * 8 | * @return The calculated skill level. 9 | */ 10 | double getLevel(); 11 | 12 | /** 13 | * The total experience the user has in the skill. 14 | * 15 | * @return The total experience. 16 | */ 17 | double getExperience(); 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/statistics/Jsonable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.statistics; 23 | 24 | import com.google.gson.JsonObject; 25 | 26 | public interface Jsonable { 27 | 28 | JsonObject toJson(); 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/statistics/SkillWeightRelationFunction.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.contracts.statistics; 2 | 3 | import com.senither.hypixel.statistics.responses.SkillsResponse; 4 | 5 | @FunctionalInterface 6 | public interface SkillWeightRelationFunction { 7 | 8 | SkillsResponse.SkillStat getWeight(SkillsResponse response); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/statistics/SlayerFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.statistics; 23 | 24 | @FunctionalInterface 25 | public interface SlayerFunction { 26 | 27 | void setValue(int experience, int tier1Kills, int tier2Kills, int tier3Kills, int tier4Kills, int tier5Kills); 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/statistics/SlayerWeightRelationFunction.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.contracts.statistics; 2 | 3 | import com.senither.hypixel.statistics.responses.SlayerResponse; 4 | 5 | @FunctionalInterface 6 | public interface SlayerWeightRelationFunction { 7 | 8 | SlayerResponse.SlayerStat getWeight(SlayerResponse response); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/contracts/statistics/StatisticsResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.contracts.statistics; 23 | 24 | public abstract class StatisticsResponse { 25 | 26 | private final boolean apiEnable; 27 | 28 | public StatisticsResponse(boolean apiEnable) { 29 | this.apiEnable = apiEnable; 30 | } 31 | 32 | public boolean isApiEnable() { 33 | return apiEnable; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/MigrationManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.collection.Collection; 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | import java.sql.SQLException; 30 | import java.util.LinkedHashSet; 31 | 32 | public class MigrationManager { 33 | 34 | private static final Logger log = LoggerFactory.getLogger(MigrationManager.class); 35 | 36 | private final DatabaseManager databaseManager; 37 | private LinkedHashSet migrations; 38 | 39 | MigrationManager(DatabaseManager databaseManager) { 40 | this.databaseManager = databaseManager; 41 | this.migrations = new LinkedHashSet<>(); 42 | } 43 | 44 | public void register(Migration migration) { 45 | migrations.add(migration); 46 | } 47 | 48 | public void migrate() throws SQLException { 49 | createMigrationsTable(); 50 | 51 | Collection result = databaseManager.query("SELECT * FROM `migrations`"); 52 | for (Migration migration : migrations) { 53 | if (result.whereLoose("name", migration.getClass().getSimpleName()).isEmpty()) { 54 | log.info("Migrating \"{}\"", migration.getClass().getSimpleName()); 55 | 56 | try { 57 | migration.up(databaseManager); 58 | 59 | databaseManager.queryInsert("INSERT INTO `migrations` SET name = ?", migration.getClass().getSimpleName()); 60 | } catch (Exception e) { 61 | migration.down(databaseManager); 62 | 63 | log.error("{} migration failed with an exception, error: {}", 64 | migration.getClass().getSimpleName(), e.getMessage(), e 65 | ); 66 | } 67 | } 68 | } 69 | } 70 | 71 | private void createMigrationsTable() throws SQLException { 72 | databaseManager.queryUpdate( 73 | "CREATE TABLE IF NOT EXISTS `migrations`(\n" + 74 | " `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,\n" + 75 | " `name` VARCHAR(128) NOT NULL,\n" + 76 | " PRIMARY KEY(`id`)\n" + 77 | ") ENGINE = InnoDB;" 78 | ); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddAutoRenameColumnToGuildsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class AddAutoRenameColumnToGuildsTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate("ALTER TABLE `guilds` ADD `auto_rename` TINYINT NOT NULL DEFAULT '0' AFTER `default_role`;"); 34 | } 35 | 36 | @Override 37 | public boolean down(DatabaseManager databaseManager) throws SQLException { 38 | return databaseManager.queryUpdate( 39 | "ALTER TABLE `guilds` DROP `auto_rename`;" 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddBanLogRoleColumnToGuildsTableMigration.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.database.migrations; 2 | 3 | import com.senither.hypixel.contracts.database.Migration; 4 | import com.senither.hypixel.database.DatabaseManager; 5 | 6 | import java.sql.SQLException; 7 | 8 | public class AddBanLogRoleColumnToGuildsTableMigration implements Migration { 9 | 10 | @Override 11 | public boolean up(DatabaseManager databaseManager) throws SQLException { 12 | return databaseManager.queryUpdate( 13 | "ALTER TABLE `guilds`\n" + 14 | " ADD `ban_log_role` BIGINT UNSIGNED NULL AFTER `donation_notification_channel`;" 15 | ); 16 | } 17 | 18 | @Override 19 | public boolean down(DatabaseManager databaseManager) throws SQLException { 20 | return databaseManager.queryUpdate( 21 | "ALTER TABLE `guilds` DROP `ban_log_role`;" 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddDefaultRoleColumnToGuildsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class AddDefaultRoleColumnToGuildsTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "ALTER TABLE `guilds` ADD `default_role` BIGINT NULL DEFAULT NULL AFTER `data`;" 35 | ); 36 | } 37 | 38 | @Override 39 | public boolean down(DatabaseManager databaseManager) throws SQLException { 40 | return databaseManager.queryUpdate( 41 | "ALTER TABLE `guilds` DROP `default_role`;" 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddDonationNotificationChannelColumnToGuildsTableMigration.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.database.migrations; 2 | 3 | import com.senither.hypixel.contracts.database.Migration; 4 | import com.senither.hypixel.database.DatabaseManager; 5 | 6 | import java.sql.SQLException; 7 | 8 | public class AddDonationNotificationChannelColumnToGuildsTableMigration implements Migration { 9 | 10 | @Override 11 | public boolean up(DatabaseManager databaseManager) throws SQLException { 12 | return databaseManager.queryUpdate( 13 | "ALTER TABLE `guilds` ADD `donation_notification_channel` BIGINT NULL DEFAULT NULL AFTER `donation_channel`;" 14 | ); 15 | } 16 | 17 | @Override 18 | public boolean down(DatabaseManager databaseManager) throws SQLException { 19 | return databaseManager.queryUpdate( 20 | "ALTER TABLE `guilds` DROP `donation_notification_channel`;" 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddDonationsChannelColumnToGuildsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class AddDonationsChannelColumnToGuildsTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "ALTER TABLE `guilds`\n" + 35 | " ADD `donation_channel` BIGINT NULL AFTER `donation_role`;" 36 | ); 37 | } 38 | 39 | @Override 40 | public boolean down(DatabaseManager databaseManager) throws SQLException { 41 | return databaseManager.queryUpdate( 42 | "ALTER TABLE `guilds` DROP `donation_channel`;" 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddDonationsColumnsToGuildsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class AddDonationsColumnsToGuildsTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "ALTER TABLE `guilds`\n" + 35 | " ADD `donation_time` INT NULL DEFAULT NULL AFTER `auto_rename`,\n" + 36 | " ADD `donation_points` INT NULL DEFAULT NULL AFTER `donation_time`,\n" + 37 | " ADD `donation_role` BIGINT NULL DEFAULT NULL AFTER `donation_points`;" 38 | ); 39 | } 40 | 41 | @Override 42 | public boolean down(DatabaseManager databaseManager) throws SQLException { 43 | return databaseManager.queryUpdate( 44 | "ALTER TABLE `guilds` DROP `donation_time`, 'donation_points', `donation_role`;" 45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddGuildMemberRoleColumnToGuildsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class AddGuildMemberRoleColumnToGuildsTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "ALTER TABLE `guilds` ADD `guild_member_role` BIGINT NULL DEFAULT NULL AFTER `default_role`;" 35 | ); 36 | } 37 | 38 | @Override 39 | public boolean down(DatabaseManager databaseManager) throws SQLException { 40 | return databaseManager.queryUpdate( 41 | "ALTER TABLE `guilds` DROP `guild_member_role`;" 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddLastCheckedColumnToUuidsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class AddLastCheckedColumnToUuidsTableMigration implements Migration { 30 | @Override 31 | public boolean up(DatabaseManager databaseManager) throws SQLException { 32 | return databaseManager.queryUpdate( 33 | "ALTER TABLE `uuids` ADD `last_checked_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;" 34 | ); 35 | } 36 | 37 | @Override 38 | public boolean down(DatabaseManager databaseManager) throws SQLException { 39 | return databaseManager.queryUpdate( 40 | "ALTER TABLE `uuids` DROP `last_checked_at`;" 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddLastDonatedAtColumnToDonationsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class AddLastDonatedAtColumnToDonationsTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "ALTER TABLE `donation_points`\n" + 35 | " ADD `last_donated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `last_checked_at`;" 36 | ); 37 | } 38 | 39 | @Override 40 | public boolean down(DatabaseManager databaseManager) throws SQLException { 41 | return databaseManager.queryUpdate( 42 | "ALTER TABLE `donation_points` DROP `last_donated_at`;" 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddLastUpdatedAtColumnToProfileAndPlayerTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class AddLastUpdatedAtColumnToProfileAndPlayerTableMigration implements Migration { 30 | @Override 31 | public boolean up(DatabaseManager databaseManager) throws SQLException { 32 | databaseManager.queryUpdate( 33 | "ALTER TABLE `players` ADD `last_updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;" 34 | ); 35 | databaseManager.queryUpdate( 36 | "ALTER TABLE `profiles` ADD `last_updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;" 37 | ); 38 | return true; 39 | } 40 | 41 | @Override 42 | public boolean down(DatabaseManager databaseManager) throws SQLException { 43 | databaseManager.queryUpdate( 44 | "ALTER TABLE `players` DROP `last_updated_at`;" 45 | ); 46 | databaseManager.queryUpdate( 47 | "ALTER TABLE `profiles` DROP `last_updated_at`;" 48 | ); 49 | return true; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddRankRequirementsColumnToGuildsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class AddRankRequirementsColumnToGuildsTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "ALTER TABLE `guilds` ADD `rank_requirements` TEXT NULL AFTER `auto_rename`;" 35 | ); 36 | } 37 | 38 | @Override 39 | public boolean down(DatabaseManager databaseManager) throws SQLException { 40 | return databaseManager.queryUpdate( 41 | "ALTER TABLE `guilds` DROP `rank_requirements`;" 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddSplashManagementRoleColumnToGuildsTableMigration.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.database.migrations; 2 | 3 | import com.senither.hypixel.contracts.database.Migration; 4 | import com.senither.hypixel.database.DatabaseManager; 5 | 6 | import java.sql.SQLException; 7 | 8 | public class AddSplashManagementRoleColumnToGuildsTableMigration implements Migration { 9 | 10 | @Override 11 | public boolean up(DatabaseManager databaseManager) throws SQLException { 12 | return databaseManager.queryUpdate( 13 | "ALTER TABLE `guilds`\n" + 14 | " ADD `splash_management_role` BIGINT UNSIGNED NULL AFTER `splash_role`;" 15 | ); 16 | } 17 | 18 | @Override 19 | public boolean down(DatabaseManager databaseManager) throws SQLException { 20 | return databaseManager.queryUpdate( 21 | "ALTER TABLE `guilds` DROP `splash_management_role`;" 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddSplashPointsColumnToGuildsTableMigration.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.database.migrations; 2 | 3 | import com.senither.hypixel.contracts.database.Migration; 4 | import com.senither.hypixel.database.DatabaseManager; 5 | 6 | import java.sql.SQLException; 7 | 8 | public class AddSplashPointsColumnToGuildsTableMigration implements Migration { 9 | 10 | @Override 11 | public boolean up(DatabaseManager databaseManager) throws SQLException { 12 | return databaseManager.queryUpdate( 13 | "ALTER TABLE `guilds` ADD `splash_points` BOOLEAN NOT NULL DEFAULT FALSE AFTER `splash_role`;" 14 | ); 15 | } 16 | 17 | @Override 18 | public boolean down(DatabaseManager databaseManager) throws SQLException { 19 | return databaseManager.queryUpdate( 20 | "ALTER TABLE `guilds` DROP `splash_points`;" 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/AddSplashesColumnsToGuildsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class AddSplashesColumnsToGuildsTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "ALTER TABLE `guilds`\n" + 35 | " ADD `splash_channel` BIGINT UNSIGNED NULL AFTER `auto_rename`,\n" + 36 | " ADD `splash_role` BIGINT UNSIGNED NULL AFTER `splash_channel`;" 37 | ); 38 | } 39 | 40 | @Override 41 | public boolean down(DatabaseManager databaseManager) throws SQLException { 42 | return databaseManager.queryUpdate( 43 | "ALTER TABLE `guilds` DROP `splash_channel`, `splash_role`;" 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/CreateBanLogTableMigration.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.database.migrations; 2 | 3 | import com.senither.hypixel.contracts.database.Migration; 4 | import com.senither.hypixel.database.DatabaseManager; 5 | 6 | import java.sql.SQLException; 7 | 8 | public class CreateBanLogTableMigration implements Migration { 9 | 10 | @Override 11 | public boolean up(DatabaseManager databaseManager) throws SQLException { 12 | return databaseManager.queryUpdate( 13 | "CREATE TABLE `ban_log`(\n" + 14 | " `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n" + 15 | " `discord_id` BIGINT UNSIGNED NOT NULL,\n" + 16 | " `added_by` VARCHAR(64) NOT NULL,\n" + 17 | " `uuid` VARCHAR(64) NOT NULL,\n" + 18 | " `reason` TEXT NULL,\n" + 19 | " `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n" + 20 | " PRIMARY KEY (`id`),\n" + 21 | " INDEX(`discord_id`),\n" + 22 | " INDEX(`uuid`)\n" + 23 | ") ENGINE = INNODB;" 24 | ); 25 | } 26 | 27 | @Override 28 | public boolean down(DatabaseManager databaseManager) throws SQLException { 29 | return databaseManager.queryUpdate("DROP TABLE `ban_log`"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/CreateBlacklistTableMigration.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.database.migrations; 2 | 3 | import com.senither.hypixel.contracts.database.Migration; 4 | import com.senither.hypixel.database.DatabaseManager; 5 | 6 | import java.sql.SQLException; 7 | 8 | public class CreateBlacklistTableMigration implements Migration { 9 | 10 | @Override 11 | public boolean up(DatabaseManager databaseManager) throws SQLException { 12 | return databaseManager.queryUpdate( 13 | "CREATE TABLE `blacklists`(\n" + 14 | " `id` BIGINT UNSIGNED NOT NULL,\n" + 15 | " `expires_in` DATETIME NULL,\n" + 16 | " `reason` VARCHAR(256) NOT NULL,\n" + 17 | " INDEX(`id`)\n" + 18 | ") ENGINE = INNODB;" 19 | ); 20 | } 21 | 22 | @Override 23 | public boolean down(DatabaseManager databaseManager) throws SQLException { 24 | return databaseManager.queryUpdate("DROP TABLE `blacklists`"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/CreateBoopOptTableMigration.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.database.migrations; 2 | 3 | import com.senither.hypixel.contracts.database.Migration; 4 | import com.senither.hypixel.database.DatabaseManager; 5 | 6 | import java.sql.SQLException; 7 | 8 | public class CreateBoopOptTableMigration implements Migration { 9 | 10 | @Override 11 | public boolean up(DatabaseManager databaseManager) throws SQLException { 12 | return databaseManager.queryUpdate( 13 | "CREATE TABLE `boop_opt`(\n" + 14 | " `discord_id` BIGINT UNSIGNED NOT NULL,\n" + 15 | " `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n" + 16 | " UNIQUE(`discord_id`)\n" + 17 | ") ENGINE = INNODB;" 18 | ); 19 | } 20 | 21 | @Override 22 | public boolean down(DatabaseManager databaseManager) throws SQLException { 23 | return databaseManager.queryUpdate("DROP TABLE `boop_opt`"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/CreateDonationPointsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class CreateDonationPointsTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "CREATE TABLE `donation_points`(\n" + 35 | " `uuid` VARCHAR(64) NOT NULL,\n" + 36 | " `discord_id` BIGINT UNSIGNED NOT NULL,\n" + 37 | " `points` BIGINT NOT NULL DEFAULT '0',\n" + 38 | " `last_checked_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n" + 39 | " PRIMARY KEY (`uuid`, `discord_id`)\n" + 40 | ") ENGINE = InnoDB;" 41 | ); 42 | } 43 | 44 | @Override 45 | public boolean down(DatabaseManager databaseManager) throws SQLException { 46 | return databaseManager.queryUpdate("DROP TABLE `donation_points`"); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/CreateGuildsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class CreateGuildsTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "CREATE TABLE `guilds`(\n" + 35 | " `id` VARCHAR(64) NOT NULL,\n" + 36 | " `discord_id` BIGINT UNSIGNED NOT NULL,\n" + 37 | " `name` VARCHAR(64) NOT NULL,\n" + 38 | " `data` MEDIUMTEXT NOT NULL,\n" + 39 | " `last_updated_at` DATETIME NULL DEFAULT NULL,\n" + 40 | " UNIQUE(`discord_id`),\n" + 41 | " UNIQUE(`id`)\n" + 42 | ") ENGINE = InnoDB;" 43 | ); 44 | } 45 | 46 | @Override 47 | public boolean down(DatabaseManager databaseManager) throws SQLException { 48 | return databaseManager.queryUpdate("DROP TABLE `guilds`"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/CreateMessagesTableMigration.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.database.migrations; 2 | 3 | import com.senither.hypixel.contracts.database.Migration; 4 | import com.senither.hypixel.database.DatabaseManager; 5 | 6 | import java.sql.SQLException; 7 | 8 | public class CreateMessagesTableMigration implements Migration { 9 | 10 | @Override 11 | public boolean up(DatabaseManager databaseManager) throws SQLException { 12 | return databaseManager.queryUpdate( 13 | "CREATE TABLE `messages`(\n" + 14 | " `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n" + 15 | " `discord_id` BIGINT UNSIGNED NOT NULL,\n" + 16 | " `channel_id` BIGINT UNSIGNED NOT NULL,\n" + 17 | " `message_id` BIGINT UNSIGNED NOT NULL,\n" + 18 | " `content` MEDIUMTEXT NOT NULL,\n" + 19 | " `variables` MEDIUMTEXT NULL DEFAULT NULL,\n" + 20 | " `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n" + 21 | " `updated_at` DATETIME ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n" + 22 | " PRIMARY KEY(`id`)\n" + 23 | ") ENGINE = INNODB;" 24 | ); 25 | } 26 | 27 | @Override 28 | public boolean down(DatabaseManager databaseManager) throws SQLException { 29 | return databaseManager.queryUpdate("DROP TABLE `messages`"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/CreatePlayersTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class CreatePlayersTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "CREATE TABLE `players`(\n" + 35 | " `uuid` VARCHAR(64) NOT NULL,\n" + 36 | " `data` MEDIUMTEXT NOT NULL,\n" + 37 | " `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n" + 38 | " UNIQUE(`uuid`)\n" + 39 | ") ENGINE = InnoDB;" 40 | ); 41 | } 42 | 43 | @Override 44 | public boolean down(DatabaseManager databaseManager) throws SQLException { 45 | return databaseManager.queryUpdate("DROP TABLE `players`"); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/CreateProfilesTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class CreateProfilesTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "CREATE TABLE `profiles`(\n" + 35 | " `uuid` VARCHAR(64) NOT NULL,\n" + 36 | " `data` MEDIUMTEXT NOT NULL,\n" + 37 | " `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n" + 38 | " UNIQUE(`uuid`)\n" + 39 | ") ENGINE = InnoDB;" 40 | ); 41 | } 42 | 43 | @Override 44 | public boolean down(DatabaseManager databaseManager) throws SQLException { 45 | return databaseManager.queryUpdate("DROP TABLE `profiles`"); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/CreateReportsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class CreateReportsTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "CREATE TABLE `reports`(\n" + 35 | " `id` VARCHAR(64) NOT NULL,\n" + 36 | " `discord_id` BIGINT UNSIGNED NOT NULL,\n" + 37 | " `data` MEDIUMTEXT NULL,\n" + 38 | " `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n" + 39 | " `finished_at` DATETIME NULL DEFAULT NULL,\n" + 40 | " UNIQUE(`id`)\n" + 41 | ") ENGINE = InnoDB;" 42 | ); 43 | } 44 | 45 | @Override 46 | public boolean down(DatabaseManager databaseManager) throws SQLException { 47 | return databaseManager.queryUpdate("DROP TABLE `reports`"); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/CreateSplashesTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class CreateSplashesTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "CREATE TABLE `splashes`(\n" + 35 | " `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n" + 36 | " `discord_id` BIGINT UNSIGNED NOT NULL,\n" + 37 | " `uuid` VARCHAR(64) NOT NULL ,\n" + 38 | " `message_id` BIGINT UNSIGNED NULL DEFAULT NULL,\n" + 39 | " `note` TEXT NULL DEFAULT NULL,\n" + 40 | " `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n" + 41 | " `splash_at` TIMESTAMP NULL,\n" + 42 | " PRIMARY KEY(`id`),\n" + 43 | " INDEX (`uuid`)\n" + 44 | ") ENGINE = InnoDB;" 45 | ); 46 | } 47 | 48 | @Override 49 | public boolean down(DatabaseManager databaseManager) throws SQLException { 50 | return databaseManager.queryUpdate("DROP TABLE `splashes`"); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/database/migrations/CreateUUIDsTableMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.database.migrations; 23 | 24 | import com.senither.hypixel.contracts.database.Migration; 25 | import com.senither.hypixel.database.DatabaseManager; 26 | 27 | import java.sql.SQLException; 28 | 29 | public class CreateUUIDsTableMigration implements Migration { 30 | 31 | @Override 32 | public boolean up(DatabaseManager databaseManager) throws SQLException { 33 | return databaseManager.queryUpdate( 34 | "CREATE TABLE `uuids`(\n" + 35 | " `uuid` VARCHAR(64) NOT NULL,\n" + 36 | " `username` VARCHAR(32) NOT NULL,\n" + 37 | " `discord_id` BIGINT UNSIGNED NULL,\n" + 38 | " UNIQUE(`uuid`)\n" + 39 | ") ENGINE = InnoDB;" 40 | ); 41 | } 42 | 43 | @Override 44 | public boolean down(DatabaseManager databaseManager) throws SQLException { 45 | return databaseManager.queryUpdate("DROP TABLE `uuids`"); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/exceptions/CommandAlreadyRegisteredException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.exceptions; 23 | 24 | import com.senither.hypixel.contracts.commands.Command; 25 | 26 | public class CommandAlreadyRegisteredException extends RuntimeException { 27 | 28 | public CommandAlreadyRegisteredException(Command command, String trigger) { 29 | super(String.format("The %s command failed to be registered, the \"%s\" trigger already exists", 30 | command.getClass().getSimpleName(), trigger 31 | )); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/exceptions/FriendlyException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.exceptions; 23 | 24 | public class FriendlyException extends RuntimeException { 25 | 26 | public FriendlyException(String message) { 27 | super(message); 28 | } 29 | 30 | @SuppressWarnings("RedundantCast") 31 | public FriendlyException(String message, String... args) { 32 | super(String.format(message, (Object[]) args)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/exceptions/InvalidFormatException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.exceptions; 23 | 24 | public class InvalidFormatException extends RuntimeException { 25 | 26 | public InvalidFormatException(String message, String time) { 27 | super(String.format(message, time)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/exceptions/InvalidRequestURIException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.exceptions; 23 | 24 | public class InvalidRequestURIException extends RuntimeException { 25 | 26 | public InvalidRequestURIException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/exceptions/NoRankRequirementException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.exceptions; 23 | 24 | import com.senither.hypixel.rank.RankCheckResponse; 25 | 26 | public class NoRankRequirementException extends FriendlyException { 27 | 28 | private RankCheckResponse rankResponse; 29 | 30 | public NoRankRequirementException(String type) { 31 | super(String.format("No rank requirements are setup for %s", type)); 32 | } 33 | 34 | public void setRankResponse(RankCheckResponse rankResponse) { 35 | this.rankResponse = rankResponse; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/hypixel/ClientContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.hypixel; 23 | 24 | import com.senither.hypixel.SkyblockAssistant; 25 | import net.hypixel.api.HypixelAPI; 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | import java.util.HashSet; 30 | import java.util.UUID; 31 | 32 | public class ClientContainer { 33 | 34 | private static final Logger log = LoggerFactory.getLogger(ClientContainer.class); 35 | 36 | private final HypixelAPI[] clients; 37 | private int index = 0; 38 | 39 | ClientContainer(SkyblockAssistant app) { 40 | if (app.getConfiguration().getHypixelTokens() == null) { 41 | clients = new HypixelAPI[]{new HypixelAPI(UUID.fromString(app.getConfiguration().getHypixelToken()))}; 42 | } else { 43 | HashSet tokens = new HashSet<>(); 44 | for (String token : app.getConfiguration().getHypixelTokens()) { 45 | try { 46 | tokens.add(UUID.fromString(token)); 47 | } catch (Exception e) { 48 | log.warn("The \"{}\" API token is not a valid UUID, the key was skipped!", token); 49 | } 50 | } 51 | 52 | HypixelAPI[] clients = new HypixelAPI[tokens.size()]; 53 | for (UUID token : tokens) { 54 | clients[index++] = new HypixelAPI(token); 55 | } 56 | this.clients = clients; 57 | } 58 | } 59 | 60 | public HypixelAPI[] getClients() { 61 | return clients; 62 | } 63 | 64 | public HypixelAPI getNextClient() { 65 | if (index >= clients.length) { 66 | index = 0; 67 | } 68 | return clients[index++]; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/hypixel/HypixelRank.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.hypixel; 23 | 24 | public enum HypixelRank { 25 | 26 | SUPERSTAR("MVP++"), 27 | MVP_PLUS("MVP+"), 28 | MVP("MVP"), 29 | VIP_PLUS("VIP+"), 30 | VIP("VIP"), 31 | DEFAULT(null); 32 | 33 | private final String name; 34 | 35 | HypixelRank(String name) { 36 | this.name = name; 37 | } 38 | 39 | public static HypixelRank getFromType(String type) { 40 | for (HypixelRank rank : values()) { 41 | if (rank.name().equalsIgnoreCase(type)) { 42 | return rank; 43 | } 44 | } 45 | return DEFAULT; 46 | } 47 | 48 | public static HypixelRank getDefaultRank() { 49 | return DEFAULT; 50 | } 51 | 52 | public String getName() { 53 | return name; 54 | } 55 | 56 | public boolean isDefault() { 57 | return this == getDefaultRank(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/hypixel/MojangPlayerUUID.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.hypixel; 23 | 24 | import java.util.UUID; 25 | 26 | public class MojangPlayerUUID { 27 | 28 | private UUID id; 29 | 30 | public UUID getUUID() { 31 | return id; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/hypixel/SkyBlockSkill.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.hypixel; 2 | 3 | public enum SkyBlockSkill { 4 | 5 | MINING(60), 6 | FORAGING(50), 7 | ENCHANTING(60), 8 | FARMING(60), 9 | COMBAT(60), 10 | FISHING(50), 11 | ALCHEMY(50), 12 | TAMING(50), 13 | CARPENTRY(50), 14 | RUNECRAFTING(25, 94300); 15 | 16 | private final int maxLevel; 17 | private final int maxLevelExp; 18 | 19 | SkyBlockSkill(int maxLevel) { 20 | this(maxLevel, maxLevel == 50 ? 55172425 : 111672425); 21 | } 22 | 23 | SkyBlockSkill(int maxLevel, int maxLevelExp) { 24 | this.maxLevel = maxLevel; 25 | this.maxLevelExp = maxLevelExp; 26 | } 27 | 28 | public int getMaxLevel() { 29 | return maxLevel; 30 | } 31 | 32 | public int getMaxLevelExp() { 33 | return maxLevelExp; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/hypixel/bazaar/BazaarProductReply.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.hypixel.bazaar; 2 | 3 | import net.hypixel.api.reply.AbstractReply; 4 | 5 | import java.util.HashMap; 6 | 7 | public class BazaarProductReply extends AbstractReply { 8 | 9 | private static final Product defaultProduct = new Product(); 10 | 11 | static { 12 | defaultProduct.product_id = "UNKNOWN"; 13 | defaultProduct.quick_status = new QuickStatus(); 14 | defaultProduct.quick_status.productId = "UNKNOWN"; 15 | 16 | defaultProduct.quick_status.sellPrice = 0D; 17 | defaultProduct.quick_status.sellVolume = 0D; 18 | defaultProduct.quick_status.sellMovingWeek = 0D; 19 | defaultProduct.quick_status.sellOrders = 0D; 20 | defaultProduct.quick_status.buyPrice = 0D; 21 | defaultProduct.quick_status.buyVolume = 0D; 22 | defaultProduct.quick_status.buyMovingWeek = 0D; 23 | defaultProduct.quick_status.buyOrders = 0D; 24 | } 25 | 26 | private long lastUpdated; 27 | private HashMap products; 28 | 29 | public long getLastUpdated() { 30 | return lastUpdated; 31 | } 32 | 33 | public HashMap getProducts() { 34 | return products; 35 | } 36 | 37 | public Product getProduct(BazaarProduct product) { 38 | return getProducts().getOrDefault(product.getKey(), defaultProduct); 39 | } 40 | 41 | public static class Product { 42 | 43 | private String product_id; 44 | private QuickStatus quick_status; 45 | 46 | public String getProductId() { 47 | return product_id; 48 | } 49 | 50 | public QuickStatus getQuickStatus() { 51 | return quick_status; 52 | } 53 | } 54 | 55 | public static class QuickStatus { 56 | 57 | private String productId; 58 | private double sellPrice; 59 | private double sellVolume; 60 | private double sellMovingWeek; 61 | private double sellOrders; 62 | private double buyPrice; 63 | private double buyVolume; 64 | private double buyMovingWeek; 65 | private double buyOrders; 66 | 67 | public String getProductId() { 68 | return productId; 69 | } 70 | 71 | public double getSellPrice() { 72 | return sellPrice; 73 | } 74 | 75 | public double getSellVolume() { 76 | return sellVolume; 77 | } 78 | 79 | public double getSellMovingWeek() { 80 | return sellMovingWeek; 81 | } 82 | 83 | public double getSellOrders() { 84 | return sellOrders; 85 | } 86 | 87 | public double getBuyPrice() { 88 | return buyPrice; 89 | } 90 | 91 | public double getBuyVolume() { 92 | return buyVolume; 93 | } 94 | 95 | public double getBuyMovingWeek() { 96 | return buyMovingWeek; 97 | } 98 | 99 | public double getBuyOrders() { 100 | return buyOrders; 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/hypixel/response/AuctionHouseResponse.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.hypixel.response; 2 | 3 | import com.senither.hypixel.inventory.ItemRarity; 4 | 5 | import java.util.List; 6 | 7 | public class AuctionHouseResponse { 8 | 9 | private boolean success; 10 | protected List auctions; 11 | 12 | public boolean isSuccess() { 13 | return success; 14 | } 15 | 16 | public List getAuctions() { 17 | return auctions; 18 | } 19 | 20 | public class Auction { 21 | 22 | private String uuid; 23 | private String auctioneer; 24 | private String profile_id; 25 | private String item_name; 26 | private String item_lore; 27 | private String tier; 28 | private List bids; 29 | private long starting_bid; 30 | private long highest_bid_amount; 31 | private long start; 32 | private long end; 33 | private boolean claimed; 34 | 35 | public String getUuid() { 36 | return uuid; 37 | } 38 | 39 | public String getAuctioneer() { 40 | return auctioneer; 41 | } 42 | 43 | public String getProfileId() { 44 | return profile_id; 45 | } 46 | 47 | public String getItemName() { 48 | return item_name; 49 | } 50 | 51 | public String getItemLore() { 52 | return item_lore; 53 | } 54 | 55 | public ItemRarity getTier() { 56 | return ItemRarity.fromName(tier); 57 | } 58 | 59 | public List getBids() { 60 | return bids; 61 | } 62 | 63 | public long getStartingBid() { 64 | return starting_bid; 65 | } 66 | 67 | public long getHighestBidAmount() { 68 | return highest_bid_amount; 69 | } 70 | 71 | public long getStart() { 72 | return start; 73 | } 74 | 75 | public long getEnd() { 76 | return end; 77 | } 78 | 79 | public boolean isClaimed() { 80 | return claimed; 81 | } 82 | 83 | public class Bid { 84 | 85 | private String auction_id; 86 | private String bidder; 87 | private long amount; 88 | private long timestamp; 89 | 90 | public String getAuctionId() { 91 | return auction_id; 92 | } 93 | 94 | public String getBidder() { 95 | return bidder; 96 | } 97 | 98 | public long getAmount() { 99 | return amount; 100 | } 101 | 102 | public long getTimestamp() { 103 | return timestamp; 104 | } 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/hypixel/response/GuildMetricsResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.hypixel.response; 23 | 24 | import com.senither.hypixel.contracts.hypixel.Response; 25 | import com.senither.hypixel.time.Carbon; 26 | 27 | import java.util.List; 28 | 29 | public class GuildMetricsResponse extends Response { 30 | 31 | protected List data; 32 | 33 | public List getData() { 34 | return data; 35 | } 36 | 37 | public class GuildMetrics { 38 | 39 | protected double average_skill; 40 | protected double average_skill_progress; 41 | protected double average_slayer; 42 | protected double average_catacomb; 43 | protected int members; 44 | private GuildWeight weight; 45 | private String created_at; 46 | 47 | public double getAverageSkill() { 48 | return average_skill; 49 | } 50 | 51 | public double getAverageSkillProgress() { 52 | return average_skill_progress; 53 | } 54 | 55 | public double getAverageSlayer() { 56 | return average_slayer; 57 | } 58 | 59 | public double getAverageCatacomb() { 60 | return average_catacomb; 61 | } 62 | 63 | public int getMembers() { 64 | return members; 65 | } 66 | 67 | public GuildWeight getWeight() { 68 | return weight; 69 | } 70 | 71 | public Carbon getCreatedAt() { 72 | return timestampToCarbonInstance(created_at); 73 | } 74 | 75 | public class GuildWeight { 76 | 77 | protected double total; 78 | protected double skill; 79 | protected double slayer; 80 | protected double multiplier; 81 | 82 | public double getTotal() { 83 | return total; 84 | } 85 | 86 | public double getSkill() { 87 | return skill; 88 | } 89 | 90 | public double getSlayer() { 91 | return slayer; 92 | } 93 | 94 | public double getMultiplier() { 95 | return multiplier; 96 | } 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/hypixel/response/LeaderboardStatsResponse.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.hypixel.response; 2 | 3 | import com.senither.hypixel.contracts.hypixel.Response; 4 | 5 | public class LeaderboardStatsResponse extends Response { 6 | 7 | protected Stats data; 8 | 9 | public Stats getData() { 10 | return data; 11 | } 12 | 13 | public class Stats { 14 | 15 | protected int guilds; 16 | protected int players; 17 | 18 | public int getGuilds() { 19 | return guilds; 20 | } 21 | 22 | public int getPlayers() { 23 | return players; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/hypixel/response/PlayerLeaderboardResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.hypixel.response; 23 | 24 | import com.senither.hypixel.contracts.hypixel.Response; 25 | import com.senither.hypixel.hypixel.leaderboard.LeaderboardPlayer; 26 | 27 | import java.util.List; 28 | 29 | @SuppressWarnings("WeakerAccess") 30 | public class PlayerLeaderboardResponse extends Response { 31 | 32 | protected List data; 33 | 34 | public List getData() { 35 | return data; 36 | } 37 | 38 | public class Player extends LeaderboardPlayer { 39 | // 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/inventory/ItemRarity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.inventory; 23 | 24 | import java.util.Arrays; 25 | import java.util.HashSet; 26 | 27 | public enum ItemRarity { 28 | 29 | SPECIAL("Special", "spec", "s"), 30 | MYTHIC("Mythic", "myth", "m"), 31 | LEGENDARY("Legendary", "legend", "leg", "l"), 32 | EPIC("Epic", "e"), 33 | RARE("Rare", "r"), 34 | UNCOMMON("Uncommon", "uncom", "u"), 35 | COMMON("Common", "com", "c"), 36 | UNKNOWN(true, "Unknown"); 37 | 38 | private final boolean isDefault; 39 | private final String name; 40 | private final HashSet aliases; 41 | 42 | ItemRarity(String name, String... aliases) { 43 | this(false, name, aliases); 44 | } 45 | 46 | ItemRarity(boolean isDefault, String name, String... aliases) { 47 | this.isDefault = isDefault; 48 | this.name = name; 49 | 50 | this.aliases = new HashSet<>(Arrays.asList(aliases)); 51 | this.aliases.add(name); 52 | } 53 | 54 | public static ItemRarity fromName(String name) { 55 | if (name == null) { 56 | return UNKNOWN; 57 | } 58 | 59 | for (ItemRarity rarity : values()) { 60 | if (rarity.name().equalsIgnoreCase(name)) { 61 | return rarity; 62 | } 63 | } 64 | return UNKNOWN; 65 | } 66 | 67 | public static ItemRarity fromAlias(String name) { 68 | if (name == null) { 69 | return UNKNOWN; 70 | } 71 | 72 | for (ItemRarity rarity : values()) { 73 | for (String alias : rarity.getAliases()) { 74 | if (alias.equalsIgnoreCase(name)) { 75 | return rarity; 76 | } 77 | } 78 | } 79 | return UNKNOWN; 80 | } 81 | 82 | public boolean isDefault() { 83 | return isDefault; 84 | } 85 | 86 | public String getName() { 87 | return name; 88 | } 89 | 90 | public HashSet getAliases() { 91 | return aliases; 92 | } 93 | 94 | public ItemRarity nextRarity() { 95 | for (int i = 0; i < values().length; i++) { 96 | if (values()[i] != this) { 97 | continue; 98 | } 99 | return i == 0 ? SPECIAL : values()[i - 1]; 100 | } 101 | return UNKNOWN; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/inventory/ItemType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.inventory; 23 | 24 | import java.util.Arrays; 25 | import java.util.List; 26 | 27 | public enum ItemType { 28 | 29 | WEAPON("sword", "bow"), 30 | TOOL("pickaxe", "axe", "shovel", "shears", "hoe", "wand"), 31 | ARMOR("helmet", "chestplate", "leggings", "boots"), 32 | ACCESSORY("accessory", "hatccessory"), 33 | UNKNOWN(); 34 | 35 | private final List types; 36 | 37 | ItemType(String... names) { 38 | types = Arrays.asList(names); 39 | } 40 | 41 | public static ItemType fromName(String name) { 42 | if (name == null) { 43 | return UNKNOWN; 44 | } 45 | 46 | for (ItemType type : values()) { 47 | if (type.getTypes().contains(name.toLowerCase())) { 48 | return type; 49 | } 50 | } 51 | return UNKNOWN; 52 | } 53 | 54 | public List getTypes() { 55 | return types; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/listeners/GenericEventListener.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.listeners; 2 | 3 | import com.senither.hypixel.metrics.Metrics; 4 | import net.dv8tion.jda.api.events.GenericEvent; 5 | import net.dv8tion.jda.api.hooks.ListenerAdapter; 6 | 7 | import javax.annotation.Nonnull; 8 | 9 | public class GenericEventListener extends ListenerAdapter { 10 | 11 | @Override 12 | public void onGenericEvent(@Nonnull GenericEvent event) { 13 | Metrics.jdaEvents.labels(event.getClass().getSimpleName()).inc(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/listeners/MemberActivityEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.listeners; 23 | 24 | import com.senither.hypixel.SkyblockAssistant; 25 | import com.senither.hypixel.database.controller.GuildController; 26 | import net.dv8tion.jda.api.entities.Role; 27 | import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent; 28 | import net.dv8tion.jda.api.hooks.ListenerAdapter; 29 | 30 | import javax.annotation.Nonnull; 31 | 32 | public class MemberActivityEventListener extends ListenerAdapter { 33 | 34 | private final SkyblockAssistant app; 35 | 36 | public MemberActivityEventListener(SkyblockAssistant app) { 37 | this.app = app; 38 | } 39 | 40 | @Override 41 | public void onGuildMemberJoin(@Nonnull GuildMemberJoinEvent event) { 42 | GuildController.GuildEntry guildEntry = GuildController.getGuildById(app.getDatabaseManager(), event.getGuild().getIdLong()); 43 | if (guildEntry == null || guildEntry.getDefaultRole() == null) { 44 | return; 45 | } 46 | 47 | Role role = event.getGuild().getRoleById(guildEntry.getDefaultRole()); 48 | if (role == null) { 49 | return; 50 | } 51 | 52 | event.getGuild().addRoleToMember(event.getMember(), role).queue(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/listeners/ReactionEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.listeners; 23 | 24 | import com.senither.hypixel.commands.administration.DonationCommand; 25 | import com.senither.hypixel.contracts.commands.DonationAdditionFunction; 26 | import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent; 27 | import net.dv8tion.jda.api.hooks.ListenerAdapter; 28 | 29 | import javax.annotation.Nonnull; 30 | import java.util.Objects; 31 | 32 | public class ReactionEventListener extends ListenerAdapter { 33 | 34 | @Override 35 | public void onMessageReactionAdd(@Nonnull MessageReactionAddEvent event) { 36 | if (isCheckmarkEmote(event) && DonationCommand.confirmationQueue.containsKey(event.getMessageIdLong())) { 37 | DonationAdditionFunction donationAdditionFunction = DonationCommand.confirmationQueue.get(event.getMessageIdLong()); 38 | 39 | if (event.getUserIdLong() == donationAdditionFunction.getAuthorId()) { 40 | donationAdditionFunction.handle(); 41 | 42 | DonationCommand.confirmationQueue.remove(event.getMessageIdLong()); 43 | event.getTextChannel().deleteMessageById(event.getMessageIdLong()).queue(); 44 | } 45 | } 46 | } 47 | 48 | private boolean isCheckmarkEmote(MessageReactionAddEvent event) { 49 | try { 50 | return Objects.equals(event.getReactionEmote().getEmoji(), "✅"); 51 | } catch (IllegalStateException ignored) { 52 | return false; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/metrics/PrometheusMetricsServlet.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.metrics; 2 | 3 | import io.prometheus.client.exporter.MetricsServlet; 4 | 5 | import javax.servlet.ServletException; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | public class PrometheusMetricsServlet extends MetricsServlet { 11 | 12 | public HttpServletResponse servletGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 13 | doGet(req, resp); 14 | return resp; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/rank/RankCheckResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.rank; 23 | 24 | import net.hypixel.api.reply.GuildReply; 25 | 26 | import java.util.HashMap; 27 | 28 | public class RankCheckResponse { 29 | 30 | private final GuildReply.Guild.Rank rank; 31 | private final HashMap metric; 32 | 33 | public RankCheckResponse(GuildReply.Guild.Rank rank, HashMap metric) { 34 | this.rank = rank; 35 | this.metric = metric; 36 | } 37 | 38 | public GuildReply.Guild.Rank getRank() { 39 | return rank; 40 | } 41 | 42 | public HashMap getMetric() { 43 | return metric; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/rank/handler/CustomObjectValueHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.rank.handler; 23 | 24 | import com.senither.hypixel.SkyblockAssistant; 25 | import com.senither.hypixel.chat.MessageFactory; 26 | import com.senither.hypixel.contracts.rank.ObjectClosure; 27 | import com.senither.hypixel.contracts.rank.RankCommandHandler; 28 | import com.senither.hypixel.database.controller.GuildController; 29 | import com.senither.hypixel.exceptions.FriendlyException; 30 | import net.dv8tion.jda.api.events.message.MessageReceivedEvent; 31 | import net.hypixel.api.reply.GuildReply; 32 | 33 | import java.util.function.Function; 34 | 35 | public class CustomObjectValueHandler extends RankCommandHandler { 36 | 37 | private final Function getter; 38 | private final ObjectClosure closure; 39 | 40 | public CustomObjectValueHandler(Function getter, ObjectClosure closure) { 41 | this.getter = getter; 42 | this.closure = closure; 43 | } 44 | 45 | @Override 46 | public void handle( 47 | SkyblockAssistant app, 48 | MessageReceivedEvent event, 49 | GuildReply guildReply, 50 | GuildController.GuildEntry guildEntry, 51 | GuildReply.Guild.Rank rank, 52 | String[] args 53 | ) { 54 | if (args.length == 0) { 55 | throw new FriendlyException(String.format( 56 | "Missing argument for %s requirement", 57 | rankType.getName() 58 | )); 59 | } 60 | 61 | T response = getter.apply(args[0]); 62 | closure.run(getRequirementsForRank(guildEntry, rank), response); 63 | 64 | updateGuildEntry(app, event, guildReply, guildEntry); 65 | 66 | MessageFactory.makeSuccess(event.getMessage(), 67 | "The new :type requirement for **:rank** have successfully been set to **:value**." 68 | ) 69 | .set("type", rankType.getName()) 70 | .set("rank", rank.getName()) 71 | .set("value", response == null ? "nothing" : response) 72 | .queue(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/rank/handler/IntegerValueHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.rank.handler; 23 | 24 | import com.senither.hypixel.SkyblockAssistant; 25 | import com.senither.hypixel.chat.MessageFactory; 26 | import com.senither.hypixel.contracts.rank.ObjectClosure; 27 | import com.senither.hypixel.contracts.rank.RankCommandHandler; 28 | import com.senither.hypixel.database.controller.GuildController; 29 | import com.senither.hypixel.exceptions.FriendlyException; 30 | import com.senither.hypixel.utils.NumberUtil; 31 | import net.dv8tion.jda.api.events.message.MessageReceivedEvent; 32 | import net.hypixel.api.reply.GuildReply; 33 | 34 | public class IntegerValueHandler extends RankCommandHandler { 35 | 36 | private final ObjectClosure closure; 37 | 38 | public IntegerValueHandler(ObjectClosure closure) { 39 | this.closure = closure; 40 | } 41 | 42 | public void handle( 43 | SkyblockAssistant app, 44 | MessageReceivedEvent event, 45 | GuildReply guildReply, 46 | GuildController.GuildEntry guildEntry, 47 | GuildReply.Guild.Rank rank, 48 | String[] args 49 | ) { 50 | if (args.length == 0 || !NumberUtil.isNumeric(args[0])) { 51 | throw new FriendlyException(String.format( 52 | "The %s value must be a number!", 53 | rankType.getName() 54 | )); 55 | } 56 | 57 | int value = NumberUtil.parseInt(args[0], Integer.MAX_VALUE); 58 | 59 | closure.run(getRequirementsForRank(guildEntry, rank), value); 60 | updateGuildEntry(app, event, guildReply, guildEntry); 61 | 62 | MessageFactory.makeSuccess(event.getMessage(), "The new :type requirement for **:rank** have successfully been set to **:value**") 63 | .set("type", rankType.getName()) 64 | .set("rank", rank.getName()) 65 | .set("value", value) 66 | .queue(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/rank/items/ArmorSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.rank.items; 23 | 24 | public class ArmorSet { 25 | 26 | private final String name; 27 | 28 | private final String helmet; 29 | private final String chestplate; 30 | private final String leggings; 31 | private final String boots; 32 | 33 | private final int setPieces; 34 | 35 | ArmorSet(String name, String helmet, String chestplate, String leggings, String boots) { 36 | this.name = name; 37 | 38 | this.helmet = helmet; 39 | this.chestplate = chestplate; 40 | this.leggings = leggings; 41 | this.boots = boots; 42 | 43 | int pieces = helmet == null ? 0 : 1; 44 | pieces += chestplate == null ? 0 : 1; 45 | pieces += leggings == null ? 0 : 1; 46 | pieces += boots == null ? 0 : 1; 47 | 48 | this.setPieces = pieces; 49 | } 50 | 51 | public String getName() { 52 | return name; 53 | } 54 | 55 | public String getHelmet() { 56 | return helmet; 57 | } 58 | 59 | public String getChestplate() { 60 | return chestplate; 61 | } 62 | 63 | public String getLeggings() { 64 | return leggings; 65 | } 66 | 67 | public String getBoots() { 68 | return boots; 69 | } 70 | 71 | public int getSetPieces() { 72 | return setPieces; 73 | } 74 | 75 | public boolean isPartOfSet(String itemName) { 76 | return (helmet != null && itemName.endsWith(helmet)) 77 | || (chestplate != null && itemName.endsWith(chestplate)) 78 | || (leggings != null && itemName.endsWith(leggings)) 79 | || (boots != null && itemName.endsWith(boots)); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/rank/items/PowerOrb.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.rank.items; 23 | 24 | public enum PowerOrb { 25 | 26 | RADIANT_ORB(1, "Radiant Power Orb"), 27 | MANA_FLUX(2, "Mana Flux Power Orb"), 28 | OVERFLUX(3, "Overflux Power Orb"); 29 | 30 | private final int id; 31 | private final String name; 32 | 33 | PowerOrb(int id, String name) { 34 | this.id = id; 35 | this.name = name; 36 | } 37 | 38 | public static PowerOrb fromId(int id) { 39 | for (PowerOrb orb : values()) { 40 | if (orb.getId() == id) { 41 | return orb; 42 | } 43 | } 44 | return null; 45 | } 46 | 47 | public static PowerOrb fromName(String name) { 48 | for (PowerOrb orb : values()) { 49 | if (orb.getName().equalsIgnoreCase(name) || orb.name().equalsIgnoreCase(name)) { 50 | return orb; 51 | } 52 | } 53 | return null; 54 | } 55 | 56 | public int getId() { 57 | return id; 58 | } 59 | 60 | public String getName() { 61 | return name; 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | return getName(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/reports/Report.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.reports; 23 | 24 | import com.senither.hypixel.database.controller.GuildController; 25 | import net.hypixel.api.reply.GuildReply; 26 | import net.hypixel.api.reply.skyblock.SkyBlockProfileReply; 27 | 28 | import java.util.HashSet; 29 | import java.util.UUID; 30 | 31 | public class Report { 32 | 33 | private final UUID id; 34 | private final long discordId; 35 | private final HashSet playerReports = new HashSet<>(); 36 | private final GuildController.GuildEntry guildEntry; 37 | private final GuildReply guildReply; 38 | 39 | Report(GuildController.GuildEntry guildEntry, GuildReply guildReply, UUID uniqueId) { 40 | this.id = uniqueId; 41 | this.discordId = guildEntry.getDiscordId(); 42 | this.guildEntry = guildEntry; 43 | this.guildReply = guildReply; 44 | } 45 | 46 | public void createPlayerReport(UnfinishedPlayerReport unfinishedPlayerReport, SkyBlockProfileReply profileReply) { 47 | playerReports.add(new PlayerReport( 48 | unfinishedPlayerReport.getUsername(), 49 | unfinishedPlayerReport.getUuid(), 50 | guildEntry, guildReply, profileReply 51 | )); 52 | } 53 | 54 | public UUID getId() { 55 | return id; 56 | } 57 | 58 | public long getDiscordId() { 59 | return discordId; 60 | } 61 | 62 | public HashSet getPlayerReports() { 63 | return playerReports; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/reports/UnfinishedPlayerReport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.reports; 23 | 24 | import net.hypixel.api.reply.GuildReply; 25 | 26 | import java.util.UUID; 27 | 28 | public class UnfinishedPlayerReport { 29 | 30 | private final UUID uuid; 31 | private final String rank; 32 | 33 | private String username = null; 34 | 35 | UnfinishedPlayerReport(GuildReply.Guild.Member member) { 36 | uuid = member.getUuid(); 37 | rank = member.getRank(); 38 | } 39 | 40 | public UUID getUuid() { 41 | return uuid; 42 | } 43 | 44 | public String getRank() { 45 | return rank; 46 | } 47 | 48 | public String getUsername() { 49 | return username; 50 | } 51 | 52 | public void setUsername(String username) { 53 | this.username = username; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/scheduler/ScheduleManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.scheduler; 23 | 24 | import com.google.common.util.concurrent.ThreadFactoryBuilder; 25 | import com.senither.hypixel.SkyblockAssistant; 26 | import com.senither.hypixel.contracts.scheduler.Job; 27 | 28 | import javax.annotation.Nonnull; 29 | import java.util.HashSet; 30 | import java.util.Set; 31 | import java.util.concurrent.Executors; 32 | import java.util.concurrent.ScheduledExecutorService; 33 | import java.util.concurrent.ScheduledFuture; 34 | 35 | public class ScheduleManager { 36 | 37 | private final Set> tasks = new HashSet<>(); 38 | private final ScheduledExecutorService schedulerService = Executors.newScheduledThreadPool(5, new ThreadFactoryBuilder() 39 | .setPriority(Thread.MAX_PRIORITY) 40 | .setNameFormat("job-schedule-%d") 41 | .build() 42 | ); 43 | 44 | private final SkyblockAssistant app; 45 | 46 | public ScheduleManager(SkyblockAssistant app) { 47 | this.app = app; 48 | } 49 | 50 | public void registerJob(@Nonnull Job job) { 51 | tasks.add(schedulerService.scheduleAtFixedRate(job, job.getDelay(), job.getPeriod(), job.getUnit())); 52 | } 53 | 54 | public Set> entrySet() { 55 | return tasks; 56 | } 57 | 58 | public ScheduledExecutorService getScheduler() { 59 | return schedulerService; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/scheduler/jobs/GarbageCollectorJob.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.scheduler.jobs; 2 | 3 | import com.senither.hypixel.SkyblockAssistant; 4 | import com.senither.hypixel.contracts.scheduler.Job; 5 | import com.senither.hypixel.hypixel.Hypixel; 6 | 7 | import java.util.concurrent.TimeUnit; 8 | 9 | public class GarbageCollectorJob extends Job { 10 | 11 | public GarbageCollectorJob(SkyblockAssistant app) { 12 | super(app, 1, 1, TimeUnit.MINUTES); 13 | } 14 | 15 | @Override 16 | public void run() { 17 | synchronized (Hypixel.uuidToUsernameCache) { 18 | Hypixel.uuidToUsernameCache.cleanUp(); 19 | } 20 | 21 | synchronized (Hypixel.usernameToUuidCache) { 22 | Hypixel.usernameToUuidCache.cleanUp(); 23 | } 24 | 25 | synchronized (Hypixel.uuidToDiscordIdCache) { 26 | Hypixel.usernameToUuidCache.cleanUp(); 27 | } 28 | 29 | synchronized (Hypixel.replyCache) { 30 | Hypixel.replyCache.cleanUp(); 31 | } 32 | 33 | synchronized (Hypixel.responseCache) { 34 | Hypixel.responseCache.cleanUp(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/scheduler/jobs/SplashQueueJob.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.scheduler.jobs; 2 | 3 | import com.senither.hypixel.SkyblockAssistant; 4 | import com.senither.hypixel.contracts.scheduler.Job; 5 | import com.senither.hypixel.database.controller.GuildController; 6 | import com.senither.hypixel.database.controller.PlayerDonationController; 7 | import com.senither.hypixel.splash.SplashContainer; 8 | import com.senither.hypixel.time.Carbon; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import java.sql.SQLException; 13 | import java.util.Iterator; 14 | import java.util.concurrent.TimeUnit; 15 | 16 | public class SplashQueueJob extends Job { 17 | 18 | private static final Logger log = LoggerFactory.getLogger(SplashQueueJob.class); 19 | 20 | public SplashQueueJob(SkyblockAssistant app) { 21 | super(app, 5, 5, TimeUnit.SECONDS); 22 | } 23 | 24 | @Override 25 | public void run() { 26 | try { 27 | Iterator iterator = app.getSplashManager().getSplashes().iterator(); 28 | while (iterator.hasNext()) { 29 | SplashContainer next = iterator.next(); 30 | 31 | if (next.shouldUpdate()) { 32 | app.getSplashManager().updateSplashFor(next); 33 | next.setLastUpdatedAt(Carbon.now().getTimestamp()); 34 | } 35 | 36 | if (next.isFinished()) { 37 | iterator.remove(); 38 | 39 | handlePointsAssignments(next); 40 | } 41 | } 42 | } catch (Exception e) { 43 | log.error("An error occurred while processing the splash queue, error: {}", e.getMessage(), e); 44 | } 45 | } 46 | 47 | private void handlePointsAssignments(SplashContainer container) { 48 | GuildController.GuildEntry guild = GuildController.getGuildById( 49 | app.getDatabaseManager(), container.getDiscordId() 50 | ); 51 | 52 | if (guild == null || !guild.isSplashTrackerEnabled() || !guild.isDonationsTrackerEnabled() || !guild.getSplashPoints()) { 53 | return; 54 | } 55 | 56 | PlayerDonationController.PlayerDonationEntry player = PlayerDonationController.getPlayerByUuid( 57 | app.getDatabaseManager(), container.getDiscordId(), container.getUserUuid() 58 | ); 59 | 60 | if (player == null) { 61 | return; 62 | } 63 | 64 | player.setPoints(player.getPoints() + guild.getDonationPoints()); 65 | 66 | try { 67 | app.getDatabaseManager().queryUpdate("UPDATE `donation_points` SET `points` = ? WHERE `discord_id` = ? AND `uuid` = ?", 68 | player.getPoints(), player.getDiscordId(), player.getUuid() 69 | ); 70 | } catch (SQLException e) { 71 | e.printStackTrace(); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/scheduler/jobs/SyncMetricsJob.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.scheduler.jobs; 2 | 3 | import com.senither.hypixel.SkyblockAssistant; 4 | import com.senither.hypixel.blacklist.BlacklistEntity; 5 | import com.senither.hypixel.contracts.scheduler.Job; 6 | import com.senither.hypixel.metrics.Metrics; 7 | import net.dv8tion.jda.api.JDA; 8 | import net.dv8tion.jda.api.Region; 9 | import net.dv8tion.jda.api.entities.Guild; 10 | 11 | import java.lang.management.ManagementFactory; 12 | import java.util.concurrent.TimeUnit; 13 | 14 | public class SyncMetricsJob extends Job { 15 | 16 | public SyncMetricsJob(SkyblockAssistant app) { 17 | super(app, 0, 30, TimeUnit.SECONDS); 18 | } 19 | 20 | @Override 21 | public void run() { 22 | jdaMetrics(); 23 | uptimeMetrics(); 24 | blacklistMetrics(); 25 | } 26 | 27 | private void blacklistMetrics() { 28 | if (app.getBlacklist() == null) { 29 | return; 30 | } 31 | 32 | Metrics.blacklist.set( 33 | app.getBlacklist().getBlacklistEntities().stream() 34 | .filter(BlacklistEntity::isBlacklisted) 35 | .count() 36 | ); 37 | } 38 | 39 | private void uptimeMetrics() { 40 | Metrics.uptime.labels("dynamic").set(ManagementFactory.getRuntimeMXBean().getUptime()); 41 | } 42 | 43 | private void jdaMetrics() { 44 | Metrics.memoryTotal.set(Runtime.getRuntime().totalMemory()); 45 | Metrics.memoryUsed.set(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()); 46 | 47 | if (app.getShardManager() == null) { 48 | return; 49 | } 50 | 51 | Metrics.guilds.set(app.getShardManager().getGuilds().size()); 52 | Metrics.channels.labels("text").set(app.getShardManager().getTextChannels().size()); 53 | Metrics.channels.labels("voice").set(app.getShardManager().getVoiceChannels().size()); 54 | 55 | for (Region region : Region.values()) { 56 | Metrics.geoTracker.labels(region.getName()).set(0); 57 | } 58 | 59 | for (JDA shard : app.getShardManager().getShards()) { 60 | Metrics.websocketHeartbeat.labels("Shard " + shard.getShardInfo().getShardId()).set(shard.getGatewayPing()); 61 | 62 | for (Guild guild : shard.getGuilds()) { 63 | Metrics.geoTracker.labels(guild.getRegion().getName()).inc(); 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/servlet/WebServlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.servlet; 23 | 24 | import com.senither.hypixel.servlet.filters.HttpFilter; 25 | import com.senither.hypixel.servlet.handlers.NotFoundRouteHandler; 26 | import com.senither.hypixel.servlet.handlers.SparkExceptionHandler; 27 | import org.slf4j.Logger; 28 | import org.slf4j.LoggerFactory; 29 | import spark.Route; 30 | import spark.Spark; 31 | 32 | public class WebServlet { 33 | 34 | public static final Logger log = LoggerFactory.getLogger(WebServlet.class); 35 | 36 | private final int port; 37 | private boolean initialized; 38 | 39 | public WebServlet(int port) { 40 | this.port = port; 41 | this.initialized = false; 42 | } 43 | 44 | private void initialize() { 45 | log.info("Igniting Spark API on port: " + port); 46 | 47 | Spark.port(port); 48 | 49 | Spark.after(new HttpFilter()); 50 | Spark.notFound(new NotFoundRouteHandler()); 51 | Spark.exception(Exception.class, new SparkExceptionHandler()); 52 | 53 | initialized = true; 54 | } 55 | 56 | public synchronized void registerGet(final String path, final Route route) { 57 | if (!initialized) { 58 | initialize(); 59 | } 60 | 61 | log.debug("GET {} has been registered o {}", path, route.getClass().getTypeName()); 62 | Spark.get(path, route); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/servlet/filters/HttpFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.servlet.filters; 23 | 24 | import com.senither.hypixel.servlet.WebServlet; 25 | import spark.Filter; 26 | import spark.Request; 27 | import spark.Response; 28 | 29 | public class HttpFilter implements Filter { 30 | 31 | @Override 32 | public void handle(Request request, Response response) throws Exception { 33 | WebServlet.log.debug(request.requestMethod() + " " + request.pathInfo()); 34 | 35 | response.header("Access-Control-Allow-Origin", "*"); 36 | response.type("application/json"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/servlet/handlers/NotFoundRouteHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.servlet.handlers; 23 | 24 | import com.senither.hypixel.contracts.servlet.SparkRoute; 25 | import spark.Request; 26 | import spark.Response; 27 | 28 | public class NotFoundRouteHandler extends SparkRoute { 29 | 30 | public NotFoundRouteHandler() { 31 | super(null); 32 | } 33 | 34 | @Override 35 | public Object handle(Request request, Response response) throws Exception { 36 | return buildResponse(response, 404, "Route was not found!"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/servlet/handlers/SparkExceptionHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.servlet.handlers; 23 | 24 | import com.google.gson.JsonObject; 25 | import com.senither.hypixel.exceptions.FriendlyException; 26 | import com.senither.hypixel.servlet.WebServlet; 27 | import spark.ExceptionHandler; 28 | import spark.Request; 29 | import spark.Response; 30 | 31 | import java.io.IOException; 32 | import java.io.PrintWriter; 33 | import java.io.StringWriter; 34 | import java.util.concurrent.ExecutionException; 35 | 36 | public class SparkExceptionHandler implements ExceptionHandler { 37 | 38 | @Override 39 | public void handle(Exception exception, Request request, Response response) { 40 | response.status(500); 41 | 42 | if (exception instanceof FriendlyException || (exception instanceof ExecutionException && exception.getCause() instanceof FriendlyException)) { 43 | JsonObject root = new JsonObject(); 44 | 45 | root.addProperty("status", 400); 46 | root.addProperty("reason", exception instanceof ExecutionException 47 | ? exception.getCause().getMessage() : exception.getMessage() 48 | ); 49 | 50 | response.header("Access-Control-Allow-Origin", "*"); 51 | response.type("application/json"); 52 | 53 | response.body(root.toString()); 54 | return; 55 | } 56 | 57 | WebServlet.log.error(request.requestMethod() + " " + request.pathInfo(), exception); 58 | 59 | try (StringWriter writer = new StringWriter()) { 60 | try (PrintWriter printer = new PrintWriter(writer)) { 61 | exception.printStackTrace(printer); 62 | 63 | response.body(writer.toString()); 64 | response.type("text/plain"); 65 | } 66 | } catch (IOException e) { 67 | e.printStackTrace(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/servlet/routes/GetMetrics.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.servlet.routes; 2 | 3 | import com.senither.hypixel.SkyblockAssistant; 4 | import com.senither.hypixel.contracts.servlet.SparkRoute; 5 | import com.senither.hypixel.metrics.PrometheusMetricsServlet; 6 | import spark.Request; 7 | import spark.Response; 8 | 9 | public class GetMetrics extends SparkRoute { 10 | 11 | private static final PrometheusMetricsServlet metricsServlet = new PrometheusMetricsServlet(); 12 | 13 | public GetMetrics(SkyblockAssistant app) { 14 | super(app); 15 | } 16 | 17 | @Override 18 | public Object handle(Request request, Response response) throws Exception { 19 | return metricsServlet.servletGet(request.raw(), response.raw()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/servlet/routes/GetUsernameRoute.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.servlet.routes; 2 | 3 | import com.google.gson.JsonObject; 4 | import com.senither.hypixel.SkyblockAssistant; 5 | import com.senither.hypixel.contracts.servlet.SparkRoute; 6 | import com.senither.hypixel.database.collection.Collection; 7 | import com.senither.hypixel.database.collection.DataRow; 8 | import spark.Request; 9 | import spark.Response; 10 | 11 | import java.util.Arrays; 12 | import java.util.HashSet; 13 | import java.util.List; 14 | import java.util.UUID; 15 | 16 | public class GetUsernameRoute extends SparkRoute { 17 | 18 | public GetUsernameRoute(SkyblockAssistant app) { 19 | super(app); 20 | } 21 | 22 | @Override 23 | public Object handle(Request request, Response response) throws Exception { 24 | HashSet stringifiedUuids = getUuidsFromRequest(request); 25 | if (stringifiedUuids.isEmpty()) { 26 | return buildResponse(response, 400, "Missing uuid or uuids query parameters for the uuids that should be resolved."); 27 | } 28 | 29 | StringBuilder stringifiedParams = new StringBuilder(); 30 | for (String ignored : stringifiedUuids) { 31 | stringifiedParams.append("?, "); 32 | } 33 | 34 | Collection usernamesCollection = app.getDatabaseManager().query(String.format( 35 | "SELECT `uuid`, `username` FROM `uuids` WHERE `uuid` IN (%s)", 36 | stringifiedParams.toString().substring(0, stringifiedParams.length() - 2) 37 | ), stringifiedUuids.toArray()); 38 | 39 | JsonObject jsonObject = new JsonObject(); 40 | for (String uuidString : stringifiedUuids) { 41 | try { 42 | UUID uuid = UUID.fromString(uuidString); 43 | 44 | List currentUuid = usernamesCollection.where("uuid", uuid.toString()); 45 | if (currentUuid.isEmpty()) { 46 | jsonObject.add(uuid.toString(), null); 47 | continue; 48 | } 49 | jsonObject.addProperty(uuid.toString(), currentUuid.get(0).getString("username")); 50 | } catch (IllegalArgumentException ignored) { 51 | } 52 | } 53 | 54 | return buildDataResponse(response, 200, jsonObject); 55 | } 56 | 57 | public HashSet getUuidsFromRequest(Request request) { 58 | HashSet uuids = new HashSet<>(); 59 | 60 | if (request.queryParams("uuid") != null) { 61 | uuids.add(request.queryParams("uuid")); 62 | } 63 | 64 | if (request.queryParams("uuids") != null) { 65 | uuids.addAll(Arrays.asList(request.queryParams("uuids").split(","))); 66 | } 67 | 68 | return uuids; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/splash/SplashContainer.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.splash; 2 | 3 | import com.senither.hypixel.time.Carbon; 4 | 5 | import java.util.UUID; 6 | 7 | public class SplashContainer { 8 | 9 | private final long id; 10 | private final long discordId; 11 | private final UUID userUuid; 12 | private final Carbon time; 13 | 14 | private String note; 15 | private long messageId; 16 | private long lastUpdatedAt; 17 | private boolean notifiedEveryone; 18 | 19 | public SplashContainer(long id, long discordId, UUID userUuid, long messageId, Carbon time, String note) { 20 | this.id = id; 21 | this.discordId = discordId; 22 | this.userUuid = userUuid; 23 | this.messageId = messageId; 24 | this.time = time; 25 | this.note = note; 26 | 27 | notifiedEveryone = time.diffInSeconds(Carbon.now()) <= SplashManager.getEndingSoonTimer(); 28 | lastUpdatedAt = Carbon.now().getTimestamp(); 29 | } 30 | 31 | public long getId() { 32 | return id; 33 | } 34 | 35 | public long getDiscordId() { 36 | return discordId; 37 | } 38 | 39 | public UUID getUserUuid() { 40 | return userUuid; 41 | } 42 | 43 | public long getMessageId() { 44 | return messageId; 45 | } 46 | 47 | public void setMessageId(long messageId) { 48 | this.messageId = messageId; 49 | } 50 | 51 | public Carbon getTime() { 52 | return time; 53 | } 54 | 55 | public String getNote() { 56 | return note; 57 | } 58 | 59 | public void setNote(String note) { 60 | this.note = note; 61 | } 62 | 63 | public long getLastUpdatedAt() { 64 | return lastUpdatedAt; 65 | } 66 | 67 | public void setLastUpdatedAt(long lastUpdatedAt) { 68 | this.lastUpdatedAt = lastUpdatedAt; 69 | } 70 | 71 | public void setNotifiedEveryone(boolean notifiedEveryone) { 72 | this.notifiedEveryone = notifiedEveryone; 73 | } 74 | 75 | public boolean hasNotifiedEveryone() { 76 | return notifiedEveryone; 77 | } 78 | 79 | public boolean shouldUpdate() { 80 | long secondsSinceLastUpdate = Carbon.now().getTimestamp() - getLastUpdatedAt(); 81 | long secondsLeft = time.diffInSeconds(); 82 | 83 | return secondsLeft < 30 84 | || secondsLeft < 300 && secondsSinceLastUpdate > 25 85 | || secondsSinceLastUpdate > 60; 86 | } 87 | 88 | public boolean isFinished() { 89 | return time.isPast(); 90 | } 91 | 92 | public boolean isEndingSoon() { 93 | return time.diffInSeconds() <= SplashManager.getEndingSoonTimer(); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/statistics/StatisticsChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.statistics; 23 | 24 | import com.senither.hypixel.statistics.checker.DungeonChecker; 25 | import com.senither.hypixel.statistics.checker.PetsChecker; 26 | import com.senither.hypixel.statistics.checker.SkillsChecker; 27 | import com.senither.hypixel.statistics.checker.SlayerChecker; 28 | 29 | @SuppressWarnings("unused") 30 | public class StatisticsChecker { 31 | 32 | public final static DungeonChecker DUNGEON = new DungeonChecker(); 33 | public final static SkillsChecker SKILLS = new SkillsChecker(); 34 | public final static SlayerChecker SLAYER = new SlayerChecker(); 35 | public final static PetsChecker PETS = new PetsChecker(); 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/statistics/checker/DungeonChecker.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.statistics.checker; 2 | 3 | import com.google.gson.JsonObject; 4 | import com.senither.hypixel.contracts.statistics.Checker; 5 | import com.senither.hypixel.statistics.responses.DungeonResponse; 6 | import net.hypixel.api.reply.PlayerReply; 7 | import net.hypixel.api.reply.skyblock.SkyBlockProfileReply; 8 | 9 | import javax.annotation.Nullable; 10 | 11 | public class DungeonChecker extends Checker { 12 | 13 | @Override 14 | public DungeonResponse checkUser(@Nullable PlayerReply playerReply, SkyBlockProfileReply profileReply, JsonObject member) { 15 | JsonObject dungeons = member.getAsJsonObject("dungeons"); 16 | if (!hasDungeonData(dungeons)) { 17 | return new DungeonResponse(true, false); 18 | } 19 | 20 | DungeonResponse response = new DungeonResponse(true, true); 21 | 22 | response.setSelectedClass(dungeons.has("selected_dungeon_class") 23 | ? DungeonResponse.DungeonClassType.fromName(dungeons.get("selected_dungeon_class").getAsString()) 24 | : null 25 | ); 26 | 27 | if (playerReply != null && playerReply.getPlayer().has("achievements")) { 28 | JsonObject achievements = playerReply.getPlayer().getAsJsonObject("achievements"); 29 | 30 | response.setSecretsFound( 31 | achievements.has("skyblock_treasure_hunter") 32 | ? achievements.get("skyblock_treasure_hunter").getAsInt() 33 | : -1 34 | ); 35 | } 36 | 37 | JsonObject playerClasses = dungeons.getAsJsonObject("player_classes"); 38 | for (DungeonResponse.DungeonClassType dungeonClassType : DungeonResponse.DungeonClassType.values()) { 39 | JsonObject dungeonClass = playerClasses.getAsJsonObject(dungeonClassType.name().toLowerCase()); 40 | 41 | response.setPlayerClassExperience( 42 | dungeonClassType, 43 | dungeonClass.has("experience") 44 | ? dungeonClass.get("experience").getAsDouble() 45 | : 0D 46 | ); 47 | } 48 | 49 | JsonObject dungeonTypes = dungeons.getAsJsonObject("dungeon_types"); 50 | for (DungeonResponse.DungeonType dungeonType : DungeonResponse.DungeonType.values()) { 51 | response.setDungeonContent(dungeonType, dungeonTypes.getAsJsonObject(dungeonType.name().toLowerCase())); 52 | } 53 | 54 | return response; 55 | } 56 | 57 | private boolean hasDungeonData(JsonObject object) { 58 | return object != null 59 | && object.has("dungeon_types") 60 | && object.has("player_classes") 61 | && object.getAsJsonObject("dungeon_types").has("catacombs") 62 | && object.getAsJsonObject("dungeon_types").getAsJsonObject("catacombs").has("experience") 63 | && object.getAsJsonObject("dungeon_types").getAsJsonObject("catacombs").has("tier_completions"); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/statistics/checker/PetsChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.statistics.checker; 23 | 24 | import com.google.gson.JsonElement; 25 | import com.google.gson.JsonObject; 26 | import com.senither.hypixel.contracts.statistics.Checker; 27 | import com.senither.hypixel.statistics.responses.PetsResponse; 28 | import net.hypixel.api.reply.PlayerReply; 29 | import net.hypixel.api.reply.skyblock.SkyBlockProfileReply; 30 | 31 | import javax.annotation.Nullable; 32 | 33 | public class PetsChecker extends Checker { 34 | 35 | @Override 36 | public PetsResponse checkUser(@Nullable PlayerReply playerReply, SkyBlockProfileReply profileReply, JsonObject member) { 37 | if (!member.has("pets")) { 38 | return new PetsResponse(false, false); 39 | } 40 | 41 | if (member.getAsJsonArray("pets").size() == 0) { 42 | return new PetsResponse(true, false); 43 | } 44 | 45 | PetsResponse response = new PetsResponse(true, true); 46 | 47 | for (JsonElement element : member.getAsJsonArray("pets")) { 48 | JsonObject pet = element.getAsJsonObject(); 49 | 50 | JsonElement heldItem = pet.get("heldItem"); 51 | 52 | response.addPet( 53 | pet.get("type").getAsString(), 54 | pet.get("tier").getAsString(), 55 | pet.get("exp").getAsLong(), 56 | heldItem == null || heldItem.isJsonNull() 57 | ? null : heldItem.getAsString(), 58 | pet.get("active").getAsBoolean() 59 | ); 60 | } 61 | 62 | return response; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/statistics/weight/DungeonWeight.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.statistics.weight; 2 | 3 | import com.senither.hypixel.Constants; 4 | import com.senither.hypixel.contracts.statistics.CanCalculateWeight; 5 | import com.senither.hypixel.contracts.statistics.DungeonWeightRelationFunction; 6 | import com.senither.hypixel.statistics.responses.DungeonResponse; 7 | 8 | public enum DungeonWeight { 9 | 10 | /** 11 | * Maxes out Catacomb at 9,500 points at level 50. 12 | */ 13 | CATACOMB(response -> response.getDungeonFromType(DungeonResponse.DungeonType.CATACOMBS), 0.0002149604615), 14 | 15 | /** 16 | * Maxes out Healer at 200 points at level 50. 17 | */ 18 | HEALER(response -> response.getClassFromType(DungeonResponse.DungeonClassType.HEALER), 0.0000045254834), 19 | 20 | /** 21 | * Maxes out Mage at 200 points at level 50. 22 | */ 23 | MAGE(response -> response.getClassFromType(DungeonResponse.DungeonClassType.MAGE), 0.0000045254834), 24 | 25 | /** 26 | * Maxes out Berserk at 200 points at level 50. 27 | */ 28 | BERSERK(response -> response.getClassFromType(DungeonResponse.DungeonClassType.BERSERK), 0.0000045254834), 29 | 30 | /** 31 | * Maxes out Archer at 200 points at level 50. 32 | */ 33 | ARCHER(response -> response.getClassFromType(DungeonResponse.DungeonClassType.ARCHER), 0.0000045254834), 34 | 35 | /** 36 | * Maxes out Tank at 200 points at level 50. 37 | */ 38 | TANK(response -> response.getClassFromType(DungeonResponse.DungeonClassType.TANK), 0.0000045254834); 39 | 40 | private static final double level50Exp = 569809640; 41 | 42 | private final DungeonWeightRelationFunction function; 43 | private final double exponent; 44 | 45 | DungeonWeight(DungeonWeightRelationFunction function, double exponent) { 46 | this.function = function; 47 | this.exponent = exponent; 48 | } 49 | 50 | public CanCalculateWeight getCalculatorFromDungeon(DungeonResponse response) { 51 | return function.getWeight(response); 52 | } 53 | 54 | public Weight calculateWeight(double experience) { 55 | double level = getLevelFromExperience(experience); 56 | double base = Math.pow(level, 4.5) * exponent; 57 | 58 | if (experience <= level50Exp) { 59 | return new Weight(base, 0D); 60 | } 61 | 62 | return new Weight( 63 | Math.floor(base), 64 | Math.pow((experience - level50Exp) / (4 * level50Exp / base), 0.968) 65 | ); 66 | } 67 | 68 | private double getLevelFromExperience(double experience) { 69 | int level = 0; 70 | for (int toRemove : Constants.DUNGEON_EXPERIENCE) { 71 | experience -= toRemove; 72 | if (experience < 0) { 73 | return level + (1D - (experience * -1) / (double) toRemove); 74 | } 75 | level++; 76 | } 77 | return level; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/statistics/weight/SlayerWeight.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.statistics.weight; 2 | 3 | import com.senither.hypixel.contracts.statistics.SlayerWeightRelationFunction; 4 | import com.senither.hypixel.statistics.responses.SlayerResponse; 5 | 6 | public enum SlayerWeight { 7 | 8 | REVENANT(SlayerResponse::getRevenant, 2208, .15), 9 | TARANTULA(SlayerResponse::getTarantula, 2118, .08), 10 | SVEN(SlayerResponse::getSven, 1962, .015), 11 | ENDERMAN(SlayerResponse::getEnderman, 1430, .017); 12 | 13 | private final SlayerWeightRelationFunction function; 14 | private final double divider; 15 | private final double modifier; 16 | 17 | SlayerWeight(SlayerWeightRelationFunction function, double divider, double modifier) { 18 | this.function = function; 19 | this.divider = divider; 20 | this.modifier = modifier; 21 | } 22 | 23 | public SlayerResponse.SlayerStat getSlayerStatsRelation(SlayerResponse response) { 24 | return function.getWeight(response); 25 | } 26 | 27 | public Weight calculateSkillWeight(double experience) { 28 | if (experience == 0) { 29 | return new Weight(0D, 0D); 30 | } 31 | 32 | if (experience <= 1000000) { 33 | return new Weight(experience / divider, 0D); 34 | } 35 | 36 | double base = 1000000 / divider; 37 | double remaining = experience - 1000000; 38 | 39 | double modifier = this.modifier; 40 | double overflow = 0; 41 | 42 | while (remaining > 0) { 43 | double left = Math.min(remaining, 1000000); 44 | 45 | overflow += Math.pow(left / (divider * (1.5 + modifier)), 0.942); 46 | remaining -= left; 47 | modifier += this.modifier; 48 | } 49 | 50 | return new Weight(base + overflow, 0D); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/statistics/weight/Weight.java: -------------------------------------------------------------------------------- 1 | package com.senither.hypixel.statistics.weight; 2 | 3 | import com.senither.hypixel.utils.NumberUtil; 4 | 5 | public class Weight { 6 | 7 | private final double weight; 8 | private final double overflow; 9 | 10 | public Weight(double weight, double overflow) { 11 | this.weight = weight; 12 | this.overflow = overflow; 13 | } 14 | 15 | public Weight() { 16 | this(0D, 0D); 17 | } 18 | 19 | public double getWeight() { 20 | return weight; 21 | } 22 | 23 | public double getOverflow() { 24 | return overflow; 25 | } 26 | 27 | public double getTotalWeight() { 28 | return weight + overflow; 29 | } 30 | 31 | public Weight add(Weight weight) { 32 | return new Weight( 33 | weight.getWeight() + getWeight(), 34 | weight.getOverflow() + getOverflow() 35 | ); 36 | } 37 | 38 | public String getTotalWeightStringified() { 39 | if (overflow == 0D) { 40 | return NumberUtil.formatNicelyWithDecimals(weight); 41 | } 42 | 43 | return String.format("%s (%s Total)", 44 | toString(), 45 | NumberUtil.formatNicelyWithDecimals(weight + overflow) 46 | ); 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | if (overflow == 0D) { 52 | return NumberUtil.formatNicelyWithDecimals(weight); 53 | } 54 | return NumberUtil.formatNicelyWithDecimals(weight) 55 | + " + " + NumberUtil.formatNicelyWithDecimals(overflow) + " Overflow"; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/time/Time.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018. 3 | * 4 | * This file is part of AvaIre. 5 | * 6 | * AvaIre is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * AvaIre is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with AvaIre. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.time; 23 | 24 | public enum Time { 25 | 26 | YEARS_PER_CENTURY(100), 27 | YEARS_PER_DECADE(10), 28 | MONTHS_PER_YEAR(12), 29 | WEEKS_PER_YEAR(52), 30 | DAYS_PER_WEEK(7), 31 | HOURS_PER_DAY(24), 32 | MINUTES_PER_HOUR(60), 33 | SECONDS_PER_MINUTE(60); 34 | 35 | private final int time; 36 | 37 | Time(int time) { 38 | this.time = time; 39 | } 40 | 41 | /** 42 | * Gets the time. 43 | * 44 | * @return the integer time value 45 | */ 46 | public int getTime() { 47 | return time; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/utils/NumberUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020. 3 | * 4 | * This file is part of Hypixel Skyblock Assistant. 5 | * 6 | * Hypixel Guild Synchronizer is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Hypixel Guild Synchronizer is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Hypixel Guild Synchronizer. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.utils; 23 | 24 | import javax.annotation.Nonnull; 25 | import java.text.DecimalFormat; 26 | import java.util.regex.Pattern; 27 | 28 | public class NumberUtil { 29 | 30 | private static final Pattern numberPattern = Pattern.compile("[-+]?\\d*\\.?\\d+"); 31 | private static final DecimalFormat niceFormat = new DecimalFormat("#,##0"); 32 | private static final DecimalFormat niceFormatWithDecimal = new DecimalFormat("#,###.##"); 33 | 34 | public static int parseInt(String number, int fallback) { 35 | try { 36 | return Integer.parseInt(number); 37 | } catch (NumberFormatException e) { 38 | return fallback; 39 | } 40 | } 41 | 42 | public static double parseDouble(String number, int fallback) { 43 | try { 44 | return Double.parseDouble(number); 45 | } catch (NumberFormatException e) { 46 | return fallback; 47 | } 48 | } 49 | 50 | public static int getBetween(int number, int min, int max) { 51 | return Math.min(max, Math.max(min, number)); 52 | } 53 | 54 | public static String formatNicely(int value) { 55 | return niceFormat.format(value); 56 | } 57 | 58 | public static String formatNicely(double value) { 59 | return niceFormat.format(value); 60 | } 61 | 62 | public static String formatNicely(long value) { 63 | return niceFormat.format(value); 64 | } 65 | 66 | public static String formatNicelyWithDecimals(double value) { 67 | return niceFormatWithDecimal.format(value); 68 | } 69 | 70 | public static boolean isNumeric(@Nonnull String string) { 71 | return numberPattern.matcher(string).matches(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/senither/hypixel/utils/RestActionUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018. 3 | * 4 | * This file is part of AvaIre. 5 | * 6 | * AvaIre is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * AvaIre is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with AvaIre. If not, see . 18 | * 19 | * 20 | */ 21 | 22 | package com.senither.hypixel.utils; 23 | 24 | import net.dv8tion.jda.api.exceptions.ErrorResponseException; 25 | import net.dv8tion.jda.api.requests.ErrorResponse; 26 | import net.dv8tion.jda.api.requests.RestAction; 27 | import okhttp3.internal.http2.StreamResetException; 28 | import org.apache.http.ConnectionClosedException; 29 | import org.slf4j.Logger; 30 | import org.slf4j.LoggerFactory; 31 | 32 | import java.net.SocketTimeoutException; 33 | import java.util.function.Consumer; 34 | 35 | public class RestActionUtil { 36 | 37 | /** 38 | * The slf4j rest action utility logger instance. 39 | */ 40 | public static final Logger log = LoggerFactory.getLogger(RestActionUtil.class); 41 | 42 | /** 43 | * This function does nothing other than work as a rest 44 | * action failure consumer that ignores the failure. 45 | */ 46 | public static final Consumer ignore = ignored -> { 47 | // Nothing to see here 48 | }; 49 | 50 | /** 51 | * This functions passes on the error to the default failure, 52 | * unless it meets some special caterina, in which case it 53 | * may either be ignored, or handled differently. 54 | */ 55 | public static final Consumer handleMessageCreate = error -> { 56 | if (error == null) return; 57 | 58 | if (error instanceof ErrorResponseException) { 59 | if (((ErrorResponseException) error).getErrorCode() == ErrorResponse.MISSING_ACCESS.getCode()) { 60 | return; // Ignore missing access errors 61 | } 62 | } 63 | 64 | if (isOkHttpConnectionError(error)) { 65 | log.warn("RestAction queue resulted in a {}: {}", 66 | error.getClass().getSimpleName(), error.getMessage(), error 67 | ); 68 | return; // Ignore OkHttp connection errors and simply warn the user instead 69 | } 70 | 71 | RestAction.getDefaultFailure().accept(error); 72 | }; 73 | 74 | private static boolean isOkHttpConnectionError(Throwable error) { 75 | return error instanceof StreamResetException 76 | || error instanceof SocketTimeoutException 77 | || error instanceof ConnectionClosedException; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /app/src/main/resources/app.properties: -------------------------------------------------------------------------------- 1 | version=@project.version@ 2 | groupId=@project.groupId@ 3 | artifactId=@project.artifactId@ 4 | -------------------------------------------------------------------------------- /app/src/main/resources/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "discord_token": null, 3 | "hypixel_token": null, 4 | "leaderboard_uri": null, 5 | "database": { 6 | "hostname": "localhost:3306", 7 | "username": "username", 8 | "password": "password", 9 | "database": "skyblock_assistant" 10 | }, 11 | "servlet": { 12 | "app_url": "http://localhost/", 13 | "enabled": true, 14 | "port": 1256, 15 | "access_token": null 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /web/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /web/.gitignore: -------------------------------------------------------------------------------- 1 | # Node & NPM 2 | node_modules/ 3 | 4 | # Generated assets directories 5 | public/css 6 | public/js 7 | mix-manifest\.json 8 | -------------------------------------------------------------------------------- /web/assets/js/app.js: -------------------------------------------------------------------------------- 1 | 2 | import Vue from 'vue'; 3 | import Axios from 'axios'; 4 | 5 | window.axios = Axios; 6 | 7 | Vue.mixin({ 8 | methods: { 9 | formatNumber(number) { 10 | return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); 11 | } 12 | } 13 | }); 14 | 15 | import App from './views/App'; 16 | 17 | const app = new Vue({ 18 | el: '#app', 19 | components: { 20 | App 21 | }, 22 | }); 23 | -------------------------------------------------------------------------------- /web/assets/js/components/FullscreenHeroStatus.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 22 | -------------------------------------------------------------------------------- /web/assets/js/config.js: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | 4 | /** 5 | * This is the hostname and port that the interal API of the bot is hosted on, 6 | * you can use the IP of the server the bot is hosted on combined with 7 | * the port defined in the config for the API. 8 | */ 9 | interalApi: 'http://localhost:1256', 10 | }; 11 | -------------------------------------------------------------------------------- /web/assets/js/views/App.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 30 | 31 | 63 | -------------------------------------------------------------------------------- /web/assets/sass/_variables.scss: -------------------------------------------------------------------------------- 1 | 2 | // Typography 3 | $font-family-sans-serif: "Roboto", sans-serif; 4 | $font-size-base: 0.9rem; 5 | $line-height-base: 1.6; 6 | -------------------------------------------------------------------------------- /web/assets/sass/app.scss: -------------------------------------------------------------------------------- 1 | // Fonts 2 | @import url('https://fonts.googleapis.com/css?family=Roboto'); 3 | 4 | // Variables 5 | @import 'variables'; 6 | 7 | // Bulma + Bulmaswatch Theme 8 | @import '~bulmaswatch/darkly/_variables'; 9 | @import '~bulma/bulma'; 10 | @import '~bulmaswatch/darkly/_overrides'; 11 | 12 | // Bulma Plugins 13 | @import '@creativebulma/bulma-tooltip'; 14 | 15 | // Custom Styles 16 | @import 'pages/report'; 17 | -------------------------------------------------------------------------------- /web/assets/sass/pages/report.scss: -------------------------------------------------------------------------------- 1 | .report-container { 2 | padding-top: 28px; 3 | 4 | & .message>.message-header { 5 | border-radius: 5px 6 | } 7 | 8 | & .rank, & .uuid, & .profile-name { 9 | color: $grey; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 6 | "watch": "npm run development -- --watch", 7 | "watch-poll": "npm run watch -- --watch-poll", 8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", 9 | "prod": "npm run production", 10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 11 | }, 12 | "devDependencies": { 13 | "axios": "^0.21.1", 14 | "bulma": "^0.7.4", 15 | "bulmaswatch": "^0.8.0", 16 | "cross-env": "^5.1", 17 | "laravel-mix": "^5.0.9", 18 | "moment": "^2.24.0", 19 | "resolve-url-loader": "^3.1.2", 20 | "sass": "^1.17.0", 21 | "sass-loader": "^7.1.0", 22 | "vue": "^2.5.17", 23 | "vue-template-compiler": "^2.6.6" 24 | }, 25 | "dependencies": { 26 | "@creativebulma/bulma-tooltip": "^1.0.1" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /web/public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Redirect Trailing Slashes If Not A Folder... 9 | RewriteCond %{REQUEST_FILENAME} !-d 10 | RewriteCond %{REQUEST_URI} (.+)/$ 11 | RewriteRule ^ %1 [L,R=301] 12 | 13 | # Handle Front Controller... 14 | RewriteCond %{REQUEST_FILENAME} !-d 15 | RewriteCond %{REQUEST_FILENAME} !-f 16 | RewriteRule ^ index.html [L] 17 | 18 | -------------------------------------------------------------------------------- /web/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hypixel Skyblock Assistant Report 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /web/webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | mix.js('assets/js/app.js', 'public/js') 4 | .sass('assets/sass/app.scss', 'public/css'); 5 | --------------------------------------------------------------------------------