Skip to content

Configs

Sven Rahn edited this page Jun 29, 2018 · 2 revisions

Official docs: https://docs.spongepowered.org/stable/en/plugin/configuration/index.html

For multiple reads and writes:

val loader = script.path.parent.resolve("my-config.conf").toConfigurationLoader()
val rootNode = loader.load()
val node1 = rootNode.getNode("test-node")
val value = node1.string

rootNode.getNode("save-test").setValue("TestValue123")

loader.save(rootNode)

Or the simpler version which is more suited for read-only configs and might not be as quick for multiple reads:

Read:

val rootNode = script.path.parent.resolve("my-config.conf").loadConfig()
val node1 = rootNode.getNode("test-node")
val value = node1.string
Clone this wiki locally