Files
kayjaydee 8725b8a1c7 feat(phase-3): runtime integration — chain damage application + cooldown
Wires the pure ChainResolver (Phase 2) to the live Hytale runtime via
four sceptre/ adapters:
- HytaleEntityAdapter — eager snapshot Ref<EntityStore> -> ChainEntity
  via TransformComponent.getPosition() and EntityStatMap.get(health) > 0
- HytalePlayerRayCaster — captures playerRef, delegates to
  TargetUtil.getTargetEntity (auto eye-origin + head-rotation)
- HytaleEntitySource — wraps TargetUtil.getAllEntitiesInSphere
- ChainDamageApplier — fires DamageSystems.executeDamage per hit;
  injectable DamageExecutor SAM keeps the helper unit-testable.

ChainLightningSceptreInteraction.firstRun is rewritten end-to-end:
cooldown gate (hasCooldown(false) -> deductCharge() only on success),
ray-cast -> BFS -> damage application, structured logging, try/catch
wrapper to keep a runtime fault from killing the server tick.

API corrections discovered against the decompiled jar:
- Ref has no uuid() — use "ref:" + getIndex() for the chain id
- DamageCause.PHYSICAL is @Nullable until runtime — use the int-index
  overload of Damage with index 0
- Static mock of DamageSystems crashes class init — abstracted behind
  a DamageExecutor SAM with a default lazy holder

Tests: 33/33 green (25 from Phase 2 + 4 ChainDamageApplier tests +
4 fixture sanity). ./gradlew build SUCCESSFUL, JAR auto-deployed.
MANUAL UAT (10 items) pending in-game.
2026-04-27 12:14:58 +02:00

100 lines
2.8 KiB
Kotlin

plugins {
id("java-library")
id("com.gradleup.shadow") version "9.3.1"
}
group = findProperty("pluginGroup") as String? ?: "com.mythlane"
version = findProperty("pluginVersion") as String? ?: "0.1.0"
description = findProperty("pluginDescription") as String? ?: "Hytale Chain Lightning"
val hytaleServerVersion: String by project
repositories {
mavenLocal()
mavenCentral()
maven {
name = "hytale"
url = uri("https://maven.hytale.com/release")
}
}
dependencies {
compileOnly("com.hypixel.hytale:Server:$hytaleServerVersion")
implementation("com.google.code.gson:gson:2.10.1")
implementation("org.jetbrains:annotations:24.1.0")
testImplementation("com.hypixel.hytale:Server:$hytaleServerVersion")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("org.mockito:mockito-core:5.14.2")
testImplementation("org.assertj:assertj-core:3.26.3")
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(25))
}
}
tasks {
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release = 25
}
processResources {
filteringCharset = Charsets.UTF_8.name()
val props = mapOf(
"group" to project.group,
"version" to project.version,
"description" to project.description,
"hytaleServerVersion" to hytaleServerVersion
)
inputs.properties(props)
filesMatching("manifest.json") {
expand(props)
}
}
shadowJar {
archiveBaseName.set("hytale-chain-lightning")
archiveClassifier.set("")
relocate("com.google.gson", "com.mythlane.chainlightning.libs.gson")
}
jar {
enabled = false
}
// Auto-copy le fat JAR vers le dossier mods du serveur dev Hytale après shadowJar.
// Override via -PdevServerMods=... ou la propriété `devServerMods` dans gradle.properties.
// Désactivable via -PdevServerMods=disabled (ou valeur vide).
val devServerModsDefault = "C:/Users/minit/Desktop/HYTALE SERVER/Server/mods"
val copyJarToDevServer by registering(Copy::class) {
val target = (findProperty("devServerMods") as String? ?: devServerModsDefault).trim()
onlyIf {
target.isNotEmpty() && target != "disabled" && file(target).isDirectory
}
from(shadowJar)
into(target)
doLast {
logger.lifecycle("[copyJarToDevServer] Copié vers $target")
}
}
shadowJar {
finalizedBy(copyJarToDevServer)
}
build {
dependsOn(shadowJar)
}
test {
useJUnitPlatform()
// Byte Buddy (Mockito) ne supporte pas encore Java 25 officiellement — flag experimental requis.
jvmArgs("-Dnet.bytebuddy.experimental=true")
}
}