feat: Merge upstream changes and update to 1.21

This commit is contained in:
2025-01-06 23:48:23 -07:00
parent fafeef079f
commit a85ef10c3c
9 changed files with 130 additions and 200 deletions

View File

@@ -33,8 +33,8 @@ object BrigardierSupport {
}
@Suppress("HasPlatformType")
fun resolveCommandManager() = (server as org.bukkit.craftbukkit.v1_20_R1.CraftServer)
.server.vanillaCommandDispatcher
fun resolveCommandManager() = (server as org.bukkit.craftbukkit.CraftServer)
.server.commands
internal fun registerAll() {
executedDefaultRegistration = true
@@ -52,7 +52,7 @@ object BrigardierSupport {
fun updateCommandTree() {
onlinePlayers.forEach {
// send the command tree
resolveCommandManager().sendCommands((it as org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer).handle)
resolveCommandManager().sendCommands((it as org.bukkit.craftbukkit.entity.CraftPlayer).handle)
}
}
}

View File

@@ -3,9 +3,10 @@
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.v1_20_R1.entity.CraftEntity
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack
import org.bukkit.craftbukkit.entity.CraftEntity
import org.bukkit.craftbukkit.inventory.CraftItemStack
import org.bukkit.entity.Entity
import org.bukkit.inventory.ItemStack
@@ -22,8 +23,4 @@ var Entity.nbtData: CompoundTag
@NMS_General
val ItemStack.nbtData: CompoundTag
get() {
CraftItemStack.asNMSCopy(this).let {
return if (it.hasTag()) (it.tag ?: CompoundTag()) else CompoundTag()
}
}
get() = (this as? CraftItemStack)?.handle?.get(DataComponents.CUSTOM_DATA)?.copyTag() ?: CompoundTag()

View File

@@ -138,8 +138,8 @@ fun Player.showOnlinePlayers() {
@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.v1_20_R1.CraftWorld ?: return null
return craftWorld.createEntity(this, entityType.entityClass!!)?.let {
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
}
@@ -197,7 +197,7 @@ fun Player.give(vararg itemStacks: ItemStack) = inventory.addItem(*itemStacks)
* Adds all equipment locks to every equipment slot
*/
fun ArmorStand.fullLock() {
for (slot in EquipmentSlot.values()) {
for (slot in EquipmentSlot.entries) {
lock(slot)
}
}
@@ -207,7 +207,7 @@ fun ArmorStand.fullLock() {
* @param slot the slot which gets locked
*/
fun ArmorStand.lock(slot: EquipmentSlot) {
for (lock in ArmorStand.LockType.values()) {
for (lock in ArmorStand.LockType.entries) {
addEquipmentLock(slot, lock)
}
}

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 -> null
EquipmentSlot.CHEST, EquipmentSlot.FEET, EquipmentSlot.HEAD, EquipmentSlot.LEGS, EquipmentSlot.BODY -> null
}
}

View File

@@ -10,7 +10,7 @@ import org.bukkit.Location
import org.bukkit.Material
import org.bukkit.block.Block
import org.bukkit.block.data.BlockData
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftEntity
import org.bukkit.craftbukkit.entity.CraftEntity
import org.bukkit.entity.Entity
import org.bukkit.entity.EntityType