diff --git a/nms/v1_19_R2/src/main/java/de/epiceric/shopchest/nms/v1_19_R2/component/ComponentExtractor.java b/nms/v1_19_R2/src/main/java/de/epiceric/shopchest/nms/v1_19_R2/component/ComponentExtractor.java new file mode 100644 index 0000000..6a72fcf --- /dev/null +++ b/nms/v1_19_R2/src/main/java/de/epiceric/shopchest/nms/v1_19_R2/component/ComponentExtractor.java @@ -0,0 +1,7 @@ +package de.epiceric.shopchest.nms.v1_19_R2.component; + +public class ComponentExtractor { + + + +} diff --git a/nms/v1_19_R2/src/main/java/de/epiceric/shopchest/nms/v1_19_R2/component/ItemTagExtractor.java b/nms/v1_19_R2/src/main/java/de/epiceric/shopchest/nms/v1_19_R2/component/ItemTagExtractor.java new file mode 100644 index 0000000..3377ce2 --- /dev/null +++ b/nms/v1_19_R2/src/main/java/de/epiceric/shopchest/nms/v1_19_R2/component/ItemTagExtractor.java @@ -0,0 +1,14 @@ +package de.epiceric.shopchest.nms.v1_19_R2.component; + +import de.epiceric.shopchest.nms.v1_19_R2.item.NMSItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; + +public class ItemTagExtractor { + + public String extractItemTag(NMSItemStack itemStack) { + final Tag tag = itemStack.getNmsItemStack().save(new CompoundTag()).get("tag"); + return tag == null ? null : tag.getAsString(); + } + +} diff --git a/nms/v1_19_R2/src/main/java/de/epiceric/shopchest/nms/v1_19_R2/component/TranslatableItemNameExtractor.java b/nms/v1_19_R2/src/main/java/de/epiceric/shopchest/nms/v1_19_R2/component/TranslatableItemNameExtractor.java new file mode 100644 index 0000000..b094b76 --- /dev/null +++ b/nms/v1_19_R2/src/main/java/de/epiceric/shopchest/nms/v1_19_R2/component/TranslatableItemNameExtractor.java @@ -0,0 +1,14 @@ +package de.epiceric.shopchest.nms.v1_19_R2.component; + +import de.epiceric.shopchest.nms.v1_19_R2.item.NMSItemStack; +import net.minecraft.network.chat.Component; + +public class TranslatableItemNameExtractor { + + public String extractTranslatableItemName(NMSItemStack nmsItemStack) { + final net.minecraft.world.item.ItemStack nStack = nmsItemStack.getNmsItemStack(); + final Component component = nStack.getItem().getName(nStack); + return Component.Serializer.toJson(component); + } + +} diff --git a/nms/v1_19_R2/src/main/java/de/epiceric/shopchest/nms/v1_19_R2/item/NMSItemStack.java b/nms/v1_19_R2/src/main/java/de/epiceric/shopchest/nms/v1_19_R2/item/NMSItemStack.java new file mode 100644 index 0000000..107cb6f --- /dev/null +++ b/nms/v1_19_R2/src/main/java/de/epiceric/shopchest/nms/v1_19_R2/item/NMSItemStack.java @@ -0,0 +1,20 @@ +package de.epiceric.shopchest.nms.v1_19_R2.item; + +import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack; +import org.bukkit.inventory.ItemStack; + +public class NMSItemStack { + + private final ItemStack bukkitItemStack; + private final net.minecraft.world.item.ItemStack nmsItemStack; + + public NMSItemStack(ItemStack bukkitItemStack) { + this.bukkitItemStack = bukkitItemStack; + nmsItemStack = CraftItemStack.asNMSCopy(bukkitItemStack); + } + + public net.minecraft.world.item.ItemStack getNmsItemStack() { + return nmsItemStack; + } + +}