使い方と制約
装備のコピーと安全な設定だけを公開します。設定変更で資源・アップグレード・電力を操作したり権限を迂回したりしません。処理中の変更競合は拒否します。
NebulaMachineConfiguration
package dev.nebulastorage.api.platform
import net.minecraft.network.chat.Component
import net.minecraft.world.item.ItemStack
import java.util.Collections
/** Detached display of upgrades owned by the physical machine; no installation or resource mutation is authorized by this view. */
interface NebulaMachineEquipmentView { fun equipment(): List<NebulaMachineEquipment> }
class NebulaMachineEquipment(item: ItemStack, val installed: Int, val limit: Int) {
private val prototype = item.copy()
val item: ItemStack get() = prototype.copy()
init { require(!item.isEmpty && limit in 1..64 && installed in 0..limit) }
}
/** Bounded local setting. IDs and values are stable protocol identities, labels are translatable display data. */
class NebulaMachineSetting(val id: String, label: Component, values: List<NebulaMachineSettingValue>, val selected: String, val editable: Boolean = true) {
private val title = label.copy()
val label get() = title.copy()
val values: List<NebulaMachineSettingValue> = Collections.unmodifiableList(values.toList())
init {
require(id.matches(Regex("[a-z0-9_.:-]{1,64}")) && values.size in 1..16)
require(values.map { it.id }.distinct().size == values.size && values.any { it.id == selected })
}
}
class NebulaMachineSettingValue(val id: String, label: Component) {
private val title = label.copy()
val label get() = title.copy()
init { require(id.matches(Regex("[a-z0-9_.:-]{1,64}"))) }
}
/**
* Settings belong to the certified physical owner and share its chunk persistence.
* Queries are read-only; applying an advertised value must not change resources, energy, upgrades, security or ownership.
* Nebula revalidates loaded ownership and refuses changes while any operation owns a lane.
*/
interface NebulaMachineConfiguration {
fun settings(): List<NebulaMachineSetting>
fun configure(id: String, value: String): Boolean
}
ソース
src/main/kotlin/dev/nebulastorage/api/platform/NebulaMachineConfiguration.kt; editorial/ja.json
43b4d12d69e6033c24fa8c39dac383ef2429b446