-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom serialization for identifiers
- Loading branch information
1 parent
3d5eccc
commit 9e90c7f
Showing
5 changed files
with
34 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/main/kotlin/com/github/quiltservertools/ledger/config/ActionsSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package com.github.quiltservertools.ledger.config | ||
|
||
import com.github.quiltservertools.ledger.config.util.IdentifierWrapper | ||
import com.uchuhimo.konf.ConfigSpec | ||
import net.minecraft.util.Identifier | ||
|
||
object ActionsSpec : ConfigSpec() { | ||
val typeBlacklist by required<List<String>>() | ||
val worldBlacklist by required<List<IdentifierWrapper>>() | ||
val objectBlacklist by required<List<IdentifierWrapper>>() | ||
val worldBlacklist by required<List<Identifier>>() | ||
val objectBlacklist by required<List<Identifier>>() | ||
val sourceBlacklist by required<List<String>>() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/kotlin/com/github/quiltservertools/ledger/config/util/IdentifierSerialization.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.github.quiltservertools.ledger.config.util | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator | ||
import com.fasterxml.jackson.core.JsonParser | ||
import com.fasterxml.jackson.databind.DeserializationContext | ||
import com.fasterxml.jackson.databind.JsonDeserializer | ||
import com.fasterxml.jackson.databind.JsonSerializer | ||
import com.fasterxml.jackson.databind.SerializerProvider | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize | ||
import net.minecraft.util.Identifier | ||
|
||
object IdentifierSerializer : JsonSerializer<Identifier>() { | ||
override fun serialize(value: Identifier, gen: JsonGenerator, serializers: SerializerProvider) { | ||
gen.writeString(value.toString()) | ||
} | ||
} | ||
|
||
object IdentifierDeserializer : JsonDeserializer<Identifier>() { | ||
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Identifier = Identifier.of(p.valueAsString) | ||
} | ||
|
||
@JsonSerialize(using = IdentifierSerializer::class) | ||
@JsonDeserialize(using = IdentifierDeserializer::class) | ||
abstract class IdentifierMixin |
13 changes: 0 additions & 13 deletions
13
src/main/kotlin/com/github/quiltservertools/ledger/config/util/IdentifierWrapper.kt
This file was deleted.
Oops, something went wrong.