Skip to content

Commit

Permalink
Adds circle, reverse_circle split. Bumps dependency version.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Aug 16, 2024
1 parent 04420f6 commit 5e5cffb
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -44,7 +44,7 @@ allprojects {
apply(plugin = "kotlin")

group = "kr.toxicity.hud"
version = "1.1"
version = "1.2"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<TriggerType, SkillHandler<SkillResult>>()
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ class MythicMobsCompatibility: Compatibility {
}
}
},
"aura_max_duration" to object : HudPlaceholder<Number> {
override fun getRequiredArgsLength(): Int = 1
override fun invoke(args: MutableList<String>, reason: UpdateEvent): Function<HudPlayer, Number> {
return Function { p ->
MythicBukkit.inst().playerManager.getProfile(p.bukkitPlayer).auraRegistry.auras[args[0]]?.maxOfOrNull {
it.startDuration
} ?: 0
}
}
},
"aura_duration" to object : HudPlaceholder<Number> {
override fun getRequiredArgsLength(): Int = 1
override fun invoke(args: MutableList<String>, reason: UpdateEvent): Function<HudPlayer, Number> {
return Function { p ->
MythicBukkit.inst().playerManager.getProfile(p.bukkitPlayer).auraRegistry.auras[args[0]]?.maxOfOrNull {
it.ticksRemaining
} ?: 0
}
}
},
)
override val strings: Map<String, HudPlaceholder<String>>
get() = mapOf(
Expand Down
26 changes: 26 additions & 0 deletions dist/src/main/kotlin/kr/toxicity/hud/image/SplitType.kt
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -72,6 +74,30 @@ enum class SplitType {
}
}
},
CIRCLE {
override fun split(target: NamedLoadedImage, split: Int): List<NamedLoadedImage> {
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<NamedLoadedImage> {
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<NamedLoadedImage>
}
17 changes: 16 additions & 1 deletion dist/src/main/kotlin/kr/toxicity/hud/util/Images.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -134,4 +136,17 @@ fun BufferedImage.withOpacity(opacity: Double): BufferedImage {
}
}
}
}
}

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..<image.width) {
for (h in 0..<image.height) {
var d = -(atan2(h.toDouble() - hh, w.toDouble() - hw) + PI / 2)
if (d < 0) d += 2 * PI
if (d > 2 * PI) d -= 2 * PI
if (d <= degree) it.setRGB(w, h, image.getRGB(w, h))
}
}
}.removeEmptyWidth(xOffset, yOffset)
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5e5cffb

Please sign in to comment.