diff --git a/build.gradle.kts b/build.gradle.kts index 549c10f..a90bf54 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,14 +32,14 @@ val ownerID = 372703841151614976L group = "net.moonleay.liljudd" version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } - ?: "2.6.4" + ?: "2.5.6" val kordver = "1.5.9-SNAPSHOT" val coroutinesver = "1.7.3" -val ktorver = "2.3.5" +val ktor_version = "2.3.4" val exposedver = "0.43.0" val postgresver = "42.6.0" -val krontabver = "2.2.1" +val krontabver = "2.2.0" val mavenArtifact = "lilJudd" project.base.archivesName.set(mavenArtifact) @@ -89,8 +89,6 @@ implementation.extendsFrom(shadow) dependencies { //Discord shadow("com.kotlindiscord.kord.extensions:kord-extensions:$kordver") - - //Coroutines shadow("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesver") //Logging @@ -103,10 +101,10 @@ dependencies { shadow("org.jetbrains.exposed:exposed-jdbc:$exposedver") shadow("org.postgresql:postgresql:$postgresver") - //Krontab + //Korntab shadow("dev.inmo:krontab:$krontabver") - shadow("io.ktor:ktor-client-core-jvm:2.3.5") - shadow("io.ktor:ktor-client-cio-jvm:2.3.5") + "shadow"("io.ktor:ktor-client-core-jvm:2.3.4") + "shadow"("io.ktor:ktor-client-cio-jvm:2.3.4") } @@ -118,7 +116,7 @@ val templateProps = mapOf( "ownerID" to ownerID, "kordversion" to kordver, "coroutinesversion" to coroutinesver, - "ktorversion" to ktorver, + "ktorversion" to ktor_version, "exposedversion" to exposedver, "postgresversion" to postgresver, "krontabversion" to krontabver diff --git a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt index 6a5bf7b..750eb8c 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt @@ -33,17 +33,11 @@ import kotlinx.coroutines.launch import net.moonleay.botendo.build.BuildConstants import net.moonleay.lilJudd.buttons.component.EditButtonManager import net.moonleay.lilJudd.data.CredentialManager -import net.moonleay.lilJudd.data.api.Splatoon3ApiCache -import net.moonleay.lilJudd.data.api.type.ApiDataType -import net.moonleay.lilJudd.data.api.type.ApiRequestType -import net.moonleay.lilJudd.data.database.DB +import net.moonleay.lilJudd.data.DB import net.moonleay.lilJudd.extensions.* import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.features.MatchManager import net.moonleay.lilJudd.features.TimeManager -import net.moonleay.lilJudd.jobs.Splatoon3ApiScheduleUpdateScheduler -import net.moonleay.lilJudd.jobs.StatusUpdater -import net.moonleay.lilJudd.jobs.component.JobManager import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.MessageUtil @@ -105,7 +99,7 @@ object Bot { } extensions { - add(::InfoExtension) + add(::VersionExtension) add(::FeatureManageExtension) add(::SendPlannerExtension) add(::MatchExtension) @@ -126,6 +120,7 @@ object Bot { sharding { recommended -> Shards(recommended) } */ + // Same goes for a Database table rewrite } // Register button presses @@ -146,6 +141,7 @@ object Bot { } if (inter.componentId.startsWith("public.message.")) { val response = inter.deferPublicResponse() + val g = this.interaction.getOriginalInteractionResponse().getGuild() response.respond { this.embeds = mutableListOf( MessageUtil.getEmbed( @@ -163,20 +159,8 @@ object Bot { bot.kordRef.on { AvailabilityManager.runThread() // Update Availabilities MatchManager.update() // Update Matches - // Make the bot update the status every 6 seconds - JobManager.addJob(StatusUpdater) } - // Update the Splatoon 3 api data and make sure it stays up-to-date - Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_CREATION_AT_STARTUP) - JobManager.addJob(Splatoon3ApiScheduleUpdateScheduler) - /* - Other caches will be added when implemented - its not used yet in order to reduce load on the api, - which i am using. - */ - //JobManager.addJob(Splatoon3ApiFestivalAndCoopUpdateScheduler) - //JobManager.addJob(Splatoon3ApiSplatnetGearUpdateScheduler) //Start the bot bot.start() diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt index 4e04fa1..115a7e5 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt @@ -28,7 +28,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.rest.builder.message.modify.embed import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.buttons.component.IEditButton -import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository +import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.MessageUtil diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt index 348446c..c7cebc3 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt @@ -28,7 +28,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.rest.builder.message.modify.embed import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.buttons.component.IEditButton -import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository +import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.Logger diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt index 93f6b36..d775a29 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt @@ -28,7 +28,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.rest.builder.message.modify.embed import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.buttons.component.IEditButton -import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository +import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.MessageUtil diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/DB.kt b/src/main/kotlin/net/moonleay/lilJudd/data/DB.kt similarity index 83% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/DB.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/DB.kt index 7c58ea0..f02009e 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/DB.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/DB.kt @@ -16,13 +16,13 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database +package net.moonleay.lilJudd.data -import net.moonleay.lilJudd.data.database.tables.MatchPlanningData -import net.moonleay.lilJudd.data.database.tables.PlanningNotifierRoles -import net.moonleay.lilJudd.data.database.tables.TimePlanningChannels -import net.moonleay.lilJudd.data.database.tables.TimePlanningMessages +import net.moonleay.lilJudd.data.tables.MatchPlanningData +import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles +import net.moonleay.lilJudd.data.tables.TimePlanningChannels +import net.moonleay.lilJudd.data.tables.TimePlanningMessages import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.SchemaUtils import org.jetbrains.exposed.sql.transactions.transaction diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3Api.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3Api.kt deleted file mode 100644 index b0192e5..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3Api.kt +++ /dev/null @@ -1,117 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api - -import net.moonleay.lilJudd.data.api.entry.schedule.ModeData -import net.moonleay.lilJudd.util.TimeUtil - -object Splatoon3Api { - private fun getRegularMode(timestamp: Long): ModeData { - Splatoon3ApiCache.cachedRegularModeData.map { modeData -> - val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") - val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") - if (timestamp in startTime..endTime) { - return modeData - } - } - throw Exception("No current mode found") - } - - private fun getOpenMode(timestamp: Long): ModeData { - Splatoon3ApiCache.cachedCompetitiveOpenModeData.map { modeData -> - val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") - val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") - if (timestamp in startTime..endTime) { - return modeData - } - } - throw Exception("No current mode found") - } - - private fun getXMode(timestamp: Long): ModeData { - Splatoon3ApiCache.cachedXModeData.map { modeData -> - val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") - val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") - if (timestamp in startTime..endTime) { - return modeData - } - } - throw Exception("No current mode found") - } - - private fun getSeriesMode(timestamp: Long): ModeData { - Splatoon3ApiCache.cachedCompetitiveSeriesModeData.map { modeData -> - val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") - val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") - if (timestamp in startTime..endTime) { - return modeData - } - } - throw Exception("No current mode found") - } - - fun getRegularMapsFormatted(timestamp: Long): String { - val modeData = getRegularMode(timestamp) - val map1 = modeData.map1!!.name.split(" ")[0] - val map2 = modeData.map2!!.name.split(" ")[0] - return "R: $map1 & $map2" - } - - fun getOpenModeFormatted(timestamp: Long): String { - val modeData = getOpenMode(timestamp) - val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") - val diffStamp = TimeUtil.getTimeDifferenceFormatted(System.currentTimeMillis(), endTime) - return "O: ${modeData.ruleSetName} $diffStamp left" - } - - fun getOpenMapFormatted(timestamp: Long): String { - val modeData = getOpenMode(timestamp) - val map1 = modeData.map1!!.name.split(" ")[0] - val map2 = modeData.map2!!.name.split(" ")[0] - return "O: $map1 & $map2" - } - - fun getSeriesModeFormatted(timestamp: Long): String { - val modeData = getSeriesMode(timestamp) - val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") - val diffStamp = TimeUtil.getTimeDifferenceFormatted(System.currentTimeMillis(), endTime) - return "S: ${modeData.ruleSetName} $diffStamp left" - } - - fun getSeriesMapsFormatted(timestamp: Long): String { - val modeData = getSeriesMode(timestamp) - val map1 = modeData.map1!!.name.split(" ")[0] - val map2 = modeData.map2!!.name.split(" ")[0] - return "S: $map1 & $map2" - } - - fun getXModeFormatted(timestamp: Long): String { - val modeData = getXMode(timestamp) - val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") - val diffStamp = TimeUtil.getTimeDifferenceFormatted(System.currentTimeMillis(), endTime) - return "X: ${modeData.ruleSetName} $diffStamp left" - } - - fun getXMapFormatted(timestamp: Long): String { - val modeData = getXMode(timestamp) - val map1 = modeData.map1!!.name.split(" ")[0] - val map2 = modeData.map2!!.name.split(" ")[0] - return "X: $map1 & $map2" - } -} diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3ApiCache.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3ApiCache.kt deleted file mode 100644 index 42ff01c..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3ApiCache.kt +++ /dev/null @@ -1,535 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api - -import io.ktor.http.* -import kotlinx.serialization.json.* -import net.moonleay.botendo.build.BuildConstants -import net.moonleay.lilJudd.data.api.entry.coop.CoopGearData -import net.moonleay.lilJudd.data.api.entry.schedule.* -import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestColor -import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestData -import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestTeamData -import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestTeamResults -import net.moonleay.lilJudd.data.api.entry.splatnet.BrandData -import net.moonleay.lilJudd.data.api.entry.splatnet.GearAbilityData -import net.moonleay.lilJudd.data.api.entry.splatnet.SplatnetItemData -import net.moonleay.lilJudd.data.api.type.ApiDataType -import net.moonleay.lilJudd.data.api.type.ApiRequestType -import net.moonleay.lilJudd.util.Logger -import net.moonleay.lilJudd.util.NetUtil - -object Splatoon3ApiCache { - private val user_agent = - "lilJudd/${BuildConstants.version} (${System.getProperty("os.name")}/${System.getProperty("os.version")}) [contact@moonleay.net]" - private val base_url = "https://splatoon3.ink/data/" // Thank god there is an API - - internal var cachedSplatfestData = mutableListOf() - internal var cachedMapData = mutableMapOf() - internal var cachedRegularModeData = mutableListOf() - internal var cachedCompetitiveSeriesModeData = mutableListOf() - internal var cachedCompetitiveOpenModeData = mutableListOf() - internal var cachedXModeData = mutableListOf() - internal var cachedChallengesData = mutableListOf() - internal var cachedShiftData = mutableListOf() - internal var cachedBigRunShiftData = mutableListOf() - internal var cachedCoopRewardsData = mutableListOf() - internal var cachedSplatnetItemData = mutableListOf() - internal var cachedSplatnetLimitedItemData = mutableListOf() - internal lateinit var splatnetShopBrandData: BrandData - internal lateinit var splatnetShopNextBrandData: BrandData - fun updateData(dataType: ApiDataType, requestType: ApiRequestType) { - Logger.out("Updating data for $dataType with USER-AGENT: $user_agent") - Logger.out("Reason for update: $requestType") - when (dataType) { - ApiDataType.SCHEDULES -> { - updateScheduleCache(user_agent) - } - - ApiDataType.SPLATNETGEAR -> { - updateSplatnetGearCache(user_agent) - } - - ApiDataType.COOP -> { - updateCOOPCache(user_agent) - } - - ApiDataType.SPLATFESTS -> { - updateSplatfestCache(user_agent) - } - - ApiDataType.ALL -> { - updateScheduleCache(user_agent) - updateSplatnetGearCache(user_agent) - updateSplatfestCache(user_agent) - updateCOOPCache(user_agent) - } - } - Logger.out("Finished updating data for $dataType") - } - - private fun updateSplatnetGearCache(uag: String) { - val apiResponse = NetUtil.GETJsonData("${base_url}gear.json", uag) - if (apiResponse.startsWith("Error")) { - Logger.out("Error getting splatnet data: $apiResponse") - return - } - val json = Json.parseToJsonElement(apiResponse) - val pickupBrandData = json.jsonObject["data"]!!.jsonObject["gesotown"]!!.jsonObject["pickupBrand"]!!.jsonObject - - val brand = pickupBrandData["brand"]!!.jsonObject - splatnetShopBrandData = - BrandData( - brand["name"]!!.jsonPrimitive.content, - Url(pickupBrandData["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), - GearAbilityData( - brand["usualGearPower"]!!.jsonObject["name"]!!.jsonPrimitive.content, - brand["usualGearPower"]!!.jsonObject["desc"]!!.jsonPrimitive.content, - Url(brand["usualGearPower"]!!.jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ), - pickupBrandData["saleEndTime"]!!.jsonPrimitive.content - ) - val nextBrand = pickupBrandData["nextBrand"]!!.jsonObject - splatnetShopNextBrandData = - BrandData( - nextBrand["name"]!!.jsonPrimitive.content, - Url(pickupBrandData["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), - null, - null - ) - cachedSplatnetItemData = mutableListOf() - val items = pickupBrandData["brandGears"]!!.jsonArray - items.forEach { - val obj = it as JsonObject - val gear = it["gear"]!!.jsonObject - val primaryGearPower = gear["primaryGearPower"]!!.jsonObject - val additionalGearPowers = gear["additionalGearPowers"]!!.jsonArray - val additionalGearPowersList = mutableListOf() - additionalGearPowers.forEach { - val ob = it as JsonObject - additionalGearPowersList.add( - GearAbilityData( - ob["name"]!!.jsonPrimitive.content, - null, - Url(ob["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ) - ) - } - cachedSplatnetItemData.add( - SplatnetItemData( - obj["saleEndTime"]!!.jsonPrimitive.content, - obj["price"]!!.jsonPrimitive.int, - gear["__typename"]!!.jsonPrimitive.content, - gear["name"]!!.jsonPrimitive.content, - GearAbilityData( - primaryGearPower["name"]!!.jsonPrimitive.content, - null, - Url(primaryGearPower["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ), - additionalGearPowersList, - Url(gear["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), - splatnetShopBrandData - ) - ) - } - Logger.out("Updated gear data") - - val limitedItemData = json.jsonObject["data"]!!.jsonObject["gesotown"]!!.jsonObject["limitedGears"]!!.jsonArray - cachedSplatnetLimitedItemData = mutableListOf() - limitedItemData.forEach { - val obj = it as JsonObject - val gear = obj["gear"]!!.jsonObject - val additionalGearPowers = gear["additionalGearPowers"]!!.jsonArray - val additionalGearPowersList = mutableListOf() - additionalGearPowers.forEach { - val ob = it as JsonObject - additionalGearPowersList.add( - GearAbilityData( - ob["name"]!!.jsonPrimitive.content, - null, - Url(ob["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ) - ) - } - cachedSplatnetLimitedItemData.add( - SplatnetItemData( - obj["saleEndTime"]!!.jsonPrimitive.content, - obj["price"]!!.jsonPrimitive.int, - gear["__typename"]!!.jsonPrimitive.content, - gear["name"]!!.jsonPrimitive.content, - GearAbilityData( - gear["primaryGearPower"]!!.jsonObject["name"]!!.jsonPrimitive.content, - null, - Url(gear["primaryGearPower"]!!.jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ), - additionalGearPowersList, - Url(gear["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), - splatnetShopBrandData - ) - ) - } - } - - private fun updateCOOPCache(uag: String) { - val apiResponse = NetUtil.GETJsonData("${base_url}coop.json", uag) - if (apiResponse.startsWith("Error")) { - Logger.out("Error getting coop data: $apiResponse") - return - } - val json = Json.parseToJsonElement(apiResponse) - val data = json.jsonObject["data"]!!.jsonObject["coopResult"]!!.jsonObject["monthlyGear"]!!.jsonObject - cachedCoopRewardsData = mutableListOf() - cachedCoopRewardsData.add( - CoopGearData( - data["name"]!!.jsonPrimitive.content, - Url(data["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), - data["__typename"]!!.jsonPrimitive.content - ) - ) - Logger.out("Updated COOP data") - } - - private fun updateScheduleCache(uag: String) { - val apiResponse = NetUtil.GETJsonData("${base_url}schedules.json", uag) - if (apiResponse.startsWith("Error")) { - Logger.out("Error getting schedule data: $apiResponse") - return - } - val json = Json.decodeFromString(apiResponse) as JsonObject - val data = json["data"]!!.jsonObject - - val mapList = data["vsStages"]!!.jsonObject["nodes"]!!.jsonArray - cachedMapData = mutableMapOf() - mapList.forEach { - val obj = it as JsonObject - val imageURL = Url(obj.jsonObject["originalImage"]!!.jsonObject["url"]!!.jsonPrimitive.content) - val id = obj.jsonObject["vsStageId"]!!.jsonPrimitive.int - cachedMapData[id] = MapData( - id, - imageURL, - it.jsonObject["name"]!!.jsonPrimitive.content - ) - } - Logger.out("Updated maplist data") - - val regularMatches = data["regularSchedules"]!!.jsonObject["nodes"]!!.jsonArray - cachedRegularModeData = mutableListOf() - regularMatches.forEach { - val obj = it as JsonObject - val setting = obj["regularMatchSetting"]!!.jsonObject - cachedRegularModeData.add( - ModeData( - obj["startTime"]!!.jsonPrimitive.content, - obj["endTime"]!!.jsonPrimitive.content, - setting["__typename"]!!.jsonPrimitive.content, - cachedMapData[setting["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int], - cachedMapData[setting["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int], - setting["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content, - setting["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content, - "TURF_WAR" - ) - ) - } - Logger.out("Updated Regular match data") - - val compMatches = data["bankaraSchedules"]!!.jsonObject["nodes"]!!.jsonArray - cachedCompetitiveSeriesModeData = mutableListOf() - cachedCompetitiveOpenModeData = mutableListOf() - compMatches.forEach { - val obj = it as JsonObject - val setting = obj["bankaraMatchSettings"]!!.jsonArray - setting.forEach { - val ob = it as JsonObject - val mode = ob["bankaraMode"]!!.jsonPrimitive.content - if (mode == "CHALLENGE") { - cachedCompetitiveSeriesModeData.add( - ModeData( - obj["startTime"]!!.jsonPrimitive.content, - obj["endTime"]!!.jsonPrimitive.content, - ob["__typename"]!!.jsonPrimitive.content, - cachedMapData[ob["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int], - cachedMapData[ob["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int], - ob["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content, - ob["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content, - mode - ) - ) - } else if (mode == "OPEN") { - cachedCompetitiveOpenModeData.add( - ModeData( - obj["startTime"]!!.jsonPrimitive.content, - obj["endTime"]!!.jsonPrimitive.content, - ob["__typename"]!!.jsonPrimitive.content, - cachedMapData[ob["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int], - cachedMapData[ob["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int], - ob["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content, - ob["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content, - mode - ) - ) - } - } - } - Logger.out("Updated Competitive match data") - - val xMatches = data["xSchedules"]!!.jsonObject["nodes"]!!.jsonArray - cachedXModeData = mutableListOf() - xMatches.forEach { - val obj = it as JsonObject - val setting = obj["xMatchSetting"]!!.jsonObject - cachedXModeData.add( - ModeData( - obj["startTime"]!!.jsonPrimitive.content, - obj["endTime"]!!.jsonPrimitive.content, - setting["__typename"]!!.jsonPrimitive.content, - cachedMapData[setting["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int], - cachedMapData[setting["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int], - setting["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content, - setting["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content, - "X" - ) - ) - } - Logger.out("Updated X match data") - - val challengeData = data["eventSchedules"]!!.jsonObject["nodes"]!!.jsonArray - cachedChallengesData = mutableListOf() - challengeData.forEach { - val obj = it as JsonObject - val tpd = obj["timePeriods"]!!.jsonArray - val setting = obj["leagueMatchSetting"]!!.jsonObject - val event = setting["leagueMatchEvent"]!!.jsonObject - cachedChallengesData.add( - ChallengeModeData( - event["leagueMatchEventId"]!!.jsonPrimitive.content, - event["name"]!!.jsonPrimitive.content, - event["desc"]!!.jsonPrimitive.content, - event["regulation"]!!.jsonPrimitive.content, - cachedMapData[setting["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int], - cachedMapData[setting["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int], - setting["__typename"]!!.jsonPrimitive.content, - setting["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content, - setting["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content, - TimePeriodData( - tpd[0].jsonObject["startTime"]!!.jsonPrimitive.content, - tpd[0].jsonObject["endTime"]!!.jsonPrimitive.content - ), - TimePeriodData( - tpd[1].jsonObject["startTime"]!!.jsonPrimitive.content, - tpd[1].jsonObject["endTime"]!!.jsonPrimitive.content - ), - TimePeriodData( - tpd[2].jsonObject["startTime"]!!.jsonPrimitive.content, - tpd[2].jsonObject["endTime"]!!.jsonPrimitive.content - ) - ) - ) - } - Logger.out("Updated Challenge data") - - val shiftData = data["coopGroupingSchedule"]!!.jsonObject["regularSchedules"]!!.jsonObject["nodes"]!!.jsonArray - cachedShiftData = mutableListOf() - shiftData.forEach { - val obj = it as JsonObject - val setting = obj["setting"]!!.jsonObject - val stage = setting["coopStage"]!!.jsonObject - val weapons = setting["weapons"]!!.jsonArray - cachedShiftData.add( - ShiftData( - obj["startTime"]!!.jsonPrimitive.content, - obj["endTime"]!!.jsonPrimitive.content, - obj["__splatoon3ink_king_salmonid_guess"]!!.jsonPrimitive.content, - setting["__typename"]!!.jsonPrimitive.content, - stage["name"]!!.jsonPrimitive.content, - Url(stage["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), - WeaponData( - weapons[0].jsonObject["name"]!!.jsonPrimitive.content, - Url(weapons[0].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ), - WeaponData( - weapons[1].jsonObject["name"]!!.jsonPrimitive.content, - Url(weapons[1].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ), - WeaponData( - weapons[2].jsonObject["name"]!!.jsonPrimitive.content, - Url(weapons[2].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ), - WeaponData( - weapons[3].jsonObject["name"]!!.jsonPrimitive.content, - Url(weapons[3].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ) - ) - ) - } - - val bigRunData = data["coopGroupingSchedule"]!!.jsonObject["bigRunSchedules"]!!.jsonObject["nodes"]!!.jsonArray - cachedBigRunShiftData = mutableListOf() - bigRunData.forEach { - val obj = it as JsonObject - val setting = obj["setting"]!!.jsonObject - val stage = setting["coopStage"]!!.jsonObject - val weapons = setting["weapons"]!!.jsonArray - cachedBigRunShiftData.add( - ShiftData( - obj["startTime"]!!.jsonPrimitive.content, - obj["endTime"]!!.jsonPrimitive.content, - obj["__splatoon3ink_king_salmonid_guess"]!!.jsonPrimitive.content, - setting["__typename"]!!.jsonPrimitive.content, - stage["name"]!!.jsonPrimitive.content, - Url(stage["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), - WeaponData( - weapons[0].jsonObject["name"]!!.jsonPrimitive.content, - Url(weapons[0].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ), - WeaponData( - weapons[1].jsonObject["name"]!!.jsonPrimitive.content, - Url(weapons[1].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ), - WeaponData( - weapons[2].jsonObject["name"]!!.jsonPrimitive.content, - Url(weapons[2].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ), - WeaponData( - weapons[3].jsonObject["name"]!!.jsonPrimitive.content, - Url(weapons[3].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) - ) - ) - ) - } - Logger.out("Updated big run data") - - Logger.out("Updated all Schedules") - } - - private fun updateSplatfestCache(uag: String) { - val apiResponse = NetUtil.GETJsonData("${base_url}festivals.json", uag) - if (apiResponse.startsWith("Error")) { - Logger.out("Error getting splatfest data: $apiResponse") - return - } - val json = Json.decodeFromString(apiResponse) as JsonObject - val festivals = json["US"]!!.jsonObject["data"]!!.jsonObject["festRecords"]!!.jsonObject["nodes"]!!.jsonArray - cachedSplatfestData = mutableListOf() - festivals.forEach { - val fest = it as JsonObject - val teams = fest.jsonObject["teams"]!!.jsonArray - val team1 = teams[0].jsonObject - val team1Color = team1["color"]!!.jsonObject - var team1Result: JsonObject? = null - if (team1["result"] !is JsonNull) { - team1Result = team1["result"]!!.jsonObject - } - val team2 = teams[1].jsonObject - val team2Color = team2["color"]!!.jsonObject - var team2Result: JsonObject? = null - if (team2["result"] !is JsonNull) { - team2Result = team2["result"]!!.jsonObject - } - val team3 = teams[2].jsonObject - val team3Color = team3["color"]!!.jsonObject - var team3Result: JsonObject? = null - if (team3["result"] !is JsonNull) { - team3Result = team3["result"]!!.jsonObject - } - cachedSplatfestData.add( - SplatfestData( - fest.jsonObject["id"]!!.jsonPrimitive.content, - fest.jsonObject["state"]!!.jsonPrimitive.content, - fest.jsonObject["startTime"]!!.jsonPrimitive.content, - fest.jsonObject["endTime"]!!.jsonPrimitive.content, - fest.jsonObject["title"]!!.jsonPrimitive.content, - Url(fest.jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), - SplatfestTeamData( - team1["teamName"]!!.jsonPrimitive.content, - SplatfestColor( - team1Color["a"]!!.jsonPrimitive.int, - team1Color["b"]!!.jsonPrimitive.double, - team1Color["g"]!!.jsonPrimitive.double, - team1Color["r"]!!.jsonPrimitive.double - ), - if (team1Result.isNullOrEmpty() || team1Result["tricolorContributionRatio"]!!.jsonPrimitive.doubleOrNull == null) - null - else SplatfestTeamResults( - team1Result["isWinner"]!!.jsonPrimitive.boolean, - team1Result["horagaiRatio"]!!.jsonPrimitive.double, - team1Result["isHoragaiRatioTop"]!!.jsonPrimitive.boolean, - team1Result["voteRatio"]!!.jsonPrimitive.double, - team1Result["isVoteRatioTop"]!!.jsonPrimitive.boolean, - team1Result["regularContributionRatio"]!!.jsonPrimitive.double, - team1Result["isRegularContributionRatioTop"]!!.jsonPrimitive.boolean, - team1Result["challengeContributionRatio"]!!.jsonPrimitive.double, - team1Result["isChallengeContributionRatioTop"]!!.jsonPrimitive.boolean, - team1Result["tricolorContributionRatio"]!!.jsonPrimitive.double, - team1Result["isTricolorContributionRatioTop"]!!.jsonPrimitive.boolean, - ) - ), - SplatfestTeamData( - team2["teamName"]!!.jsonPrimitive.content, - SplatfestColor( - team2Color["a"]!!.jsonPrimitive.int, - team2Color["b"]!!.jsonPrimitive.double, - team2Color["g"]!!.jsonPrimitive.double, - team2Color["r"]!!.jsonPrimitive.double - ), - if (team2Result.isNullOrEmpty() || team2Result["tricolorContributionRatio"]!!.jsonPrimitive.doubleOrNull == null) - null - else SplatfestTeamResults( - team2Result["isWinner"]!!.jsonPrimitive.boolean, - team2Result["horagaiRatio"]!!.jsonPrimitive.double, - team2Result["isHoragaiRatioTop"]!!.jsonPrimitive.boolean, - team2Result["voteRatio"]!!.jsonPrimitive.double, - team2Result["isVoteRatioTop"]!!.jsonPrimitive.boolean, - team2Result["regularContributionRatio"]!!.jsonPrimitive.double, - team2Result["isRegularContributionRatioTop"]!!.jsonPrimitive.boolean, - team2Result["challengeContributionRatio"]!!.jsonPrimitive.double, - team2Result["isChallengeContributionRatioTop"]!!.jsonPrimitive.boolean, - team2Result["tricolorContributionRatio"]!!.jsonPrimitive.double, - team2Result["isTricolorContributionRatioTop"]!!.jsonPrimitive.boolean, - ) - ), - SplatfestTeamData( - team3["teamName"]!!.jsonPrimitive.content, - SplatfestColor( - team3Color["a"]!!.jsonPrimitive.int, - team3Color["b"]!!.jsonPrimitive.double, - team3Color["g"]!!.jsonPrimitive.double, - team3Color["r"]!!.jsonPrimitive.double - ), - if (team3Result.isNullOrEmpty() || team3Result["tricolorContributionRatio"]!!.jsonPrimitive.doubleOrNull == null) - null - else SplatfestTeamResults( - team3Result["isWinner"]!!.jsonPrimitive.boolean, - team3Result["horagaiRatio"]!!.jsonPrimitive.double, - team3Result["isHoragaiRatioTop"]!!.jsonPrimitive.boolean, - team3Result["voteRatio"]!!.jsonPrimitive.double, - team3Result["isVoteRatioTop"]!!.jsonPrimitive.boolean, - team3Result["regularContributionRatio"]!!.jsonPrimitive.double, - team3Result["isRegularContributionRatioTop"]!!.jsonPrimitive.boolean, - team3Result["challengeContributionRatio"]!!.jsonPrimitive.double, - team3Result["isChallengeContributionRatioTop"]!!.jsonPrimitive.boolean, - team3Result["tricolorContributionRatio"]!!.jsonPrimitive.double, - team3Result["isTricolorContributionRatioTop"]!!.jsonPrimitive.boolean, - ) - ), - ) - ) - } - Logger.out("Updated Splatfest data") - } -} diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/coop/CoopGearData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/coop/CoopGearData.kt deleted file mode 100644 index 4f46642..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/coop/CoopGearData.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.coop - -import io.ktor.http.* - -data class CoopGearData( - val name: String, - val image: Url, - val __typename: String, - - ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ChallengeModeData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ChallengeModeData.kt deleted file mode 100644 index c288fe9..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ChallengeModeData.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.schedule - -data class ChallengeModeData( - val leagueMatchEventId: String, - val name: String, - val description: String, - val regulation: String, - val map1: MapData?, - val map2: MapData?, - val __typename: String, - val ruleSet: String, - val ruleSetName: String, - val timePeriod1: TimePeriodData, - val timePeriod2: TimePeriodData, - val timePeriod3: TimePeriodData, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/MapData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/MapData.kt deleted file mode 100644 index 422783c..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/MapData.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.schedule - -import io.ktor.http.* - -data class MapData( - val stageID: Int, - val image: Url, - val name: String, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ModeData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ModeData.kt deleted file mode 100644 index 8295a1a..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ModeData.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.schedule - -data class ModeData( - val startTime: String, - val endTime: String, - val matchType: String, - val map1: MapData?, - val map2: MapData?, - val ruleSetName: String, - val ruleSet: String, - val mode: String, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ShiftData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ShiftData.kt deleted file mode 100644 index a4d28ae..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ShiftData.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.schedule - -import io.ktor.http.* - -data class ShiftData( - val startTime: String, - val endTime: String, - val __splatoon3ink_king_salmonid_guess: String, - val __typename: String, - val stageName: String, - val image: Url, - val weapon1: WeaponData, - val weapon2: WeaponData, - val weapon3: WeaponData, - val weapon4: WeaponData, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/TimePeriodData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/TimePeriodData.kt deleted file mode 100644 index 53edb96..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/TimePeriodData.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.schedule - -data class TimePeriodData( - val startTime: String, - val endTime: String, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/WeaponData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/WeaponData.kt deleted file mode 100644 index 997a24b..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/WeaponData.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.schedule - -import io.ktor.http.* - -data class WeaponData( - val name: String, - val image: Url, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestColor.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestColor.kt deleted file mode 100644 index 391ccb3..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestColor.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.splatfest - -data class SplatfestColor( - val a: Int, - val b: Double, - val g: Double, - val r: Double, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestData.kt deleted file mode 100644 index f52b9b4..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestData.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.splatfest - -import io.ktor.http.* - -data class SplatfestData( - val id: String, - val state: String, - val startTime: String, - val endTime: String, - val title: String, - val image: Url, - val team1: SplatfestTeamData, - val team2: SplatfestTeamData, - val team3: SplatfestTeamData, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamData.kt deleted file mode 100644 index 9ea2e72..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamData.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.splatfest - -data class SplatfestTeamData( - val teamName: String, - val color: SplatfestColor, - val results: SplatfestTeamResults?, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamResults.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamResults.kt deleted file mode 100644 index 4888adc..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamResults.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.splatfest - -data class SplatfestTeamResults( - val isWinner: Boolean, - val horagaiRatio: Double, - val horagaiRatioTop: Boolean, - val voteRatio: Double, - val voteRatioTop: Boolean, - val regularRatio: Double, - val regularRatioTop: Boolean, - val challengeRatio: Double, - val challengeRatioTop: Boolean, - val tricolorRatio: Double, - val tricolorRatioTop: Boolean, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/BrandData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/BrandData.kt deleted file mode 100644 index 6781172..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/BrandData.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.splatnet - -import io.ktor.http.* - -data class BrandData( - val name: String, - val image: Url, - val usualGearPower: GearAbilityData?, - val saleEndTime: String?, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/GearAbilityData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/GearAbilityData.kt deleted file mode 100644 index 713d946..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/GearAbilityData.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.splatnet - -import io.ktor.http.* - -data class GearAbilityData( - val name: String, - val description: String?, - val image: Url, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/SplatnetItemData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/SplatnetItemData.kt deleted file mode 100644 index 43df20b..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/SplatnetItemData.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.entry.splatnet - -import io.ktor.http.* - -data class SplatnetItemData( - val saleEndTime: String, - val price: Int, - val typeName: String, - val name: String, - val primaryGearPower: GearAbilityData, - val additionalGearPowers: List, - val image: Url, - val brand: BrandData, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiDataType.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiDataType.kt deleted file mode 100644 index 7123b0d..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiDataType.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.type - -enum class ApiDataType { - SCHEDULES, - SPLATNETGEAR, - COOP, - SPLATFESTS, - ALL -} diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiRequestType.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiRequestType.kt deleted file mode 100644 index da20371..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiRequestType.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.api.type - -enum class ApiRequestType(val nameToDisplay: String) { - AUTOMATIC_CACHE_UPDATE("automatic request to update the cache"), - AUTOMATIC_CACHE_CREATION_AT_STARTUP("automatic request to create cache at startup"), - MANUAL("manual request"), - DEBUG("debug request") -} diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/MatchPlanningDataData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/entry/MatchPlanningDataData.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt index b19c5e7..f48dc28 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/MatchPlanningDataData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database.entry +package net.moonleay.lilJudd.data.entry data class MatchPlanningDataData( val id: Int, diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/PlanningNotifierRolesData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/entry/PlanningNotifierRolesData.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt index c58130a..730e7fe 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/PlanningNotifierRolesData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database.entry +package net.moonleay.lilJudd.data.entry data class PlanningNotifierRolesData( val id: Int, // The id of the entry diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/TimePlanningChannelsData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt similarity index 94% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/entry/TimePlanningChannelsData.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt index 7edd496..fba9898 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/TimePlanningChannelsData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database.entry +package net.moonleay.lilJudd.data.entry data class TimePlanningChannelsData( val id: Int, diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/TimePlanningMessagesData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/entry/TimePlanningMessagesData.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt index 3126e2c..fcb283b 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/TimePlanningMessagesData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database.entry +package net.moonleay.lilJudd.data.entry data class TimePlanningMessagesData( val id: Int, // The id of the entry diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/MatchPlanningDataRepository.kt b/src/main/kotlin/net/moonleay/lilJudd/data/repository/MatchPlanningDataRepository.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/repository/MatchPlanningDataRepository.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/repository/MatchPlanningDataRepository.kt index 84a1e66..385eb69 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/MatchPlanningDataRepository.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/repository/MatchPlanningDataRepository.kt @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database.repository +package net.moonleay.lilJudd.data.repository -import net.moonleay.lilJudd.data.database.entry.MatchPlanningDataData -import net.moonleay.lilJudd.data.database.tables.MatchPlanningData +import net.moonleay.lilJudd.data.entry.MatchPlanningDataData +import net.moonleay.lilJudd.data.tables.MatchPlanningData import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.transactions.transaction diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/PlanningNotifierRolesRepository.kt b/src/main/kotlin/net/moonleay/lilJudd/data/repository/PlanningNotifierRolesRepository.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/repository/PlanningNotifierRolesRepository.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/repository/PlanningNotifierRolesRepository.kt index 4059e70..2603081 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/PlanningNotifierRolesRepository.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/repository/PlanningNotifierRolesRepository.kt @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database.repository +package net.moonleay.lilJudd.data.repository -import net.moonleay.lilJudd.data.database.entry.PlanningNotifierRolesData -import net.moonleay.lilJudd.data.database.tables.PlanningNotifierRoles +import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData +import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.transactions.transaction diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/TimePlanningChannelsRepository.kt b/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningChannelsRepository.kt similarity index 92% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/repository/TimePlanningChannelsRepository.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningChannelsRepository.kt index f5fd171..7756802 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/TimePlanningChannelsRepository.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningChannelsRepository.kt @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database.repository +package net.moonleay.lilJudd.data.repository -import net.moonleay.lilJudd.data.database.entry.TimePlanningChannelsData -import net.moonleay.lilJudd.data.database.tables.TimePlanningChannels +import net.moonleay.lilJudd.data.entry.TimePlanningChannelsData +import net.moonleay.lilJudd.data.tables.TimePlanningChannels import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.transactions.transaction diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/TimePlanningMessagesRepository.kt b/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningMessagesRepository.kt similarity index 93% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/repository/TimePlanningMessagesRepository.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningMessagesRepository.kt index 780a939..5e2f273 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/TimePlanningMessagesRepository.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningMessagesRepository.kt @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database.repository +package net.moonleay.lilJudd.data.repository -import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData -import net.moonleay.lilJudd.data.database.tables.TimePlanningMessages +import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData +import net.moonleay.lilJudd.data.tables.TimePlanningMessages import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.select diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/MatchPlanningData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/tables/MatchPlanningData.kt similarity index 96% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/tables/MatchPlanningData.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/tables/MatchPlanningData.kt index 391b3e8..e2e8afa 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/MatchPlanningData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/tables/MatchPlanningData.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database.tables +package net.moonleay.lilJudd.data.tables import org.jetbrains.exposed.sql.Table diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/PlanningNotifierRoles.kt b/src/main/kotlin/net/moonleay/lilJudd/data/tables/PlanningNotifierRoles.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/tables/PlanningNotifierRoles.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/tables/PlanningNotifierRoles.kt index 66fe906..e2fc9e0 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/PlanningNotifierRoles.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/tables/PlanningNotifierRoles.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database.tables +package net.moonleay.lilJudd.data.tables import org.jetbrains.exposed.sql.Table diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/TimePlanningChannels.kt b/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningChannels.kt similarity index 94% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/tables/TimePlanningChannels.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningChannels.kt index d3b31e3..a521838 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/TimePlanningChannels.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningChannels.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database.tables +package net.moonleay.lilJudd.data.tables import org.jetbrains.exposed.sql.Table diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/TimePlanningMessages.kt b/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningMessages.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/database/tables/TimePlanningMessages.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningMessages.kt index dd48838..8f8a01b 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/TimePlanningMessages.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningMessages.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.database.tables +package net.moonleay.lilJudd.data.tables import org.jetbrains.exposed.sql.Table diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt index 9f2674d..17592e6 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt @@ -28,8 +28,8 @@ import com.kotlindiscord.kord.extensions.types.respond import dev.kord.core.behavior.channel.createMessage import dev.kord.core.behavior.createRole import dev.kord.rest.builder.message.create.actionRow -import net.moonleay.lilJudd.data.database.entry.MatchPlanningDataData -import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository +import net.moonleay.lilJudd.data.entry.MatchPlanningDataData +import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.extensions.component.MatchTypes import net.moonleay.lilJudd.jobs.MatchJob import net.moonleay.lilJudd.jobs.component.JobManager diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt index 781de2c..ee85372 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt @@ -26,8 +26,8 @@ import dev.kord.common.entity.Permission import dev.kord.core.behavior.channel.createMessage import dev.kord.rest.builder.message.create.actionRow import kotlinx.coroutines.delay -import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData -import net.moonleay.lilJudd.data.database.repository.TimePlanningMessagesRepository +import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData +import net.moonleay.lilJudd.data.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.util.* import java.time.ZoneId import java.time.ZonedDateTime @@ -105,7 +105,7 @@ class SendPlannerExtension : Extension() { -1, c.data.guildId.value?.value!!.toLong(), c.id.value.toLong(), - (TimeUtil.getWeekStamp().toEpochSecond()), + (TimeUtil.getWeekStamp().toEpochSecond() * 1000), msgStr ) ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/InfoExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/VersionExtension.kt similarity index 89% rename from src/main/kotlin/net/moonleay/lilJudd/extensions/InfoExtension.kt rename to src/main/kotlin/net/moonleay/lilJudd/extensions/VersionExtension.kt index ff5a61a..3554f72 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/InfoExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/VersionExtension.kt @@ -24,11 +24,11 @@ import net.moonleay.botendo.build.BuildConstants import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.MessageUtil -class InfoExtension : Extension() { - override val name = "info" +class VersionExtension : Extension() { + override val name = "version" override suspend fun setup() { publicSlashCommand { - name = "info" + name = "version" description = "Show infos about the bot" this.action { MessageUtil.sendEmbedForPublicSlashCommand( @@ -38,8 +38,7 @@ class InfoExtension : Extension() { "Lil' Judd ***v." + BuildConstants.version + "***\n" + "Kord-Extensions ***v." + BuildConstants.kordVersion + "***\n" + "Coroutines ***v." + BuildConstants.coroutinesVersion + "***\n" + - "Krontab ***v." + BuildConstants.krontabVersion + "***\n\n" + - "Splatoon 3 api data provided by splatoon3.ink" + "Krontab ***v." + BuildConstants.krontabVersion + "***" ) } } diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt index cc49d1c..df88ee1 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt @@ -30,10 +30,10 @@ import dev.kord.core.entity.channel.MessageChannel import dev.kord.gateway.PrivilegedIntent import dev.kord.rest.builder.message.EmbedBuilder import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.data.database.entry.PlanningNotifierRolesData -import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData -import net.moonleay.lilJudd.data.database.repository.PlanningNotifierRolesRepository -import net.moonleay.lilJudd.data.database.repository.TimePlanningMessagesRepository +import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData +import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData +import net.moonleay.lilJudd.data.repository.PlanningNotifierRolesRepository +import net.moonleay.lilJudd.data.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.extensions.FeatureManageExtension import net.moonleay.lilJudd.features.component.FeatureEnum import net.moonleay.lilJudd.features.component.IFeature @@ -47,21 +47,18 @@ object AvailabilityManager : IFeature { Logger.out("Starting to update roles...") // ChannelID, Data - val messages = TimePlanningMessagesRepository.getWeek(TimeUtil.getWeekStamp().toEpochSecond()) + val messages = TimePlanningMessagesRepository.getWeek(TimeUtil.getWeekStamp().toEpochSecond() * 1000) .associateBy { it.channelID } val targetedRoles = PlanningNotifierRolesRepository.getAll().associateBy { it.channelID } - if (targetedRoles.isEmpty()) { - Logger.out("No saved roles. Canceling.") - return - } for (id in messages.keys) { val snf = Snowflake(id) // snf = Snowflake val data = messages[id]!! // this is the data of the table - if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) { - // This channel does not exist anymore. - Logger.out("Warning: Channel ${data.channelID} does not exist anymore. Skipping.") - continue + if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) + continue // This channel does not exist anymore. + if (targetedRoles.isEmpty()) { + Logger.out("No saved roles. Canceling.") + return } val roleData = targetedRoles[data.channelID] // Get the role data if (roleData == null) { @@ -74,17 +71,15 @@ object AvailabilityManager : IFeature { } suspend fun updateInChannel(snf: Snowflake) { - val stamp = TimeUtil.getWeekStamp().toEpochSecond() - Logger.out("Weekstamp: $stamp") val messageData = TimePlanningMessagesRepository.getWeekInChannel( - stamp, + TimeUtil.getWeekStamp().toEpochSecond() * 1000, snf.value.toLong() ) + val roleData = PlanningNotifierRolesRepository.getForChannel(snf.value.toLong()) if (messageData == null) { Logger.out("Could not find data for channel ${snf.value}") return } - val roleData = PlanningNotifierRolesRepository.getForChannel(snf.value.toLong()) if (roleData == null) { Logger.out("Role for channel ${messageData.channelID} does not exist") return // this took way to long to find out that this was the issue @@ -98,7 +93,7 @@ object AvailabilityManager : IFeature { return // This channel does not exist anymore. val c = Bot.bot.kordRef.getChannelOf(snf)!! // Get the channel as MessageChannel val weekday = ZonedDateTime.now().dayOfWeek // The current week day - val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() // The current week time stamp + val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() * 1000 // The current week time stamp Logger.out("It is week ${weekStamp} and day ${weekday}/${TimeUtil.getDayOfMonthInt(weekday)} of the week.") val g = Bot.bot.kordRef.getGuild(Snowflake(tpmd.serverID)) // Get all members with the role diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt index 129fdc0..fc89dc9 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt @@ -20,8 +20,8 @@ package net.moonleay.lilJudd.features import dev.kord.common.entity.Snowflake import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.data.database.entry.MatchPlanningDataData -import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository +import net.moonleay.lilJudd.data.entry.MatchPlanningDataData +import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.jobs.MatchJob import net.moonleay.lilJudd.jobs.component.JobManager import net.moonleay.lilJudd.util.Logger diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt index ec073ac..d986440 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt @@ -29,11 +29,11 @@ import dev.kord.rest.builder.message.EmbedBuilder import dev.kord.rest.builder.message.create.actionRow import kotlinx.coroutines.delay import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.data.database.entry.TimePlanningChannelsData -import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData -import net.moonleay.lilJudd.data.database.repository.PlanningNotifierRolesRepository -import net.moonleay.lilJudd.data.database.repository.TimePlanningChannelsRepository -import net.moonleay.lilJudd.data.database.repository.TimePlanningMessagesRepository +import net.moonleay.lilJudd.data.entry.TimePlanningChannelsData +import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData +import net.moonleay.lilJudd.data.repository.PlanningNotifierRolesRepository +import net.moonleay.lilJudd.data.repository.TimePlanningChannelsRepository +import net.moonleay.lilJudd.data.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.extensions.FeatureManageExtension import net.moonleay.lilJudd.features.component.FeatureEnum import net.moonleay.lilJudd.features.component.IFeature diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt index 6f13dfa..8360f62 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt @@ -22,7 +22,7 @@ import dev.inmo.krontab.KronScheduler import dev.kord.common.entity.Snowflake import kotlinx.coroutines.Job import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository +import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.jobs.component.CronjobType import net.moonleay.lilJudd.jobs.component.ICronjob import net.moonleay.lilJudd.jobs.component.JobManager diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiFestivalAndCoopUpdateScheduler.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiFestivalAndCoopUpdateScheduler.kt deleted file mode 100644 index ff299fc..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiFestivalAndCoopUpdateScheduler.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.jobs - -import dev.inmo.krontab.KronScheduler -import kotlinx.coroutines.Job -import net.moonleay.lilJudd.data.api.Splatoon3ApiCache -import net.moonleay.lilJudd.data.api.type.ApiDataType -import net.moonleay.lilJudd.data.api.type.ApiRequestType -import net.moonleay.lilJudd.jobs.component.CronjobType -import net.moonleay.lilJudd.jobs.component.ICronjob -import net.moonleay.lilJudd.util.Logger - -object Splatoon3ApiFestivalAndCoopUpdateScheduler : ICronjob { - override val jobName: String - get() = "Splatoon3ApiFestivalAndCoopUpdateScheduler" - override val jobIncoming: String - get() = "0 0 0 /1 * * 0o *" // once a day - override val jobType: CronjobType - get() = CronjobType.INFINITE - override val continueJob: Boolean - get() = true - override lateinit var cronjobJob: Job - override lateinit var scheduler: KronScheduler - - override suspend fun jobFunction() { - Logger.out("Running Splatoon3ApiFestivalUpdateScheduler.") - Splatoon3ApiCache.updateData(ApiDataType.SPLATFESTS, ApiRequestType.AUTOMATIC_CACHE_UPDATE) - Logger.out("Splatoon3ApiFestivalUpdateScheduler finished.") - Logger.out("Running Splatoon3ApiCoopUpdateScheduler.") - Splatoon3ApiCache.updateData(ApiDataType.COOP, ApiRequestType.AUTOMATIC_CACHE_UPDATE) - Logger.out("Splatoon3ApiCoopUpdateScheduler finished.") - } -} diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt deleted file mode 100644 index 5c38b15..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.jobs - -import dev.inmo.krontab.KronScheduler -import kotlinx.coroutines.Job -import net.moonleay.lilJudd.data.api.Splatoon3ApiCache -import net.moonleay.lilJudd.data.api.type.ApiDataType -import net.moonleay.lilJudd.data.api.type.ApiRequestType -import net.moonleay.lilJudd.jobs.component.CronjobType -import net.moonleay.lilJudd.jobs.component.ICronjob -import net.moonleay.lilJudd.util.Logger - -object Splatoon3ApiScheduleUpdateScheduler : ICronjob { - override val jobName: String - get() = "Splatoon3ApiScheduleUpdateScheduler" - override val jobIncoming: String - get() = "0 0 /1 * * * 0o *" //Every hour - override val jobType: CronjobType - get() = CronjobType.INFINITE - override val continueJob: Boolean - get() = true - override lateinit var cronjobJob: Job - override lateinit var scheduler: KronScheduler - - override suspend fun jobFunction() { - Logger.out("Running Splatoon3ApiScheduleUpdateScheduler.") - Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_UPDATE) - Logger.out("Splatoon3ApiScheduleUpdateScheduler finished.") - } -} diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiSplatnetGearUpdateScheduler.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiSplatnetGearUpdateScheduler.kt deleted file mode 100644 index 51048f2..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiSplatnetGearUpdateScheduler.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.jobs - -import dev.inmo.krontab.KronScheduler -import kotlinx.coroutines.Job -import net.moonleay.lilJudd.data.api.Splatoon3ApiCache -import net.moonleay.lilJudd.data.api.type.ApiDataType -import net.moonleay.lilJudd.data.api.type.ApiRequestType -import net.moonleay.lilJudd.jobs.component.CronjobType -import net.moonleay.lilJudd.jobs.component.ICronjob -import net.moonleay.lilJudd.util.Logger - -object Splatoon3ApiSplatnetGearUpdateScheduler : ICronjob { - override val jobName: String - get() = "Splatoon3ApiSplatnetGearUpdateScheduler" - override val jobIncoming: String - get() = "0 0 /6 * * * 0o *" //Every 6 hours - override val jobType: CronjobType - get() = CronjobType.INFINITE - override val continueJob: Boolean - get() = true - override lateinit var cronjobJob: Job - override lateinit var scheduler: KronScheduler - - override suspend fun jobFunction() { - Logger.out("Running Splatoon3ApiSplatnetGearUpdateScheduler.") - Splatoon3ApiCache.updateData(ApiDataType.SPLATNETGEAR, ApiRequestType.AUTOMATIC_CACHE_UPDATE) - Logger.out("Splatoon3ApiSplatnetGearUpdateScheduler finished.") - } -} diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt deleted file mode 100644 index 7df554b..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt +++ /dev/null @@ -1,67 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.jobs - -import dev.inmo.krontab.KronScheduler -import dev.kord.common.entity.PresenceStatus -import kotlinx.coroutines.Job -import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.data.api.Splatoon3Api -import net.moonleay.lilJudd.jobs.component.CronjobType -import net.moonleay.lilJudd.jobs.component.ICronjob - -object StatusUpdater : ICronjob { - override val jobName: String - get() = "StatusUpdater" - override val jobIncoming: String - get() = "/5 * * * * * 0o *" //Every 5 seconds - override val jobType: CronjobType - get() = CronjobType.INFINITE - override val continueJob: Boolean - get() = true - override lateinit var cronjobJob: Job - override lateinit var scheduler: KronScheduler - - private var statusList = listOf() - private var index = 0 - - override suspend fun jobFunction() { - refreshStatusList(System.currentTimeMillis()) - Bot.bot.kordRef.editPresence { - this.status = PresenceStatus.DoNotDisturb - this.playing(statusList[index]) - } - ++index - if (index >= statusList.size) { - index = 0 - } - } - - fun refreshStatusList(timestamp: Long) { - statusList = listOf( - Splatoon3Api.getRegularMapsFormatted(timestamp), - Splatoon3Api.getSeriesModeFormatted(timestamp), - Splatoon3Api.getSeriesMapsFormatted(timestamp), - Splatoon3Api.getOpenModeFormatted(timestamp), - Splatoon3Api.getOpenMapFormatted(timestamp), - Splatoon3Api.getXModeFormatted(timestamp), - Splatoon3Api.getXMapFormatted(timestamp), - ) - } -} diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/NetUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/NetUtil.kt deleted file mode 100644 index 5b43bbc..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/util/NetUtil.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.util - -import java.net.URL -import javax.net.ssl.HttpsURLConnection - -object NetUtil { - fun GETJsonData(urlIN: String, userAgent: String): String { - val startTime = System.currentTimeMillis() - val url = URL(urlIN) - val connection = url.openConnection() as HttpsURLConnection - connection.requestMethod = "GET" - connection.setRequestProperty("User-Agent", userAgent) - connection.setRequestProperty("Accept", "application/json") - val responseCode = connection.responseCode - val timeDiff = System.currentTimeMillis() - startTime - Logger.out("GET took $timeDiff ms (from: $urlIN, as $userAgent)") - return if (responseCode == HttpsURLConnection.HTTP_OK) { - val inputStream = connection.inputStream - val inputStreamReader = inputStream.reader() - val inputAsString = inputStreamReader.readText() - inputStream.close() - inputAsString - } else { - "Error $responseCode" - } - } -} diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/TimeUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/TimeUtil.kt index 5287bc3..c3c3e54 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/util/TimeUtil.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/util/TimeUtil.kt @@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit object TimeUtil { - fun getTimeFormatedShortend(time2: Long, showS: Boolean): String { + fun getTimeFormatedShortend(time2: Long): String { var time = time2 val days: Long = TimeUnit.MILLISECONDS .toDays(time) @@ -52,7 +52,7 @@ object TimeUtil { if (minutes >= 1) { s += minutes.toString() + "m " } - if (seconds >= 1 && hours < 1 && showS) { + if (seconds >= 1 && hours < 1) { s += seconds.toString() + "s" } if (s.isEmpty() || s.isBlank()) { @@ -158,17 +158,4 @@ object TimeUtil { val zdt_ = zdt.minusHours(1) return "0 ${zdt_.minute} ${zdt_.hour} ${zdt_.dayOfMonth - 1} ${zdt_.month.value - 1} ${zdt_.year}"// 0o *w" } - - fun deformatJSONTime(inp: String, zone: String): Long { - // 2023-10-05T08:00:00Z - val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'") - val localDateTime = LocalDateTime.parse(inp, formatter) - val zoneId = ZoneId.of(zone) // TODO: Add the possibility to set your timezone - return ZonedDateTime.of(localDateTime, zoneId).toEpochSecond() * 1000 - } - - fun getTimeDifferenceFormatted(start: Long, end: Long): String { - val diff = end - start - return getTimeFormatedShortend(diff, false) - } }