File not found Fixes
Dieser Commit ist enthalten in:
Ursprung
ec2a74de1f
Commit
af638716ad
@ -15,7 +15,14 @@ data class GroupData(val name: String, val fights: MutableList<Int>)
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
class Groups {
|
||||
companion object {
|
||||
private var groups: GroupsData = Cbor.decodeFromByteArray(kGroupsFile.readBytes())
|
||||
private var groups: GroupsData = if (kGroupsFile.exists()) {
|
||||
Cbor.decodeFromByteArray(kGroupsFile.readBytes())
|
||||
} else {
|
||||
kGroupsFile.createNewFile()
|
||||
kGroupsFile.writeBytes(Cbor.encodeToByteArray(GroupsData(mutableListOf())))
|
||||
|
||||
GroupsData(mutableListOf())
|
||||
}
|
||||
|
||||
fun getGroup(name: String): GroupData? {
|
||||
return groups.groups.find { it.name == name }
|
||||
|
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren