feat: Update to 1.21.8

This commit is contained in:
2025-11-24 03:39:23 -07:00
parent a85ef10c3c
commit 00c74a0f9d
9 changed files with 8 additions and 57 deletions

View File

@@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "net.axay" group = "net.axay"
version = "1.21.1-VAL" version = "1.21.8-VAL"
description = "A Kotlin API for Minecraft plugins using the Spigot or Paper toolchain" description = "A Kotlin API for Minecraft plugins using the Spigot or Paper toolchain"
@@ -16,7 +16,7 @@ plugins {
id("org.jetbrains.dokka") version "1.9.20" id("org.jetbrains.dokka") version "1.9.20"
id("io.papermc.paperweight.userdev") version "1.7.1" id("io.papermc.paperweight.userdev") version "2.0.0-SNAPSHOT"
} }
repositories { repositories {
@@ -24,7 +24,7 @@ repositories {
} }
dependencies { dependencies {
paperweight.paperDevBundle("1.21-R0.1-SNAPSHOT") paperweight.paperDevBundle("1.21.8-R0.1-SNAPSHOT")
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3") api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -5,21 +5,9 @@ package net.axay.kspigot.data
import net.axay.kspigot.annotations.NMS_General import net.axay.kspigot.annotations.NMS_General
import net.minecraft.core.component.DataComponents import net.minecraft.core.component.DataComponents
import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.CompoundTag
import org.bukkit.craftbukkit.entity.CraftEntity
import org.bukkit.craftbukkit.inventory.CraftItemStack import org.bukkit.craftbukkit.inventory.CraftItemStack
import org.bukkit.entity.Entity
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
@NMS_General
var Entity.nbtData: CompoundTag
get() {
val nbtTagCompound = CompoundTag()
(this as CraftEntity).handle.save(nbtTagCompound)
return nbtTagCompound
}
set(value) {
(this as CraftEntity).handle.load(value)
}
@NMS_General @NMS_General
val ItemStack.nbtData: CompoundTag val ItemStack.nbtData: CompoundTag

View File

@@ -61,7 +61,7 @@ val Entity.isStandingInMidAir: Boolean
* @throws NullPointerException if the entity doesn't have a max health value * @throws NullPointerException if the entity doesn't have a max health value
*/ */
val LivingEntity.realMaxHealth: Double val LivingEntity.realMaxHealth: Double
get() = getAttribute(Attribute.GENERIC_MAX_HEALTH)?.value get() = getAttribute(Attribute.MAX_HEALTH)?.value
?: throw NullPointerException("The entity does not have a max health value!") ?: throw NullPointerException("The entity does not have a max health value!")
/** /**
@@ -76,7 +76,7 @@ fun Damageable.kill() {
* @throws NullPointerException if the entity does not have a max health value * @throws NullPointerException if the entity does not have a max health value
*/ */
fun LivingEntity.heal() { fun LivingEntity.heal() {
health = getAttribute(Attribute.GENERIC_MAX_HEALTH)?.value health = getAttribute(Attribute.MAX_HEALTH)?.value
?: throw NullPointerException("The entity does not have a max health value!") ?: throw NullPointerException("The entity does not have a max health value!")
} }
@@ -132,18 +132,6 @@ fun Player.showOnlinePlayers() {
onlinePlayers.filter { it != this }.forEach { this.showPlayer(PluginInstance, it) } onlinePlayers.filter { it != this }.forEach { this.showPlayer(PluginInstance, it) }
} }
/**
* Spawns an entity without any variations in color, type etc...
*/
@Deprecated("This function is unstable and it cannot be guaranteed that it will work at any time in the future.")
@NMS_General
fun Location.spawnCleanEntity(entityType: EntityType): Entity? {
val craftWorld = world as? org.bukkit.craftbukkit.CraftWorld ?: return null
return craftWorld.makeEntity(this, entityType.entityClass!!)?.let {
craftWorld.handle.addFreshEntity(it)
return@let it.bukkitEntity
}
}
/** /**
* @param mainText title text * @param mainText title text

View File

@@ -21,7 +21,7 @@ val PlayerInteractEntityEvent.interactItem: ItemStack?
return when (this.hand) { return when (this.hand) {
EquipmentSlot.HAND -> p.inventory.itemInMainHand EquipmentSlot.HAND -> p.inventory.itemInMainHand
EquipmentSlot.OFF_HAND -> p.inventory.itemInOffHand EquipmentSlot.OFF_HAND -> p.inventory.itemInOffHand
EquipmentSlot.CHEST, EquipmentSlot.FEET, EquipmentSlot.HEAD, EquipmentSlot.LEGS, EquipmentSlot.BODY -> null EquipmentSlot.CHEST, EquipmentSlot.FEET, EquipmentSlot.HEAD, EquipmentSlot.LEGS, EquipmentSlot.BODY, EquipmentSlot.SADDLE -> null
} }
} }

View File

@@ -1,6 +1,6 @@
package net.axay.kspigot.localization package net.axay.kspigot.localization
import org.apache.commons.lang.text.StrSubstitutor import org.apache.commons.lang3.text.StrSubstitutor
import org.bukkit.entity.Player import org.bukkit.entity.Player
import java.io.InputStreamReader import java.io.InputStreamReader
import java.nio.charset.StandardCharsets import java.nio.charset.StandardCharsets

View File

@@ -88,7 +88,3 @@ class MaterialCircle(radius: Number, material: Material) : Circle(radius) {
class ParticleCircle(radius: Number, particle: KSpigotParticle) : Circle(radius) { class ParticleCircle(radius: Number, particle: KSpigotParticle) : Circle(radius) {
override val data = StructureDataParticle(particle) override val data = StructureDataParticle(particle)
} }
class EntityCircle(radius: Number, entityType: EntityType) : Circle(radius) {
override val data = StructureDataEntity(entityType)
}

View File

@@ -1,8 +1,6 @@
package net.axay.kspigot.structures package net.axay.kspigot.structures
import net.axay.kspigot.annotations.NMS_General import net.axay.kspigot.annotations.NMS_General
import net.axay.kspigot.data.nbtData
import net.axay.kspigot.extensions.bukkit.spawnCleanEntity
import net.axay.kspigot.extensions.geometry.SimpleLocation3D import net.axay.kspigot.extensions.geometry.SimpleLocation3D
import net.axay.kspigot.particles.KSpigotParticle import net.axay.kspigot.particles.KSpigotParticle
import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.CompoundTag
@@ -52,20 +50,6 @@ data class StructureDataBlock(
} }
} }
@NMS_General
data class StructureDataEntity(
val entityType: EntityType,
val nbtData: CompoundTag,
) : StructureData {
constructor(entity: Entity) : this(entity.type, entity.nbtData)
constructor(entityType: EntityType) : this(entityType, CompoundTag())
@Suppress("DEPRECATION")
override fun createAt(loc: Location) {
(loc.spawnCleanEntity(entityType) as CraftEntity).handle.load(nbtData)
}
}
data class StructureDataParticle( data class StructureDataParticle(
val particle: KSpigotParticle, val particle: KSpigotParticle,
) : StructureData { ) : StructureData {

View File

@@ -17,11 +17,6 @@ fun LocationArea.loadStructure(includeBlocks: Boolean = true, includeEntities: B
fillBlocks.mapTo(HashSet()) { fillBlocks.mapTo(HashSet()) {
SingleStructureData(it.location relationTo minLoc.blockLoc, StructureDataBlock(it)) SingleStructureData(it.location relationTo minLoc.blockLoc, StructureDataBlock(it))
} }
else emptySet(),
if (includeEntities)
entities.mapTo(HashSet()) {
SingleStructureData(it.location relationTo minLoc.blockLoc, StructureDataEntity(it))
}
else emptySet() else emptySet()
) )