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
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"
@@ -16,7 +16,7 @@ plugins {
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 {
@@ -24,7 +24,7 @@ repositories {
}
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-coroutines-core:1.8.1")

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
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
zipStorePath=wrapper/dists

View File

@@ -5,21 +5,9 @@ package net.axay.kspigot.data
import net.axay.kspigot.annotations.NMS_General
import net.minecraft.core.component.DataComponents
import net.minecraft.nbt.CompoundTag
import org.bukkit.craftbukkit.entity.CraftEntity
import org.bukkit.craftbukkit.inventory.CraftItemStack
import org.bukkit.entity.Entity
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
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
*/
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!")
/**
@@ -76,7 +76,7 @@ fun Damageable.kill() {
* @throws NullPointerException if the entity does not have a max health value
*/
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!")
}
@@ -132,18 +132,6 @@ fun Player.showOnlinePlayers() {
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

View File

@@ -21,7 +21,7 @@ val PlayerInteractEntityEvent.interactItem: ItemStack?
return when (this.hand) {
EquipmentSlot.HAND -> p.inventory.itemInMainHand
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
import org.apache.commons.lang.text.StrSubstitutor
import org.apache.commons.lang3.text.StrSubstitutor
import org.bukkit.entity.Player
import java.io.InputStreamReader
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) {
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
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.particles.KSpigotParticle
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(
val particle: KSpigotParticle,
) : StructureData {

View File

@@ -17,11 +17,6 @@ fun LocationArea.loadStructure(includeBlocks: Boolean = true, includeEntities: B
fillBlocks.mapTo(HashSet()) {
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()
)