diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 35ef6bc..48ebe24 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,13 +12,14 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - - uses: MineInAbyss/publish-action@master + - uses: MineInAbyss/publish-action@develop with: maven-metadata-url: https://repo.mineinabyss.com/releases/com/mineinabyss/emojy/maven-metadata.xml - pages-path: build/dokka/htmlMultiModule/ - dokka: dokkaHtmlMultiModule + maven-snapshot-metadata-url: https://repo.mineinabyss.com/snapshots/com/mineinabyss/emojy/maven-metadata.xml maven-username: ${{ secrets.MAVEN_PUBLISH_USERNAME }} maven-password: ${{ secrets.MAVEN_PUBLISH_PASSWORD }} release-files: | diff --git a/build.gradle.kts b/build.gradle.kts index 142244f..76f4b00 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,11 +27,11 @@ allprojects { dependencies { // MineInAbyss platform - compileOnly(libs.bundles.idofront.core) - compileOnly(libs.kotlinx.serialization.json) - compileOnly(libs.kotlinx.serialization.kaml) - compileOnly(libs.kotlinx.coroutines) - compileOnly(libs.minecraft.mccoroutine) + compileOnly(idofrontLibs.bundles.idofront.core) + compileOnly(idofrontLibs.kotlinx.serialization.json) + compileOnly(idofrontLibs.kotlinx.serialization.kaml) + compileOnly(idofrontLibs.kotlinx.coroutines) + compileOnly(idofrontLibs.minecraft.mccoroutine) // Shaded paperweight.paperDevBundle("1.20.4-R0.1-SNAPSHOT") //NMS diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 9920f3f..1956639 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -2,7 +2,7 @@ plugins { id("com.mineinabyss.conventions.kotlin.jvm") id("com.mineinabyss.conventions.papermc") id("com.mineinabyss.conventions.autoversion") - alias(libs.plugins.kotlinx.serialization) + alias(idofrontLibs.plugins.kotlinx.serialization) } repositories { @@ -15,14 +15,14 @@ repositories { dependencies { // MineInAbyss platform - compileOnly(libs.bundles.idofront.core) - compileOnly(libs.kotlinx.serialization.json) - compileOnly(libs.kotlinx.serialization.kaml) - compileOnly(libs.kotlinx.coroutines) - compileOnly(libs.minecraft.mccoroutine) + compileOnly(idofrontLibs.bundles.idofront.core) + compileOnly(idofrontLibs.kotlinx.serialization.json) + compileOnly(idofrontLibs.kotlinx.serialization.kaml) + compileOnly(idofrontLibs.kotlinx.coroutines) + compileOnly(idofrontLibs.minecraft.mccoroutine) - compileOnly(libs.creative.api) - compileOnly(libs.creative.serializer.minecraft) + compileOnly(idofrontLibs.creative.api) + compileOnly(idofrontLibs.creative.serializer.minecraft) // Shaded implementation("com.aaaaahhhhh.bananapuncher714:GifConverter:1.0") diff --git a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyContext.kt b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyContext.kt index e0b89ee..a4d540c 100644 --- a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyContext.kt +++ b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyContext.kt @@ -8,6 +8,7 @@ import com.mineinabyss.emojy.nms.EmojyNMSHandlers import com.mineinabyss.emojy.nms.IEmojyNMSHandler import com.mineinabyss.emojy.translator.EmojyLanguage import com.mineinabyss.idofront.di.DI +import com.mineinabyss.idofront.messaging.ComponentLogger val emojy by DI.observe() val emojyConfig by DI.observe() @@ -18,4 +19,5 @@ interface EmojyContext { val gifs: Set val languages: Set val handler: IEmojyNMSHandler + val logger: ComponentLogger } diff --git a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyGenerator.kt b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyGenerator.kt index b3005db..6628ac1 100644 --- a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyGenerator.kt +++ b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyGenerator.kt @@ -33,13 +33,13 @@ object EmojyGenerator { resourcePack.font(font.toBuilder().addProvider(FontProvider.space().advance("\uE101", -1).build()).build()) // If the font has already added an entry for the emote, skip it font.providers().any { it is BitMapFontProvider && it.file() == emote.texture } -> - return@forEach if (emojyConfig.debug) logWarn("Skipping ${emote.id}-font because it is a bitmap and already added") else {} + return@forEach emojy.logger.d("Skipping ${emote.id}-font because it is a bitmap and already added") } resourcePack.font(emote.appendFont(resourcePack)) emotesFolder.listFiles()?.find { f -> f.nameWithoutExtension == emote.texture.value().substringAfterLast("/").removeSuffix(".png") }?.let { resourcePack.texture(Texture.texture(emote.texture, Writable.file(it))) - } ?: if (emojyConfig.debug) logWarn("Could not find texture for ${emote.id}") else {} + } ?: emojy.logger.d("Could not find texture for ${emote.id}") } emojy.gifs.forEach { it.generateSplitGif(resourcePack) @@ -58,7 +58,7 @@ object EmojyGenerator { Texture.texture(Key.key("${framePath.asString()}${it.name}"), Writable.file(it)) }?.forEach(resourcePack::texture) }.onFailure { - if (emojyConfig.debug) logError("Could not generate split gif for ${id}.gif: ${it.message}") + emojy.logger.d("Could not generate split gif for ${id}.gif: ${it.message}") } } } diff --git a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt index e579ee6..0c48575 100644 --- a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt +++ b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt @@ -10,6 +10,10 @@ import com.mineinabyss.emojy.translator.EmojyLanguage import com.mineinabyss.emojy.translator.EmojyTranslator import com.mineinabyss.idofront.config.config import com.mineinabyss.idofront.di.DI +import com.mineinabyss.idofront.messaging.ComponentLogger +import com.mineinabyss.idofront.messaging.injectLogger +import com.mineinabyss.idofront.messaging.observeLogger +import com.mineinabyss.idofront.plugin.dataPath import com.mineinabyss.idofront.plugin.listeners import net.kyori.adventure.key.Key import net.kyori.adventure.translation.GlobalTranslator @@ -49,20 +53,23 @@ class EmojyPlugin : JavaPlugin() { fun createEmojyContext() { DI.remove() - DI.add(config("config", dataFolder.toPath(), EmojyConfig()).getOrLoad()) + DI.add(config("config", dataPath, EmojyConfig(), onLoad = { + this@EmojyPlugin.injectLogger(ComponentLogger.forPlugin(this@EmojyPlugin, it.logLevel)) + }).getOrLoad()) DI.remove() - DI.add(config("templates", dataFolder.toPath(), EmojyTemplates()).getOrLoad()) + DI.add(config("templates", dataPath, EmojyTemplates()).getOrLoad()) DI.remove() DI.add(object : EmojyContext { override val plugin: EmojyPlugin = this@EmojyPlugin - override val emotes: Set = config("emotes", dataFolder.toPath(), Emotes()).getOrLoad().emotes - override val gifs: Set = config("gifs", dataFolder.toPath(), Gifs()).getOrLoad().gifs + override val emotes: Set = config("emotes", dataPath, Emotes()).getOrLoad().emotes + override val gifs: Set = config("gifs", dataPath, Gifs()).getOrLoad().gifs override val languages: Set = emojyConfig.supportedLanguages.map { EmojyLanguage(it.split("_").let { l -> Locale(l.first(), l.last().uppercase()) }, - config>(it, dataFolder.toPath() / "languages", mapOf()).getOrLoad()) + config>(it, dataPath / "languages", mapOf()).getOrLoad()) }.toSet() + override val logger by plugin.observeLogger() override val handler: IEmojyNMSHandler = EmojyNMSHandlers.setup() }) diff --git a/core/src/main/kotlin/com/mineinabyss/emojy/config/EmojyConfig.kt b/core/src/main/kotlin/com/mineinabyss/emojy/config/EmojyConfig.kt index 446b88f..5c1e87a 100644 --- a/core/src/main/kotlin/com/mineinabyss/emojy/config/EmojyConfig.kt +++ b/core/src/main/kotlin/com/mineinabyss/emojy/config/EmojyConfig.kt @@ -2,6 +2,7 @@ package com.mineinabyss.emojy.config +import co.touchlab.kermit.Severity import com.mineinabyss.emojy.* import com.mineinabyss.idofront.messaging.* import com.mineinabyss.idofront.serialization.KeySerializer @@ -39,7 +40,7 @@ data class EmojyConfig( val requirePermissions: Boolean = true, val supportForceUnicode: Boolean = true, - val debug: Boolean = true, + val logLevel: Severity = Severity.Debug, val emojyList: EmojyList = EmojyList(), val supportedLanguages: Set = mutableSetOf("en_us"), ) { @@ -206,7 +207,7 @@ data class Gifs(val gifs: Set = mutableSetOf()) { aspectRatio = reader.getAspectRatio(0) reader.getNumImages(true) }.onFailure { - if (emojyConfig.debug) logError("Could not get frame count for ${id}.gif") + emojy.logger.d("Could not get frame count for ${id}.gif") }.getOrNull() ?: run { aspectRatio = 1f 0 diff --git a/gradle.properties b/gradle.properties index e409055..b8debd1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=com.mineinabyss version=0.8 -idofrontVersion=0.21.2 +idofrontVersion=0.23.0 diff --git a/gradle/emojyLibs.toml b/gradle/libs.versions.toml similarity index 100% rename from gradle/emojyLibs.toml rename to gradle/libs.versions.toml diff --git a/settings.gradle.kts b/settings.gradle.kts index 58b5595..2db4462 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -27,10 +27,9 @@ dependencyResolutionManagement { } versionCatalogs { - create("libs"){ + create("idofrontLibs"){ from("com.mineinabyss:catalog:$idofrontVersion") } - create("emojyLibs").from(files("gradle/emojyLibs.toml")) } } diff --git a/v1_19_R1/build.gradle.kts b/v1_19_R1/build.gradle.kts index 8798848..58d0d94 100644 --- a/v1_19_R1/build.gradle.kts +++ b/v1_19_R1/build.gradle.kts @@ -13,13 +13,13 @@ repositories { dependencies { // MineInAbyss platform - compileOnly(libs.kotlinx.serialization.json) - compileOnly(libs.kotlinx.serialization.kaml) - compileOnly(libs.kotlinx.coroutines) - compileOnly(libs.minecraft.mccoroutine) + compileOnly(idofrontLibs.kotlinx.serialization.json) + compileOnly(idofrontLibs.kotlinx.serialization.kaml) + compileOnly(idofrontLibs.kotlinx.coroutines) + compileOnly(idofrontLibs.minecraft.mccoroutine) // Shaded - implementation(libs.bundles.idofront.core) + implementation(idofrontLibs.bundles.idofront.core) implementation(project(":core")) paperweight.paperDevBundle("1.19.2-R0.1-SNAPSHOT") //NMS } diff --git a/v1_19_R2/build.gradle.kts b/v1_19_R2/build.gradle.kts index 478258e..0e33bc5 100644 --- a/v1_19_R2/build.gradle.kts +++ b/v1_19_R2/build.gradle.kts @@ -13,13 +13,13 @@ repositories { dependencies { // MineInAbyss platform - compileOnly(libs.kotlinx.serialization.json) - compileOnly(libs.kotlinx.serialization.kaml) - compileOnly(libs.kotlinx.coroutines) - compileOnly(libs.minecraft.mccoroutine) + compileOnly(idofrontLibs.kotlinx.serialization.json) + compileOnly(idofrontLibs.kotlinx.serialization.kaml) + compileOnly(idofrontLibs.kotlinx.coroutines) + compileOnly(idofrontLibs.minecraft.mccoroutine) // Shaded - implementation(libs.bundles.idofront.core) + implementation(idofrontLibs.bundles.idofront.core) implementation(project(":core")) paperweight.paperDevBundle("1.19.3-R0.1-SNAPSHOT") //NMS } diff --git a/v1_19_R3/build.gradle.kts b/v1_19_R3/build.gradle.kts index 1626f96..ccb8d43 100644 --- a/v1_19_R3/build.gradle.kts +++ b/v1_19_R3/build.gradle.kts @@ -13,13 +13,13 @@ repositories { dependencies { // MineInAbyss platform - compileOnly(libs.kotlinx.serialization.json) - compileOnly(libs.kotlinx.serialization.kaml) - compileOnly(libs.kotlinx.coroutines) - compileOnly(libs.minecraft.mccoroutine) + compileOnly(idofrontLibs.kotlinx.serialization.json) + compileOnly(idofrontLibs.kotlinx.serialization.kaml) + compileOnly(idofrontLibs.kotlinx.coroutines) + compileOnly(idofrontLibs.minecraft.mccoroutine) // Shaded - implementation(libs.bundles.idofront.core) + implementation(idofrontLibs.bundles.idofront.core) implementation(project(":core")) paperweight.paperDevBundle("1.19.4-R0.1-SNAPSHOT") //NMS } diff --git a/v1_20_R1/build.gradle.kts b/v1_20_R1/build.gradle.kts index b0a079d..14eea49 100644 --- a/v1_20_R1/build.gradle.kts +++ b/v1_20_R1/build.gradle.kts @@ -13,13 +13,13 @@ repositories { dependencies { // MineInAbyss platform - compileOnly(libs.kotlinx.serialization.json) - compileOnly(libs.kotlinx.serialization.kaml) - compileOnly(libs.kotlinx.coroutines) - compileOnly(libs.minecraft.mccoroutine) + compileOnly(idofrontLibs.kotlinx.serialization.json) + compileOnly(idofrontLibs.kotlinx.serialization.kaml) + compileOnly(idofrontLibs.kotlinx.coroutines) + compileOnly(idofrontLibs.minecraft.mccoroutine) // Shaded - implementation(libs.bundles.idofront.core) + implementation(idofrontLibs.bundles.idofront.core) implementation(project(":core")) paperweight.paperDevBundle("1.20-R0.1-SNAPSHOT") //NMS } diff --git a/v1_20_R2/build.gradle.kts b/v1_20_R2/build.gradle.kts index 2cb241f..c32e7c5 100644 --- a/v1_20_R2/build.gradle.kts +++ b/v1_20_R2/build.gradle.kts @@ -13,13 +13,13 @@ repositories { dependencies { // MineInAbyss platform - compileOnly(libs.kotlinx.serialization.json) - compileOnly(libs.kotlinx.serialization.kaml) - compileOnly(libs.kotlinx.coroutines) - compileOnly(libs.minecraft.mccoroutine) + compileOnly(idofrontLibs.kotlinx.serialization.json) + compileOnly(idofrontLibs.kotlinx.serialization.kaml) + compileOnly(idofrontLibs.kotlinx.coroutines) + compileOnly(idofrontLibs.minecraft.mccoroutine) // Shaded - implementation(libs.bundles.idofront.core) + implementation(idofrontLibs.bundles.idofront.core) implementation(project(":core")) paperweight.paperDevBundle("1.20.2-R0.1-SNAPSHOT") //NMS } diff --git a/v1_20_R3/build.gradle.kts b/v1_20_R3/build.gradle.kts index 2214a76..16fe9bf 100644 --- a/v1_20_R3/build.gradle.kts +++ b/v1_20_R3/build.gradle.kts @@ -13,13 +13,13 @@ repositories { dependencies { // MineInAbyss platform - compileOnly(libs.kotlinx.serialization.json) - compileOnly(libs.kotlinx.serialization.kaml) - compileOnly(libs.kotlinx.coroutines) - compileOnly(libs.minecraft.mccoroutine) + compileOnly(idofrontLibs.kotlinx.serialization.json) + compileOnly(idofrontLibs.kotlinx.serialization.kaml) + compileOnly(idofrontLibs.kotlinx.coroutines) + compileOnly(idofrontLibs.minecraft.mccoroutine) // Shaded - implementation(libs.bundles.idofront.core) + implementation(idofrontLibs.bundles.idofront.core) implementation(project(":core")) paperweight.paperDevBundle("1.20.4-R0.1-SNAPSHOT") //NMS }