Ещё больше приборки в структуре
This commit is contained in:
parent
215ae8429e
commit
6fafcd6185
@ -41,7 +41,7 @@ import ru.dbotthepony.kstarbound.defs.world.dungeon.DungeonWorldDef
|
||||
import ru.dbotthepony.kstarbound.io.*
|
||||
import ru.dbotthepony.kstarbound.io.json.AABBTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.AABBiTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.Vector2dTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.Vector2fTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.Vector2iTypeAdapter
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs
|
||||
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import ru.dbotthepony.kstarbound.io.json.IStringSerializable
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
|
||||
|
||||
enum class DamageType(private vararg val aliases: String) : IStringSerializable {
|
||||
NORMAL,
|
||||
|
@ -5,7 +5,6 @@ import com.google.gson.TypeAdapter
|
||||
import com.google.gson.stream.JsonReader
|
||||
import com.google.gson.stream.JsonToken
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.sbIntern
|
||||
import ru.dbotthepony.kstarbound.util.NotNullVar
|
||||
|
||||
|
@ -6,8 +6,8 @@ import com.google.gson.TypeAdapter
|
||||
import com.google.gson.stream.JsonReader
|
||||
import com.google.gson.stream.JsonToken
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import ru.dbotthepony.kstarbound.io.json.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.IStringSerializable
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
|
||||
import ru.dbotthepony.kstarbound.io.json.Vector2dTypeAdapter
|
||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||
|
||||
|
@ -5,7 +5,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.defs.util.enrollMap
|
||||
import ru.dbotthepony.kstarbound.defs.util.flattenMap
|
||||
import ru.dbotthepony.kstarbound.io.json.INativeJsonHolder
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.INativeJsonHolder
|
||||
|
||||
/**
|
||||
* Базовый класс описания прототипа игрового объекта
|
||||
@ -16,7 +16,8 @@ import ru.dbotthepony.kstarbound.io.json.INativeJsonHolder
|
||||
* Если границы поля зависят от других полей, то проверка такого поля должна осуществляться уже при самой
|
||||
* сборке прототипа.
|
||||
*/
|
||||
abstract class RawPrototype<RAW : RawPrototype<RAW, ASSEMBLED>, ASSEMBLED : AssembledPrototype<ASSEMBLED, RAW>> : INativeJsonHolder {
|
||||
abstract class RawPrototype<RAW : RawPrototype<RAW, ASSEMBLED>, ASSEMBLED : AssembledPrototype<ASSEMBLED, RAW>> :
|
||||
INativeJsonHolder {
|
||||
val json = Object2ObjectArrayMap<String, Any>()
|
||||
fun enroll() = enrollMap(json, Starbound.STRING_INTERNER::intern)
|
||||
abstract fun assemble(directory: String = ""): ASSEMBLED
|
||||
|
@ -2,9 +2,9 @@ package ru.dbotthepony.kstarbound.defs.item
|
||||
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.defs.util.enrollMap
|
||||
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.asJsonObject
|
||||
import ru.dbotthepony.kstarbound.io.json.asList
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.util.asJsonObject
|
||||
import ru.dbotthepony.kstarbound.io.json.util.asList
|
||||
import ru.dbotthepony.kstarbound.io.json.neverNull
|
||||
import ru.dbotthepony.kstarbound.util.NotNullVar
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.item
|
||||
|
||||
import ru.dbotthepony.kstarbound.defs.util.enrollMap
|
||||
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.util.NotNullVar
|
||||
|
||||
class CurrencyItemPrototype : ItemPrototype(), ICurrencyItemDefinition {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.item
|
||||
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.ifString
|
||||
|
||||
interface IArmorItemDefinition : ILeveledItemDefinition, IScriptableItemDefinition {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.item
|
||||
|
||||
import ru.dbotthepony.kstarbound.defs.IThingWithDescription
|
||||
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
|
||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||
|
||||
interface IFossilItemDefinition : IItemDefinition {
|
||||
|
@ -3,7 +3,7 @@ package ru.dbotthepony.kstarbound.defs.item
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.defs.IThingWithDescription
|
||||
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
||||
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.ifString
|
||||
|
||||
interface IItemDefinition : IThingWithDescription {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package ru.dbotthepony.kstarbound.defs.item
|
||||
|
||||
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
|
||||
|
||||
interface ILeveledStatusEffect {
|
||||
val levelFunction: String
|
||||
@ -17,10 +17,10 @@ data class LeveledStatusEffect(
|
||||
) : ILeveledStatusEffect {
|
||||
companion object {
|
||||
val ADAPTER = FactoryAdapter.Builder(LeveledStatusEffect::class,
|
||||
LeveledStatusEffect::levelFunction,
|
||||
LeveledStatusEffect::stat,
|
||||
LeveledStatusEffect::baseMultiplier,
|
||||
LeveledStatusEffect::amount,
|
||||
LeveledStatusEffect::levelFunction,
|
||||
LeveledStatusEffect::stat,
|
||||
LeveledStatusEffect::baseMultiplier,
|
||||
LeveledStatusEffect::amount,
|
||||
).build()
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package ru.dbotthepony.kstarbound.defs.item
|
||||
|
||||
import ru.dbotthepony.kstarbound.defs.ThingDescription
|
||||
import ru.dbotthepony.kstarbound.defs.util.enrollMap
|
||||
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.INativeJsonHolder
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.INativeJsonHolder
|
||||
import ru.dbotthepony.kstarbound.util.NotNullVar
|
||||
|
||||
open class ItemPrototype : IItemDefinition, INativeJsonHolder {
|
||||
|
@ -1,11 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.item
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.TypeAdapter
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import ru.dbotthepony.kstarbound.io.json.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.IStringSerializable
|
||||
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
|
||||
|
||||
enum class ItemRarity(val canonical: String) : IStringSerializable {
|
||||
COMMON("Common"),
|
||||
|
@ -2,7 +2,7 @@ package ru.dbotthepony.kstarbound.defs.item
|
||||
|
||||
import ru.dbotthepony.kstarbound.defs.MaterialReference
|
||||
import ru.dbotthepony.kstarbound.defs.util.enrollMap
|
||||
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
||||
|
||||
class LiquidItemPrototype : ItemPrototype() {
|
||||
var liquid: MaterialReference? = null
|
||||
|
@ -2,7 +2,7 @@ package ru.dbotthepony.kstarbound.defs.item
|
||||
|
||||
import ru.dbotthepony.kstarbound.defs.MaterialReference
|
||||
import ru.dbotthepony.kstarbound.defs.util.enrollMap
|
||||
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
||||
|
||||
class MaterialItemPrototype : ItemPrototype() {
|
||||
var material: MaterialReference? = null
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.liquid
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
||||
import ru.dbotthepony.kvector.vector.Color
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.parallax
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
||||
|
||||
class ParallaxPrototype {
|
||||
var verticalOrigin = 0.0
|
||||
|
@ -5,7 +5,7 @@ import com.google.gson.TypeAdapter
|
||||
import com.google.gson.stream.JsonReader
|
||||
import com.google.gson.stream.JsonToken
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
|
@ -8,8 +8,8 @@ import org.apache.logging.log4j.LogManager
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.defs.*
|
||||
import ru.dbotthepony.kstarbound.defs.image.ImageReference
|
||||
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.util.NotNullVar
|
||||
import ru.dbotthepony.kvector.vector.Color
|
||||
@ -205,9 +205,9 @@ class ActionProjectile : IConfigurableAction {
|
||||
|
||||
companion object {
|
||||
val ADAPTER = BuilderAdapter.Builder(::ActionProjectile,
|
||||
ActionProjectile::type,
|
||||
ActionProjectile::angle,
|
||||
ActionProjectile::inheritDamageFactor,
|
||||
ActionProjectile::type,
|
||||
ActionProjectile::angle,
|
||||
ActionProjectile::inheritDamageFactor,
|
||||
).ignoreKey("action").build()
|
||||
}
|
||||
}
|
||||
@ -224,7 +224,7 @@ class ActionSound : IConfigurableAction {
|
||||
|
||||
companion object {
|
||||
val ADAPTER = BuilderAdapter.Builder(::ActionSound,
|
||||
ActionSound::options,
|
||||
ActionSound::options,
|
||||
).ignoreKey("action").build()
|
||||
}
|
||||
}
|
||||
@ -242,8 +242,8 @@ class ActionLoop : IConfigurableAction {
|
||||
|
||||
companion object {
|
||||
val ADAPTER = BuilderAdapter.Builder(::ActionLoop,
|
||||
ActionLoop::count,
|
||||
ActionLoop::body,
|
||||
ActionLoop::count,
|
||||
ActionLoop::body,
|
||||
).ignoreKey("action").build()
|
||||
}
|
||||
}
|
||||
@ -260,7 +260,7 @@ class ActionActions : IConfigurableAction {
|
||||
|
||||
companion object {
|
||||
val ADAPTER = BuilderAdapter.Builder(::ActionActions,
|
||||
ActionActions::list,
|
||||
ActionActions::list,
|
||||
).ignoreKey("action").build()
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.projectile
|
||||
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import ru.dbotthepony.kstarbound.io.json.IStringSerializable
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
|
||||
|
||||
enum class ProjectilePhysics(vararg aliases: String) : IStringSerializable {
|
||||
GAS,
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.tile
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
|
||||
|
||||
data class MaterialModifier(
|
||||
val modId: Int,
|
||||
|
@ -2,7 +2,7 @@ package ru.dbotthepony.kstarbound.defs.tile
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
|
||||
|
||||
const val TILE_COLOR_VARIANTS = 9
|
||||
|
||||
|
@ -9,8 +9,8 @@ import com.google.gson.stream.JsonWriter
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.io.json.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.util.WriteOnce
|
||||
import ru.dbotthepony.kstarbound.world.ITileGetter
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.tile
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
|
||||
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
||||
import ru.dbotthepony.kvector.vector.Color
|
||||
|
||||
|
@ -6,8 +6,8 @@ import com.google.gson.stream.JsonReader
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import ru.dbotthepony.kstarbound.io.ColorTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
|
||||
import ru.dbotthepony.kvector.vector.Color
|
||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.world
|
||||
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import ru.dbotthepony.kstarbound.io.json.IStringSerializable
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
|
||||
|
||||
enum class SkyType(vararg aliases: String) : IStringSerializable {
|
||||
ATMOSPHERIC,
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.world
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
||||
|
||||
class WorldProperties {
|
||||
var nonCombat = false
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.world.dungeon
|
||||
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import ru.dbotthepony.kstarbound.io.json.IStringSerializable
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
|
||||
|
||||
enum class BeamUpRule(vararg aliases: String) : IStringSerializable {
|
||||
NOWHERE,
|
||||
|
@ -3,8 +3,8 @@ package ru.dbotthepony.kstarbound.defs.world.dungeon
|
||||
import com.google.gson.GsonBuilder
|
||||
import ru.dbotthepony.kstarbound.defs.world.SkyParameters
|
||||
import ru.dbotthepony.kstarbound.defs.world.WorldProperties
|
||||
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ru.dbotthepony.kstarbound.defs.world.dungeon
|
||||
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import ru.dbotthepony.kstarbound.io.json.IStringSerializable
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
|
||||
|
||||
enum class DungeonType(vararg aliases: String) : IStringSerializable {
|
||||
FLOATING("FloatingDungeon"),
|
||||
|
@ -1,4 +1,4 @@
|
||||
package ru.dbotthepony.kstarbound.io.json
|
||||
package ru.dbotthepony.kstarbound.io.json.builder
|
||||
|
||||
import com.google.common.collect.ImmutableMap
|
||||
import com.google.common.collect.ImmutableSet
|
||||
@ -15,6 +15,8 @@ import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.defs.util.flattenJsonElement
|
||||
import ru.dbotthepony.kstarbound.io.json.util.LazyTypeProvider
|
||||
import ru.dbotthepony.kstarbound.io.json.util.ListAdapter
|
||||
import ru.dbotthepony.kstarbound.util.NotNullVar
|
||||
import kotlin.properties.Delegates
|
||||
import kotlin.reflect.KClass
|
||||
@ -293,11 +295,13 @@ class BuilderAdapter<T : Any> private constructor(
|
||||
fun <V> add(property: KMutableProperty1<T, V>, adapter: TypeAdapter<V>, configurator: PropertyConfigurator<T, V>.() -> Unit = {}): Builder<T> {
|
||||
val config = _add(property, adapter, configurator)
|
||||
|
||||
properties.add(WrappedProperty(
|
||||
properties.add(
|
||||
WrappedProperty(
|
||||
property,
|
||||
adapter,
|
||||
mustBePresent = config.mustBePresent
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
return this
|
||||
}
|
||||
@ -327,11 +331,13 @@ class BuilderAdapter<T : Any> private constructor(
|
||||
|
||||
check(!extraPropertiesAreFatal) { "Can't have both flattened properties and extraPropertiesAreFatal" }
|
||||
|
||||
flatProperties.add(WrappedProperty(
|
||||
flatProperties.add(
|
||||
WrappedProperty(
|
||||
property,
|
||||
adapter,
|
||||
mustBePresent = config.mustBePresent
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
return this
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.dbotthepony.kstarbound.io.json
|
||||
package ru.dbotthepony.kstarbound.io.json.builder
|
||||
|
||||
import com.google.common.collect.ImmutableList
|
||||
import com.google.common.collect.ImmutableMap
|
||||
@ -9,7 +9,6 @@ import com.google.gson.stream.JsonReader
|
||||
import com.google.gson.stream.JsonToken
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap
|
||||
import ru.dbotthepony.kstarbound.set
|
||||
import java.util.Arrays
|
||||
import java.util.stream.Stream
|
||||
import kotlin.reflect.KClass
|
@ -1,4 +1,4 @@
|
||||
package ru.dbotthepony.kstarbound.io.json
|
||||
package ru.dbotthepony.kstarbound.io.json.builder
|
||||
|
||||
import com.google.common.collect.ImmutableList
|
||||
import com.google.common.collect.ImmutableMap
|
||||
@ -20,6 +20,10 @@ import ru.dbotthepony.kstarbound.defs.util.enrollList
|
||||
import ru.dbotthepony.kstarbound.defs.util.enrollMap
|
||||
import ru.dbotthepony.kstarbound.defs.util.flattenJsonElement
|
||||
import ru.dbotthepony.kstarbound.getValue
|
||||
import ru.dbotthepony.kstarbound.io.json.util.LazyTypeProvider
|
||||
import ru.dbotthepony.kstarbound.io.json.util.ListAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.util.MapAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.util.String2ObjectAdapter
|
||||
import ru.dbotthepony.kstarbound.setValue
|
||||
import java.lang.reflect.Constructor
|
||||
import kotlin.jvm.internal.DefaultConstructorMarker
|
@ -1,4 +1,4 @@
|
||||
package ru.dbotthepony.kstarbound.io.json
|
||||
package ru.dbotthepony.kstarbound.io.json.util
|
||||
|
||||
import com.google.gson.TypeAdapter
|
||||
import com.google.gson.stream.JsonReader
|
@ -1,4 +1,4 @@
|
||||
package ru.dbotthepony.kstarbound.io.json
|
||||
package ru.dbotthepony.kstarbound.io.json.util
|
||||
|
||||
import com.google.common.collect.ImmutableList
|
||||
import com.google.gson.JsonSyntaxException
|
||||
@ -6,7 +6,6 @@ import com.google.gson.TypeAdapter
|
||||
import com.google.gson.stream.JsonReader
|
||||
import com.google.gson.stream.JsonToken
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
|
||||
fun <T : Any> TypeAdapter<T>.asList(valueTransformer: (T) -> T = { it }): TypeAdapter<List<T>> {
|
||||
return ListAdapter(this, valueTransformer = valueTransformer)
|
@ -1,11 +1,10 @@
|
||||
package ru.dbotthepony.kstarbound.io.json
|
||||
package ru.dbotthepony.kstarbound.io.json.util
|
||||
|
||||
import com.google.common.collect.ImmutableMap
|
||||
import com.google.gson.TypeAdapter
|
||||
import com.google.gson.stream.JsonReader
|
||||
import com.google.gson.stream.JsonToken
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
|
||||
class MapAdapter<K, V>(val keyAdapter: TypeAdapter<K>, val valueAdapter: TypeAdapter<V>) : TypeAdapter<Map<K, V>>() {
|
||||
constructor(keyType: Class<K>, valueType: Class<V>) : this(LazyTypeProvider(keyType), LazyTypeProvider(valueType))
|
@ -1,4 +1,4 @@
|
||||
package ru.dbotthepony.kstarbound.io.json
|
||||
package ru.dbotthepony.kstarbound.io.json.util
|
||||
|
||||
import com.google.common.collect.ImmutableMap
|
||||
import com.google.gson.TypeAdapter
|
Loading…
Reference in New Issue
Block a user