Releases: SilkMC/silk
1.2.0
New features
fabrikmc-nbt module
Thanks to @F0Xde, the new nbt module brings nbt serialization with kotlinx.serialization, an nbt builder and nbt conversion.
For serialization simply annotate a class with @Serializable
and use your kotlinx.serialization features as usual.
For encoding and decoding, use:
Nbt.encodeToNbtElement(value)
Nbt.decodeFromNbtElement<T>(nbtElement)
The nbt dsl works as follows:
val compound = nbtCompound {
put("age", 32)
put("name", "John")
list("friends") {
add("Peter")
}
}
fabrikmc-persistence module
The persistence module allows you to store data persistently on holders like Chunks, Entities and more. Additionally, this module makes use of the nbt module and allows you to store any class annotated with @serializable on your persistent data holders.
@Serializable
private data class Person(val name: String, val age: Int, val friends: List<String>)
// specify the key
private val personKey by compoundKey<Person>()
// to save the data
fun Player.storePerson() {
persistentCompound.let {
it[personKey] = Person(
"John",
32,
listOf("Peter", "James", "Sofia")
)
}
}
// to read the data
fun Player.loadPerson() = persistentCompound[personKey]
Brigardier wrapper improvements
The Brigardier wrapper now allows you to skip passing the argument type to argument builders for simple types by using a reified generic type instead.
Additionally, you can now use the resolveArgument()
function to resolve arguments without having to specify their names.
For a single argument:
argument<String>("name") {
simpleExecutes {
val name = resolveArgument()
}
}
Or for multiple arguments:
argument<String>("name") name@{
argument<Int>("age") age@{
simpleExecutes {
val name = this@name.resolveArgument()
val age = this@age.resolveArgument()
}
}
}
Furthermore, the Brigardier wrapper now supports chaining of the argument
and literal
functions.
Sideboard API
You can now easily create sideboards with changing content. The sideboards make use of kotlinx.coroutines flows, this means that the update logic is very flexible.
A simple example would be:
sideboard(
literalText("Simple Sideboard") { color = 0x6DFF41 }
) {
literalLine("Hey, how")
literalLine("are you?")
literalLine(" ")
lineChangingPeriodically(1000) {
literalText("changing color") {
color = (0x000000..0xFFFFFF).random()
}
}
}
the coroutineTask function
In the scope of the function, you now have access to the following values:
- round
- roundFromZero
- counterDownToOne
- counterDownToZero
Packets
You can now send packets to an Iterable of Players using Iterable<ServerPlayerEntity>::sendPacket
.
Position conversion class
The FabrikPosition
class now supports even more types of Positions and Locations, e.g. ChunkSectionPos and more.
Internal changes
mcCoroutineScope
andfabrikCoroutineScope
now use a SupervisorJob to change the behaviour when exceptions are thrown- mixins no longer target the server exclusively
Breaking Changes
- a
CoroutineTask
can now be cancelled using thecancel()
function provided by kotlinx.coroutines - the default for the register parameter of the
command
function is now set to true - the
simpleExecutes
function of the Brigardier wrapper now passes the command context asthis
instead ofit
1.1.0
1.0.0
0.4.2-SNAPSHOT
Merge pull request #7 from bluefireoly/scoreboard Update main