Update KSpigot to 1.18.1

This commit is contained in:
Jakob K
2021-12-12 03:06:10 +01:00
parent c23b41e086
commit cc4d180902
10 changed files with 76 additions and 84 deletions

View File

@@ -0,0 +1,27 @@
package net.axay.kspigot.data
import net.axay.kspigot.annotations.NMS_General
import net.minecraft.nbt.CompoundTag
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity
import org.bukkit.craftbukkit.v1_18_R1.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
get() {
CraftItemStack.asNMSCopy(this).let {
return if (it.hasTag()) (it.tag ?: CompoundTag()) else CompoundTag()
}
}