From 404c3dd6d18a62b74f506230e583599d63db64ef Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 8 Sep 2022 19:53:44 +0700 Subject: [PATCH] Reified generics for lists --- .../kstarbound/defs/tile/MaterialModifier.kt | 2 +- .../kstarbound/defs/tile/RenderTemplate.kt | 12 ++++++------ .../kstarbound/io/KConcreteTypeAdapter.kt | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/MaterialModifier.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/MaterialModifier.kt index edc5e353..78fd8ad8 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/MaterialModifier.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/MaterialModifier.kt @@ -29,7 +29,7 @@ data class MaterialModifier( .plain(MaterialModifier::health) .plain(MaterialModifier::harvestLevel) .plain(MaterialModifier::breaksWithTile) - .list(MaterialModifier::miningSounds, String::class) + .list(MaterialModifier::miningSounds) .plain(MaterialModifier::miningParticle) .plain(MaterialModifier::renderTemplate, RenderTemplate.CACHE) .plain(MaterialModifier::renderParameters) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/RenderTemplate.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/RenderTemplate.kt index 33c6dee8..05a92dc2 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/RenderTemplate.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/RenderTemplate.kt @@ -113,7 +113,7 @@ data class RenderRuleList( companion object { val ADAPTER = KConcreteTypeAdapter.Builder(RenderRuleList::class) - .list(RenderRuleList::entries, Entry::class) + .list(RenderRuleList::entries) .plain(RenderRuleList::join) .build() } @@ -200,10 +200,10 @@ data class RenderMatch( companion object { val ADAPTER = KConcreteTypeAdapter.Builder(RenderMatch::class) - .list(RenderMatch::pieces, Piece::class) - .list(RenderMatch::matchAllPoints, Matcher::class) - .list(RenderMatch::matchAnyPoints, Matcher::class) - .list(RenderMatch::subMatches, RenderMatch::class) + .list(RenderMatch::pieces) + .list(RenderMatch::matchAllPoints) + .list(RenderMatch::matchAnyPoints) + .list(RenderMatch::subMatches) .plain(RenderMatch::haltOnMatch) .plain(RenderMatch::haltOnSubMatch) .build() @@ -233,7 +233,7 @@ data class RenderMatchList( companion object { val ADAPTER = KConcreteTypeAdapter.Builder(RenderMatchList::class) .plain(RenderMatchList::name) - .list(RenderMatchList::list, RenderMatch::class) + .list(RenderMatchList::list) .build(asList = true) } } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/io/KConcreteTypeAdapter.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/io/KConcreteTypeAdapter.kt index deeec68e..41a0be89 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/io/KConcreteTypeAdapter.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/io/KConcreteTypeAdapter.kt @@ -475,8 +475,8 @@ class KConcreteTypeAdapter( * * Список неизменяем (создаётся объект [ImmutableList]) */ - fun list(field: KProperty1?>, type: KClass): Builder { - return this.list(field, type.java) + inline fun list(field: KProperty1?>): Builder { + return this.list(field, V::class.java) } /**