···11package me.lukiiy.mapling
2233+/**
44+ * Data holder for a [ManagedWorld]. Can hold positions, areas and cusotm values.
55+ */
36class WorldData(private val values: MutableMap<String, Any> = linkedMapOf(), private val sections: MutableMap<String, WorldData> = linkedMapOf(), private val positions: MutableMap<String, Position> = linkedMapOf(), private val areas: MutableMap<String, Pair<Position, Position>> = linkedMapOf()) {
47 fun set(key: String, value: Any): WorldData {
58 if (value is Position) return setPosition(key, value)
···2932 }
3033 }
31343535+ /**
3636+ * Gets or creates a nested [WorldData] section, serving as sort of a group.
3737+ *
3838+ * @param name Dot-separated path, (like "spawns.overworld")
3939+ * @return The section at that path (created if absent)
4040+ */
3241 fun section(name: String): WorldData {
3342 val parts = name.split('.').filter { it.isNotBlank() }
3443 var current = this
···3847 return current
3948 }
40495050+ /**
5151+ * Gets the nested [WorldData] section at the given dot-separated path, if it exists. Does not create missing sections.
5252+ *
5353+ * @param name Dot-separated path, (like "spawns.overworld")
5454+ * @return The section at that path, or `null` if any part of the path doesn't exist
5555+ */
4156 fun getSection(name: String): WorldData? {
4257 val parts = name.split('.').filter { it.isNotBlank() }
4358 var current: WorldData = this