-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
79 additions
and
77 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
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,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
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
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
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
31 changes: 0 additions & 31 deletions
31
...erializers/src/main/kotlin/com/mineinabyss/idofront/serialization/PotionDataSerializer.kt
This file was deleted.
Oops, something went wrong.
9 changes: 6 additions & 3 deletions
9
...zers/src/main/kotlin/com/mineinabyss/idofront/serialization/PotionEffectTypeSerializer.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,31 +1,34 @@ | ||
package com.mineinabyss.idofront.serialization | ||
|
||
import com.mineinabyss.idofront.util.toMCKey | ||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.descriptors.SerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
import org.bukkit.Registry | ||
import org.bukkit.potion.PotionEffectType | ||
|
||
@JvmInline | ||
@Serializable | ||
@SerialName("PotionEffectType") | ||
private value class PotionEffectTypeSurrogate(val type: String) { | ||
|
||
init { | ||
require(type.isNotBlank() && PotionEffectType.getByName(type) != null) { "PotionEffectType must be valid" } | ||
require(type.isNotBlank() && Registry.POTION_EFFECT_TYPE.get(type.toMCKey()) != null) { "PotionEffectType must be valid" } | ||
} | ||
} | ||
|
||
object PotionEffectTypeSerializer : KSerializer<PotionEffectType> { | ||
override val descriptor: SerialDescriptor = PotionEffectTypeSurrogate.serializer().descriptor | ||
override fun serialize(encoder: Encoder, value: PotionEffectType) { | ||
val surrogate = PotionEffectTypeSurrogate(value.name) | ||
val surrogate = PotionEffectTypeSurrogate(value.key.asString()) | ||
encoder.encodeSerializableValue(PotionEffectTypeSurrogate.serializer(), surrogate) | ||
} | ||
|
||
override fun deserialize(decoder: Decoder): PotionEffectType { | ||
val surrogate = decoder.decodeSerializableValue(PotionEffectTypeSurrogate.serializer()) | ||
return PotionEffectType.getByName(surrogate.type)!! | ||
return Registry.POTION_EFFECT_TYPE.get(surrogate.type.toMCKey())!! | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...erializers/src/main/kotlin/com/mineinabyss/idofront/serialization/PotionTypeSerializer.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,26 @@ | ||
package com.mineinabyss.idofront.serialization | ||
|
||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.descriptors.SerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
import org.bukkit.potion.PotionType | ||
|
||
@Serializable | ||
@SerialName("PotionType") | ||
private class PotionTypeSurrogate(val type: PotionType) | ||
|
||
object PotionTypeSerializer : KSerializer<PotionType> { | ||
override val descriptor: SerialDescriptor = PotionTypeSurrogate.serializer().descriptor | ||
|
||
override fun serialize(encoder: Encoder, value: PotionType) { | ||
encoder.encodeSerializableValue(PotionTypeSurrogate.serializer(), PotionTypeSurrogate(value)) | ||
} | ||
|
||
override fun deserialize(decoder: Decoder): PotionType { | ||
val surrogate = decoder.decodeSerializableValue(PotionTypeSurrogate.serializer()) | ||
return surrogate.type | ||
} | ||
} |
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
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
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