Skip to content

Commit

Permalink
feat: bump to 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Jan 15, 2024
1 parent 73133c8 commit 2d3e32e
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 79 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=com.mineinabyss
version=0.20
version=0.21
30 changes: 15 additions & 15 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
[versions]
minecraft = "1.20.2-R0.1-SNAPSHOT"
kotlin = "1.9.10"
minecraft = "1.20.4-R0.1-SNAPSHOT"
kotlin = "1.9.20"
jvm = "17"

anvilgui = "1.9.0-SNAPSHOT"
anvilgui = "1.9.2-SNAPSHOT"
coroutines = "1.7.3"
compose = "1.5.2"
exposed = "0.44.0"
compose = "1.5.11"
exposed = "0.46.0"
fastutil = "8.2.2"
fawe = "2.8.0"
fawe = "2.8.4"
junit = "5.10.0"
kaml = "0.55.0"
kaml = "0.57.0"
kmongo = "4.8.0" #Deprecated due to MongoDB including Kotlin
kotest = "5.7.2"
kotest = "5.8.0"
kt-statistics = "1.2.1"
ktor = "2.3.6"
logback = "1.4.11"
mccoroutine = "2.13.0"
mockbukkit = "3.24.1"
mccoroutine = "2.14.0"
mockbukkit = "3.65.0"
mockk = "1.13.8"
modelengine = "R4.0.2"
modelengine = "R4.0.3"
protocollib = "5.1.0"
reflections = "0.10.2"
serialization = "1.6.0"
serialization = "1.6.2"
sqlite-jdbc = "3.43.0.0"
vault = "1.7"
worldguard = "7.1.0-SNAPSHOT"
creative = "1.3.0"
creative = "1.6.0"

mythic-dist = "5.2.6"
mythiccrucible = "1.6.0"
oraxen = "1.164.0"
oraxen = "1.167.0"
itemsadder = "3.5.0b"


# Gradle deps
dokka = "1.9.0"
shadowjar = "8.1.1"
dependencyversions = "0.48.0"
userdev = "1.5.8"
userdev = "1.5.11"

