Ещё больше приборки в структуре

This commit is contained in:
DBotThePony 2023-01-22 18:47:30 +07:00
parent 215ae8429e
commit 6fafcd6185
Signed by: DBot
GPG Key ID: DCC23B5715498507
37 changed files with 71 additions and 68 deletions

View File

@ -41,7 +41,7 @@ import ru.dbotthepony.kstarbound.defs.world.dungeon.DungeonWorldDef
import ru.dbotthepony.kstarbound.io.* import ru.dbotthepony.kstarbound.io.*
import ru.dbotthepony.kstarbound.io.json.AABBTypeAdapter import ru.dbotthepony.kstarbound.io.json.AABBTypeAdapter
import ru.dbotthepony.kstarbound.io.json.AABBiTypeAdapter 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.Vector2dTypeAdapter
import ru.dbotthepony.kstarbound.io.json.Vector2fTypeAdapter import ru.dbotthepony.kstarbound.io.json.Vector2fTypeAdapter
import ru.dbotthepony.kstarbound.io.json.Vector2iTypeAdapter import ru.dbotthepony.kstarbound.io.json.Vector2iTypeAdapter

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs package ru.dbotthepony.kstarbound.defs
import com.google.gson.stream.JsonWriter 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 { enum class DamageType(private vararg val aliases: String) : IStringSerializable {
NORMAL, NORMAL,

View File

@ -5,7 +5,6 @@ import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken import com.google.gson.stream.JsonToken
import com.google.gson.stream.JsonWriter import com.google.gson.stream.JsonWriter
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
import ru.dbotthepony.kstarbound.sbIntern import ru.dbotthepony.kstarbound.sbIntern
import ru.dbotthepony.kstarbound.util.NotNullVar import ru.dbotthepony.kstarbound.util.NotNullVar

View File

@ -6,8 +6,8 @@ import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken import com.google.gson.stream.JsonToken
import com.google.gson.stream.JsonWriter import com.google.gson.stream.JsonWriter
import ru.dbotthepony.kstarbound.io.json.EnumAdapter import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
import ru.dbotthepony.kstarbound.io.json.IStringSerializable import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
import ru.dbotthepony.kstarbound.io.json.Vector2dTypeAdapter import ru.dbotthepony.kstarbound.io.json.Vector2dTypeAdapter
import ru.dbotthepony.kvector.vector.ndouble.Vector2d import ru.dbotthepony.kvector.vector.ndouble.Vector2d

View File

@ -5,7 +5,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap
import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.Starbound
import ru.dbotthepony.kstarbound.defs.util.enrollMap import ru.dbotthepony.kstarbound.defs.util.enrollMap
import ru.dbotthepony.kstarbound.defs.util.flattenMap 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>() val json = Object2ObjectArrayMap<String, Any>()
fun enroll() = enrollMap(json, Starbound.STRING_INTERNER::intern) fun enroll() = enrollMap(json, Starbound.STRING_INTERNER::intern)
abstract fun assemble(directory: String = ""): ASSEMBLED abstract fun assemble(directory: String = ""): ASSEMBLED

View File

@ -2,9 +2,9 @@ package ru.dbotthepony.kstarbound.defs.item
import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.Starbound
import ru.dbotthepony.kstarbound.defs.util.enrollMap 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.io.json.asJsonObject import ru.dbotthepony.kstarbound.io.json.util.asJsonObject
import ru.dbotthepony.kstarbound.io.json.asList import ru.dbotthepony.kstarbound.io.json.util.asList
import ru.dbotthepony.kstarbound.io.json.neverNull import ru.dbotthepony.kstarbound.io.json.neverNull
import ru.dbotthepony.kstarbound.util.NotNullVar import ru.dbotthepony.kstarbound.util.NotNullVar

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs.item package ru.dbotthepony.kstarbound.defs.item
import ru.dbotthepony.kstarbound.defs.util.enrollMap 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 import ru.dbotthepony.kstarbound.util.NotNullVar
class CurrencyItemPrototype : ItemPrototype(), ICurrencyItemDefinition { class CurrencyItemPrototype : ItemPrototype(), ICurrencyItemDefinition {

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs.item package ru.dbotthepony.kstarbound.defs.item
import ru.dbotthepony.kstarbound.Starbound 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 import ru.dbotthepony.kstarbound.io.json.ifString
interface IArmorItemDefinition : ILeveledItemDefinition, IScriptableItemDefinition { interface IArmorItemDefinition : ILeveledItemDefinition, IScriptableItemDefinition {

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs.item package ru.dbotthepony.kstarbound.defs.item
import ru.dbotthepony.kstarbound.defs.IThingWithDescription 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 import ru.dbotthepony.kvector.vector.ndouble.Vector2d
interface IFossilItemDefinition : IItemDefinition { interface IFossilItemDefinition : IItemDefinition {

View File

@ -3,7 +3,7 @@ package ru.dbotthepony.kstarbound.defs.item
import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.Starbound
import ru.dbotthepony.kstarbound.defs.IThingWithDescription import ru.dbotthepony.kstarbound.defs.IThingWithDescription
import ru.dbotthepony.kstarbound.defs.image.SpriteReference 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 import ru.dbotthepony.kstarbound.io.json.ifString
interface IItemDefinition : IThingWithDescription { interface IItemDefinition : IThingWithDescription {

View File

@ -1,6 +1,6 @@
package ru.dbotthepony.kstarbound.defs.item package ru.dbotthepony.kstarbound.defs.item
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
interface ILeveledStatusEffect { interface ILeveledStatusEffect {
val levelFunction: String val levelFunction: String
@ -17,10 +17,10 @@ data class LeveledStatusEffect(
) : ILeveledStatusEffect { ) : ILeveledStatusEffect {
companion object { companion object {
val ADAPTER = FactoryAdapter.Builder(LeveledStatusEffect::class, val ADAPTER = FactoryAdapter.Builder(LeveledStatusEffect::class,
LeveledStatusEffect::levelFunction, LeveledStatusEffect::levelFunction,
LeveledStatusEffect::stat, LeveledStatusEffect::stat,
LeveledStatusEffect::baseMultiplier, LeveledStatusEffect::baseMultiplier,
LeveledStatusEffect::amount, LeveledStatusEffect::amount,
).build() ).build()
} }
} }

View File

@ -2,8 +2,8 @@ package ru.dbotthepony.kstarbound.defs.item
import ru.dbotthepony.kstarbound.defs.ThingDescription import ru.dbotthepony.kstarbound.defs.ThingDescription
import ru.dbotthepony.kstarbound.defs.util.enrollMap 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.io.json.INativeJsonHolder import ru.dbotthepony.kstarbound.io.json.builder.INativeJsonHolder
import ru.dbotthepony.kstarbound.util.NotNullVar import ru.dbotthepony.kstarbound.util.NotNullVar
open class ItemPrototype : IItemDefinition, INativeJsonHolder { open class ItemPrototype : IItemDefinition, INativeJsonHolder {

View File

@ -1,11 +1,7 @@
package ru.dbotthepony.kstarbound.defs.item package ru.dbotthepony.kstarbound.defs.item
import com.google.gson.GsonBuilder
import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonWriter import com.google.gson.stream.JsonWriter
import ru.dbotthepony.kstarbound.io.json.EnumAdapter import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
import ru.dbotthepony.kstarbound.io.json.IStringSerializable
import ru.dbotthepony.kstarbound.registerTypeAdapter
enum class ItemRarity(val canonical: String) : IStringSerializable { enum class ItemRarity(val canonical: String) : IStringSerializable {
COMMON("Common"), COMMON("Common"),

View File

@ -2,7 +2,7 @@ package ru.dbotthepony.kstarbound.defs.item
import ru.dbotthepony.kstarbound.defs.MaterialReference import ru.dbotthepony.kstarbound.defs.MaterialReference
import ru.dbotthepony.kstarbound.defs.util.enrollMap 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() { class LiquidItemPrototype : ItemPrototype() {
var liquid: MaterialReference? = null var liquid: MaterialReference? = null

View File

@ -2,7 +2,7 @@ package ru.dbotthepony.kstarbound.defs.item
import ru.dbotthepony.kstarbound.defs.MaterialReference import ru.dbotthepony.kstarbound.defs.MaterialReference
import ru.dbotthepony.kstarbound.defs.util.enrollMap 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() { class MaterialItemPrototype : ItemPrototype() {
var material: MaterialReference? = null var material: MaterialReference? = null

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs.liquid package ru.dbotthepony.kstarbound.defs.liquid
import com.google.gson.GsonBuilder 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.kstarbound.registerTypeAdapter
import ru.dbotthepony.kvector.vector.Color import ru.dbotthepony.kvector.vector.Color

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs.parallax package ru.dbotthepony.kstarbound.defs.parallax
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
class ParallaxPrototype { class ParallaxPrototype {
var verticalOrigin = 0.0 var verticalOrigin = 0.0

View File

@ -5,7 +5,7 @@ import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken import com.google.gson.stream.JsonToken
import com.google.gson.stream.JsonWriter 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 ru.dbotthepony.kvector.vector.ndouble.Vector2d
import kotlin.properties.Delegates import kotlin.properties.Delegates

View File

@ -8,8 +8,8 @@ import org.apache.logging.log4j.LogManager
import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.Starbound
import ru.dbotthepony.kstarbound.defs.* import ru.dbotthepony.kstarbound.defs.*
import ru.dbotthepony.kstarbound.defs.image.ImageReference import ru.dbotthepony.kstarbound.defs.image.ImageReference
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
import ru.dbotthepony.kstarbound.io.json.EnumAdapter import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
import ru.dbotthepony.kstarbound.registerTypeAdapter import ru.dbotthepony.kstarbound.registerTypeAdapter
import ru.dbotthepony.kstarbound.util.NotNullVar import ru.dbotthepony.kstarbound.util.NotNullVar
import ru.dbotthepony.kvector.vector.Color import ru.dbotthepony.kvector.vector.Color
@ -205,9 +205,9 @@ class ActionProjectile : IConfigurableAction {
companion object { companion object {
val ADAPTER = BuilderAdapter.Builder(::ActionProjectile, val ADAPTER = BuilderAdapter.Builder(::ActionProjectile,
ActionProjectile::type, ActionProjectile::type,
ActionProjectile::angle, ActionProjectile::angle,
ActionProjectile::inheritDamageFactor, ActionProjectile::inheritDamageFactor,
).ignoreKey("action").build() ).ignoreKey("action").build()
} }
} }
@ -224,7 +224,7 @@ class ActionSound : IConfigurableAction {
companion object { companion object {
val ADAPTER = BuilderAdapter.Builder(::ActionSound, val ADAPTER = BuilderAdapter.Builder(::ActionSound,
ActionSound::options, ActionSound::options,
).ignoreKey("action").build() ).ignoreKey("action").build()
} }
} }
@ -242,8 +242,8 @@ class ActionLoop : IConfigurableAction {
companion object { companion object {
val ADAPTER = BuilderAdapter.Builder(::ActionLoop, val ADAPTER = BuilderAdapter.Builder(::ActionLoop,
ActionLoop::count, ActionLoop::count,
ActionLoop::body, ActionLoop::body,
).ignoreKey("action").build() ).ignoreKey("action").build()
} }
} }
@ -260,7 +260,7 @@ class ActionActions : IConfigurableAction {
companion object { companion object {
val ADAPTER = BuilderAdapter.Builder(::ActionActions, val ADAPTER = BuilderAdapter.Builder(::ActionActions,
ActionActions::list, ActionActions::list,
).ignoreKey("action").build() ).ignoreKey("action").build()
} }
} }

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs.projectile package ru.dbotthepony.kstarbound.defs.projectile
import com.google.gson.stream.JsonWriter 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 { enum class ProjectilePhysics(vararg aliases: String) : IStringSerializable {
GAS, GAS,

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs.tile package ru.dbotthepony.kstarbound.defs.tile
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
data class MaterialModifier( data class MaterialModifier(
val modId: Int, val modId: Int,

View File

@ -2,7 +2,7 @@ package ru.dbotthepony.kstarbound.defs.tile
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import ru.dbotthepony.kstarbound.Starbound 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 const val TILE_COLOR_VARIANTS = 9

View File

@ -9,8 +9,8 @@ import com.google.gson.stream.JsonWriter
import it.unimi.dsi.fastutil.objects.ObjectArraySet import it.unimi.dsi.fastutil.objects.ObjectArraySet
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.Starbound
import ru.dbotthepony.kstarbound.io.json.EnumAdapter import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
import ru.dbotthepony.kstarbound.registerTypeAdapter import ru.dbotthepony.kstarbound.registerTypeAdapter
import ru.dbotthepony.kstarbound.util.WriteOnce import ru.dbotthepony.kstarbound.util.WriteOnce
import ru.dbotthepony.kstarbound.world.ITileGetter import ru.dbotthepony.kstarbound.world.ITileGetter

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs.tile package ru.dbotthepony.kstarbound.defs.tile
import com.google.gson.GsonBuilder 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.kstarbound.registerTypeAdapter
import ru.dbotthepony.kvector.vector.Color import ru.dbotthepony.kvector.vector.Color

View File

@ -6,8 +6,8 @@ import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter import com.google.gson.stream.JsonWriter
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import ru.dbotthepony.kstarbound.io.ColorTypeAdapter import ru.dbotthepony.kstarbound.io.ColorTypeAdapter
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
import ru.dbotthepony.kstarbound.io.json.EnumAdapter import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
import ru.dbotthepony.kvector.vector.Color import ru.dbotthepony.kvector.vector.Color
import ru.dbotthepony.kvector.vector.ndouble.Vector2d import ru.dbotthepony.kvector.vector.ndouble.Vector2d
import kotlin.properties.ReadWriteProperty import kotlin.properties.ReadWriteProperty

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs.world package ru.dbotthepony.kstarbound.defs.world
import com.google.gson.stream.JsonWriter 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 { enum class SkyType(vararg aliases: String) : IStringSerializable {
ATMOSPHERIC, ATMOSPHERIC,

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs.world package ru.dbotthepony.kstarbound.defs.world
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
class WorldProperties { class WorldProperties {
var nonCombat = false var nonCombat = false

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs.world.dungeon package ru.dbotthepony.kstarbound.defs.world.dungeon
import com.google.gson.stream.JsonWriter 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 { enum class BeamUpRule(vararg aliases: String) : IStringSerializable {
NOWHERE, NOWHERE,

View File

@ -3,8 +3,8 @@ package ru.dbotthepony.kstarbound.defs.world.dungeon
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import ru.dbotthepony.kstarbound.defs.world.SkyParameters import ru.dbotthepony.kstarbound.defs.world.SkyParameters
import ru.dbotthepony.kstarbound.defs.world.WorldProperties import ru.dbotthepony.kstarbound.defs.world.WorldProperties
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
import ru.dbotthepony.kstarbound.io.json.EnumAdapter import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
import ru.dbotthepony.kstarbound.registerTypeAdapter import ru.dbotthepony.kstarbound.registerTypeAdapter
import kotlin.properties.Delegates import kotlin.properties.Delegates

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.kstarbound.defs.world.dungeon package ru.dbotthepony.kstarbound.defs.world.dungeon
import com.google.gson.stream.JsonWriter 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 { enum class DungeonType(vararg aliases: String) : IStringSerializable {
FLOATING("FloatingDungeon"), FLOATING("FloatingDungeon"),

View File

@ -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.ImmutableMap
import com.google.common.collect.ImmutableSet import com.google.common.collect.ImmutableSet
@ -15,6 +15,8 @@ import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.Starbound
import ru.dbotthepony.kstarbound.defs.util.flattenJsonElement 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 ru.dbotthepony.kstarbound.util.NotNullVar
import kotlin.properties.Delegates import kotlin.properties.Delegates
import kotlin.reflect.KClass 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> { fun <V> add(property: KMutableProperty1<T, V>, adapter: TypeAdapter<V>, configurator: PropertyConfigurator<T, V>.() -> Unit = {}): Builder<T> {
val config = _add(property, adapter, configurator) val config = _add(property, adapter, configurator)
properties.add(WrappedProperty( properties.add(
WrappedProperty(
property, property,
adapter, adapter,
mustBePresent = config.mustBePresent mustBePresent = config.mustBePresent
)) )
)
return this return this
} }
@ -327,11 +331,13 @@ class BuilderAdapter<T : Any> private constructor(
check(!extraPropertiesAreFatal) { "Can't have both flattened properties and extraPropertiesAreFatal" } check(!extraPropertiesAreFatal) { "Can't have both flattened properties and extraPropertiesAreFatal" }
flatProperties.add(WrappedProperty( flatProperties.add(
WrappedProperty(
property, property,
adapter, adapter,
mustBePresent = config.mustBePresent mustBePresent = config.mustBePresent
)) )
)
return this return this
} }

View File

@ -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.ImmutableList
import com.google.common.collect.ImmutableMap 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.JsonToken
import com.google.gson.stream.JsonWriter import com.google.gson.stream.JsonWriter
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap
import ru.dbotthepony.kstarbound.set
import java.util.Arrays import java.util.Arrays
import java.util.stream.Stream import java.util.stream.Stream
import kotlin.reflect.KClass import kotlin.reflect.KClass

View File

@ -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.ImmutableList
import com.google.common.collect.ImmutableMap 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.enrollMap
import ru.dbotthepony.kstarbound.defs.util.flattenJsonElement import ru.dbotthepony.kstarbound.defs.util.flattenJsonElement
import ru.dbotthepony.kstarbound.getValue 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 ru.dbotthepony.kstarbound.setValue
import java.lang.reflect.Constructor import java.lang.reflect.Constructor
import kotlin.jvm.internal.DefaultConstructorMarker import kotlin.jvm.internal.DefaultConstructorMarker

View File

@ -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.TypeAdapter
import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonReader

View File

@ -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.common.collect.ImmutableList
import com.google.gson.JsonSyntaxException 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.JsonReader
import com.google.gson.stream.JsonToken import com.google.gson.stream.JsonToken
import com.google.gson.stream.JsonWriter import com.google.gson.stream.JsonWriter
import ru.dbotthepony.kstarbound.Starbound
fun <T : Any> TypeAdapter<T>.asList(valueTransformer: (T) -> T = { it }): TypeAdapter<List<T>> { fun <T : Any> TypeAdapter<T>.asList(valueTransformer: (T) -> T = { it }): TypeAdapter<List<T>> {
return ListAdapter(this, valueTransformer = valueTransformer) return ListAdapter(this, valueTransformer = valueTransformer)

View File

@ -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.common.collect.ImmutableMap
import com.google.gson.TypeAdapter import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken import com.google.gson.stream.JsonToken
import com.google.gson.stream.JsonWriter 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>>() { 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)) constructor(keyType: Class<K>, valueType: Class<V>) : this(LazyTypeProvider(keyType), LazyTypeProvider(valueType))

View File

@ -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.common.collect.ImmutableMap
import com.google.gson.TypeAdapter import com.google.gson.TypeAdapter