From 5e5cffb4cb865b5f37fd03f57f4426aaf5231b96 Mon Sep 17 00:00:00 2001 From: toxicity Date: Fri, 16 Aug 2024 13:01:14 +0900 Subject: [PATCH] Adds circle, reverse_circle split. Bumps dependency version. --- .idea/kotlinc.xml | 2 +- build.gradle.kts | 4 +-- .../mmoitems/MMOItemsCompatibility.kt | 3 +-- .../mythicmobs/MythicMobsCompatibility.kt | 20 ++++++++++++++ .../kotlin/kr/toxicity/hud/image/SplitType.kt | 26 +++++++++++++++++++ .../kotlin/kr/toxicity/hud/util/Images.kt | 17 +++++++++++- gradle/wrapper/gradle-wrapper.properties | 2 +- 7 files changed, 67 insertions(+), 7 deletions(-) diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 6d0ee1c2..5815a4a6 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 349871ef..0d52f76e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ plugins { `java-library` - kotlin("jvm") version("2.0.0") + kotlin("jvm") version("2.0.10") id("io.github.goooler.shadow") version("8.1.8") id("io.papermc.paperweight.userdev") version("1.7.2") apply(false) id("xyz.jpenilla.run-paper") version("2.3.0") @@ -44,7 +44,7 @@ allprojects { apply(plugin = "kotlin") group = "kr.toxicity.hud" - version = "1.1" + version = "1.2" repositories { mavenCentral() diff --git a/dist/src/main/kotlin/kr/toxicity/hud/compatibility/mmoitems/MMOItemsCompatibility.kt b/dist/src/main/kotlin/kr/toxicity/hud/compatibility/mmoitems/MMOItemsCompatibility.kt index bbc7b3b3..bb3f7204 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/compatibility/mmoitems/MMOItemsCompatibility.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/compatibility/mmoitems/MMOItemsCompatibility.kt @@ -1,6 +1,5 @@ package kr.toxicity.hud.compatibility.mmoitems -import com.google.gson.JsonParser import io.lumine.mythic.lib.MythicLib import io.lumine.mythic.lib.api.item.ItemTag import io.lumine.mythic.lib.api.item.SupportedNBTTagValues @@ -52,7 +51,7 @@ class MMOItemsCompatibility: Compatibility { val compact = ItemTag.getTagAtPath(ItemStats.ABILITIES.nbtPath, tags)?.value as? String ?: return emptyMap() return runCatching { val map = HashMap>() - JsonParser.parseString(compact).asJsonArray.forEach { + io.lumine.mythic.lib.gson.JsonParser.parseString(compact).asJsonArray.forEach { if (it.isJsonObject) { val data = AbilityData(it.asJsonObject) map[data.trigger] = data.handler diff --git a/dist/src/main/kotlin/kr/toxicity/hud/compatibility/mythicmobs/MythicMobsCompatibility.kt b/dist/src/main/kotlin/kr/toxicity/hud/compatibility/mythicmobs/MythicMobsCompatibility.kt index 5c880275..281963ec 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/compatibility/mythicmobs/MythicMobsCompatibility.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/compatibility/mythicmobs/MythicMobsCompatibility.kt @@ -56,6 +56,26 @@ class MythicMobsCompatibility: Compatibility { } } }, + "aura_max_duration" to object : HudPlaceholder { + override fun getRequiredArgsLength(): Int = 1 + override fun invoke(args: MutableList, reason: UpdateEvent): Function { + return Function { p -> + MythicBukkit.inst().playerManager.getProfile(p.bukkitPlayer).auraRegistry.auras[args[0]]?.maxOfOrNull { + it.startDuration + } ?: 0 + } + } + }, + "aura_duration" to object : HudPlaceholder { + override fun getRequiredArgsLength(): Int = 1 + override fun invoke(args: MutableList, reason: UpdateEvent): Function { + return Function { p -> + MythicBukkit.inst().playerManager.getProfile(p.bukkitPlayer).auraRegistry.auras[args[0]]?.maxOfOrNull { + it.ticksRemaining + } ?: 0 + } + } + }, ) override val strings: Map> get() = mapOf( diff --git a/dist/src/main/kotlin/kr/toxicity/hud/image/SplitType.kt b/dist/src/main/kotlin/kr/toxicity/hud/image/SplitType.kt index 2924604d..349d66fc 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/image/SplitType.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/image/SplitType.kt @@ -1,8 +1,10 @@ package kr.toxicity.hud.image +import kr.toxicity.hud.util.circleCut import kr.toxicity.hud.util.removeEmptyWidth import java.awt.AlphaComposite import java.awt.image.BufferedImage +import kotlin.math.PI enum class SplitType { LEFT { @@ -72,6 +74,30 @@ enum class SplitType { } } }, + CIRCLE { + override fun split(target: NamedLoadedImage, split: Int): List { + val saveName = target.name.substringBefore('.') + return (1..split).map { + val targetImage = target.image.circleCut(2 * PI * it.toDouble() / split.toDouble()) ?: throw RuntimeException() + NamedLoadedImage( + "${saveName}_$it.png", + targetImage + ) + } + } + }, + REVERSE_CIRCLE { + override fun split(target: NamedLoadedImage, split: Int): List { + val saveName = target.name.substringBefore('.') + return (1..split).map { + val targetImage = target.image.circleCut(2 * PI * (split - it + 1).toDouble() / split.toDouble()) ?: throw RuntimeException() + NamedLoadedImage( + "${saveName}_$it.png", + targetImage + ) + } + } + }, ; abstract fun split(target: NamedLoadedImage, split: Int): List } \ No newline at end of file diff --git a/dist/src/main/kotlin/kr/toxicity/hud/util/Images.kt b/dist/src/main/kotlin/kr/toxicity/hud/util/Images.kt index 97c50a7d..e17315a7 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/util/Images.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/util/Images.kt @@ -9,6 +9,8 @@ import java.io.File import java.io.InputStream import java.io.OutputStream import javax.imageio.ImageIO +import kotlin.math.PI +import kotlin.math.atan2 import kotlin.math.roundToInt private const val WHITE = (0xFF shl 24) or (0xFF shl 16) or (0xFF shl 8) or 0xFF @@ -134,4 +136,17 @@ fun BufferedImage.withOpacity(opacity: Double): BufferedImage { } } } -} \ No newline at end of file +} + +fun LoadedImage.circleCut(degree: Double) = BufferedImage(image.width, image.height, BufferedImage.TYPE_INT_ARGB).also { + val hw = image.width.toDouble() / 2 + val hh = image.height.toDouble() / 2 + for (w in 0.. 2 * PI) d -= 2 * PI + if (d <= degree) it.setRGB(w, h, image.getRGB(w, h)) + } + } +}.removeEmptyWidth(xOffset, yOffset) \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8f77e2d0..954984db 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Feb 29 02:18:16 KST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists