mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 10:22:29 +00:00
Fix item preview in version >= 1.17
This commit is contained in:
parent
d4cddcab37
commit
8b0bd54a1d
@ -23,6 +23,11 @@ public interface TextComponentHelper {
|
|||||||
player.spigot().sendMessage(component);
|
player.spigot().sendMessage(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the 'tag' json object containing the item's data
|
||||||
|
* @param itemStack The item stack that will be displayed
|
||||||
|
* @return A string representing a json object of the 'tag'
|
||||||
|
*/
|
||||||
String getNbt(ItemStack itemStack);
|
String getNbt(ItemStack itemStack);
|
||||||
|
|
||||||
default Consumer<Player> getSendableItemInfo(String message, String itemPlaceHolder, ItemStack itemStack, String productName){
|
default Consumer<Player> getSendableItemInfo(String message, String itemPlaceHolder, ItemStack itemStack, String productName){
|
||||||
|
@ -2,12 +2,14 @@ package de.epiceric.shopchest.nms.v1_17_1_R1;
|
|||||||
|
|
||||||
import de.epiceric.shopchest.nms.TextComponentHelper;
|
import de.epiceric.shopchest.nms.TextComponentHelper;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class TextComponentHelperImpl implements TextComponentHelper {
|
public class TextComponentHelperImpl implements TextComponentHelper {
|
||||||
@Override
|
@Override
|
||||||
public String getNbt(ItemStack itemStack) {
|
public String getNbt(ItemStack itemStack) {
|
||||||
return CraftItemStack.asNMSCopy(itemStack).save(new CompoundTag()).getAsString();
|
final Tag tag = CraftItemStack.asNMSCopy(itemStack).save(new CompoundTag()).get("tag");
|
||||||
|
return tag == null ? null : tag.getAsString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,14 @@ package de.epiceric.shopchest.nms.v1_17_R1;
|
|||||||
|
|
||||||
import de.epiceric.shopchest.nms.TextComponentHelper;
|
import de.epiceric.shopchest.nms.TextComponentHelper;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class TextComponentHelperImpl implements TextComponentHelper {
|
public class TextComponentHelperImpl implements TextComponentHelper {
|
||||||
@Override
|
@Override
|
||||||
public String getNbt(ItemStack itemStack) {
|
public String getNbt(ItemStack itemStack) {
|
||||||
return CraftItemStack.asNMSCopy(itemStack).save(new CompoundTag()).getAsString();
|
final Tag tag = CraftItemStack.asNMSCopy(itemStack).save(new CompoundTag()).get("tag");
|
||||||
|
return tag == null ? null : tag.getAsString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user