[libraries]
minecraft-papermc = { module = "io.papermc.paper:paper-api", version.ref = "minecraft" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ChildManager : ChildRunning {

with(command) {
//if there are extra arguments and sub-commands exist, we first try to match them to any sub-commands
if (argumentsWereSent && subcommand.names.contains(firstArgument)) {
if (argumentsWereSent && firstArgument in subcommand.names) {
applySharedTo(subcommand)
subcommand.runWith(init)
this.executedCommand = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ package com.mineinabyss.idofront.nms.aliases
import net.minecraft.server.level.ServerLevel
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.level.Level
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld
import org.bukkit.craftbukkit.v1_20_R2.entity.*
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftInventoryPlayer
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld
import org.bukkit.craftbukkit.v1_20_R3.entity.*
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftInventoryPlayer
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack
import org.bukkit.entity.*
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.PlayerInventory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.NbtIo
import org.bukkit.Bukkit
import org.bukkit.OfflinePlayer
import org.bukkit.craftbukkit.v1_20_R2.CraftServer
import org.bukkit.craftbukkit.v1_20_R3.CraftServer
import java.io.File
import java.nio.file.Files
import java.util.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.NbtIo
import net.minecraft.nbt.Tag
import org.bukkit.NamespacedKey
import org.bukkit.craftbukkit.v1_20_R2.persistence.CraftPersistentDataAdapterContext
import org.bukkit.craftbukkit.v1_20_R2.persistence.CraftPersistentDataTypeRegistry
import org.bukkit.craftbukkit.v1_20_R3.persistence.CraftPersistentDataAdapterContext
import org.bukkit.craftbukkit.v1_20_R3.persistence.CraftPersistentDataTypeRegistry
import org.bukkit.persistence.PersistentDataAdapterContext
import org.bukkit.persistence.PersistentDataContainer
import org.bukkit.persistence.PersistentDataType
Expand All @@ -26,7 +26,7 @@ class WrappedPDC(
override fun <T, Z : Any> set(key: NamespacedKey, type: PersistentDataType<T, Z>, value: Z) {
compoundTag.put(
key.toString(),
DATA_TYPE_REGISTRY.wrap(type.primitiveType, type.toPrimitive(value, adapterContext))
DATA_TYPE_REGISTRY.wrap(type, type.toPrimitive(value, adapterContext))
)
}

Expand All @@ -38,7 +38,7 @@ class WrappedPDC(

override fun <T : Any, Z> get(key: NamespacedKey, type: PersistentDataType<T, Z>): Z? {
val value: Tag = compoundTag.get(key.toString()) ?: return null
return type.fromPrimitive(DATA_TYPE_REGISTRY.extract(type.primitiveType, value), adapterContext)
return type.fromPrimitive(DATA_TYPE_REGISTRY.extract<T, Tag>(type, value), adapterContext)
}

override fun <T : Any, Z : Any> getOrDefault(
Expand All @@ -56,6 +56,14 @@ class WrappedPDC(

override fun isEmpty(): Boolean = compoundTag.isEmpty

override fun copyTo(other: PersistentDataContainer, replace: Boolean) {
val target = (other as? WrappedPDC)?.compoundTag ?: return
if (replace) target.tags.putAll(compoundTag.tags)
else compoundTag.tags.forEach { (key, value) ->
if (key !in target) target.put(key, value)
}
}

override fun getAdapterContext(): PersistentDataAdapterContext = adapterContext

override fun serializeToBytes(): ByteArray {
Expand Down

This file was deleted.

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())!!
}
}
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
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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.NamespacedKey
import org.bukkit.Registry
import org.bukkit.enchantments.Enchantment

@Serializable
Expand All @@ -24,8 +26,8 @@ data class SerializableEnchantment(
@SerialName("Enchantment")
private value class EnchantmentSurrogate(val enchant: String) {
init {
require(Enchantment.getByKey(enchant.getCorrectKey()) != null)
{ "Enchantment must be valid. Valid ones are ${Enchantment.values().map { it.key }}" }
require(Registry.ENCHANTMENT.get(enchant.toMCKey()) != null)
{ "Enchantment must be valid. Valid ones are ${Registry.ENCHANTMENT.map { it.key }}" }
}
}

Expand All @@ -38,9 +40,6 @@ object EnchantmentSerializer : KSerializer<Enchantment> {

override fun deserialize(decoder: Decoder): Enchantment {
val surrogate = decoder.decodeSerializableValue(EnchantmentSurrogate.serializer())
return Enchantment.getByKey(surrogate.enchant.getCorrectKey())!!
return Registry.ENCHANTMENT.get(surrogate.enchant.toMCKey())!!
}
}

private fun String.getCorrectKey() =
if (":" in this) NamespacedKey.fromString(this) else NamespacedKey.minecraft(this)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.google.common.collect.HashMultimap
import com.mineinabyss.idofront.di.DI
import com.mineinabyss.idofront.messaging.logWarn
import com.mineinabyss.idofront.plugin.Plugins
import com.mineinabyss.idofront.plugin.Services
import dev.lone.itemsadder.api.CustomStack
import io.lumine.mythiccrucible.MythicCrucible
import io.th0rgal.oraxen.OraxenPlugin
Expand All @@ -26,7 +25,7 @@ import org.bukkit.inventory.meta.Damageable
import org.bukkit.inventory.meta.KnowledgeBookMeta
import org.bukkit.inventory.meta.LeatherArmorMeta
import org.bukkit.inventory.meta.PotionMeta
import org.bukkit.potion.PotionData
import org.bukkit.potion.PotionType
import java.util.*

/**
Expand All @@ -50,7 +49,7 @@ data class SerializableItemStack(
@EncodeDefault(NEVER) val enchantments: List<SerializableEnchantment>? = null,
@EncodeDefault(NEVER) val itemFlags: List<ItemFlag>? = null,
@EncodeDefault(NEVER) val attributeModifiers: List<SerializableAttribute>? = null,
@EncodeDefault(NEVER) val potionData: @Serializable(with = PotionDataSerializer::class) PotionData? = null,
@EncodeDefault(NEVER) val potionType: @Serializable(with = PotionTypeSerializer::class) PotionType? = null,
@EncodeDefault(NEVER) val knowledgeBookRecipes: List<String>? = null,
@EncodeDefault(NEVER) val color: @Serializable(with = ColorSerializer::class) Color? = null,
@EncodeDefault(NEVER) val tag: String? = null,
Expand Down Expand Up @@ -107,8 +106,7 @@ data class SerializableItemStack(

// Support for our prefab system in geary.
prefab?.takeIf { Properties.PREFAB !in ignoreProperties }?.let {
encodePrefab?.invoke(applyTo, it)
?: logWarn("Tried to use prefab tag when reading item, but no prefab provider was registered")
encodePrefab.invoke(applyTo, it)
}

// Modify item
Expand All @@ -131,8 +129,8 @@ data class SerializableItemStack(
if (itemFlags?.isNotEmpty() == true && Properties.ITEM_FLAGS !in ignoreProperties) meta.addItemFlags(*itemFlags.toTypedArray())
if (color != null && Properties.COLOR !in ignoreProperties) (meta as? PotionMeta)?.setColor(color)
?: (meta as? LeatherArmorMeta)?.setColor(color)
if (potionData != null && Properties.POTION_DATA !in ignoreProperties) (meta as? PotionMeta)?.basePotionData =
potionData
if (potionType != null && Properties.POTION_TYPE !in ignoreProperties) (meta as? PotionMeta)?.basePotionType =
potionType
if (enchantments != null && Properties.ENCHANTMENTS !in ignoreProperties) {
enchantments.forEach { meta.addEnchant(it.enchant, it.level, true) }
}
Expand Down Expand Up @@ -164,7 +162,7 @@ data class SerializableItemStack(
ENCHANTMENTS,
ITEM_FLAGS,
ATTRIBUTE_MODIFIERS,
POTION_DATA,
POTION_TYPE,
KNOWLEDGE_BOOK_RECIPES,
COLOR,
}
Expand Down Expand Up @@ -196,7 +194,7 @@ fun ItemStack.toSerializable(): SerializableItemStack = with(itemMeta) {
?: emptyList()).takeIf { it.isNotEmpty() },
itemFlags = (this?.itemFlags?.toList() ?: listOf()).takeIf { it.isNotEmpty() },
attributeModifiers = attributeList.takeIf { it.isNotEmpty() },
potionData = (this as? PotionMeta)?.basePotionData,
potionType = (this as? PotionMeta)?.basePotionType,
color = (this as? PotionMeta)?.color ?: (this as? LeatherArmorMeta)?.color
) //TODO perhaps this should encode prefab too?
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ import org.bukkit.NamespacedKey
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.RecipeChoice
import org.bukkit.inventory.meta.PotionMeta
import org.bukkit.potion.PotionData
import org.bukkit.potion.PotionType

@Serializable
@SerialName("potionmix")
class PotionMixRecipeIngredients(
private val input: SerializableItemStack =
ItemStack(Material.POTION).editItemMeta<PotionMeta> { basePotionData = PotionData(PotionType.WATER) }
.toSerializable(),
ItemStack(Material.POTION).editItemMeta<PotionMeta> { basePotionType = PotionType.WATER }.toSerializable(),
private val ingredient: SerializableItemStack,
) {
fun toPotionMix(key: NamespacedKey, result: ItemStack): PotionMix {
Expand Down

0 comments on commit 2d3e32e

Please sign in to comment.