mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Fixes air material
Former-commit-id: f0fd13ea753b6df7da28189358ec4d917f96dad5 [formerly 5fecaa9300aa15a2c586da00fdb19f2d9d60ce71] Former-commit-id: ef59231fa2c209ff2b8a75b56dc430509f08755a
This commit is contained in:
1 parent
fa08b3b9ea
commit
c1b070e7bf
2 files changed
+7
-4
No files matched your search
@@ -1,21 +1,20 @@
|
||||
package org.maxgamer.quickshop.Util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public abstract class ItemNMS {
|
||||
private static final String nmsVersion;
|
||||
|
||||
public abstract class ItemNMS {
|
||||
private static Method craftItemStack_asNMSCopyMethod;
|
||||
private static Class<?> nbtTagCompoundClass;
|
||||
private static Method itemStack_saveMethod;
|
||||
|
||||
static {
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
nmsVersion = name.substring(name.lastIndexOf('.') + 1);
|
||||
String nmsVersion = name.substring(name.lastIndexOf('.') + 1);
|
||||
|
||||
try {
|
||||
craftItemStack_asNMSCopyMethod = Class.forName("org.bukkit.craftbukkit." + nmsVersion + ".inventory.CraftItemStack")
|
||||
@@ -34,6 +33,8 @@ public abstract class ItemNMS {
|
||||
}
|
||||
|
||||
public static String saveJsonfromNMS(ItemStack bStack) throws Throwable {
|
||||
if (bStack.getType() == Material.AIR)
|
||||
return null;
|
||||
Object mcStack = craftItemStack_asNMSCopyMethod.invoke(null, bStack);
|
||||
Object nbtTagCompound = nbtTagCompoundClass.newInstance();
|
||||
|
||||
|
||||
@@ -561,6 +561,8 @@ public class Util {
|
||||
public static void sendItemholochat(ItemStack itemStack, Player player, String normalText) {
|
||||
try {
|
||||
String json = ItemNMS.saveJsonfromNMS(itemStack);
|
||||
if (json == null)
|
||||
return;
|
||||
TextComponent normalmessage = new TextComponent(normalText+" "+MsgUtil.getMessage("menu.preview"));
|
||||
ComponentBuilder cBuilder = new ComponentBuilder(json);
|
||||
HoverEvent he = new HoverEvent(HoverEvent.Action.SHOW_ITEM, cBuilder.create());
|
||||
|
||||
Reference in new issue
Block a user