Fixed craftitemstack

This commit is contained in:
Auxilor 2020-11-03 18:34:05 +00:00
parent 813fa3f4e8
commit e9ca330a33

View File

@ -53,8 +53,11 @@ public final class PacketOpenWindowMerchant extends AbstractPacketAdapter {
Object selling = fSelling.get(handle); // NMS Selling ItemStack
modifiersField.setInt(fSelling, fSelling.getModifiers() & ~Modifier.FINAL);
String nmsVersion = EcoEnchantsPlugin.nmsVersion; // Fuck you spigot for making me do this
if(nmsVersion.equalsIgnoreCase("v1_16_R3")) nmsVersion = "v1_16_R2";
// Reflectively access CraftItemStack.class for respective version
Class<?> craftItemStack = Class.forName("org.bukkit.craftbukkit." + EcoEnchantsPlugin.nmsVersion + ".inventory.CraftItemStack");
Class<?> craftItemStack = Class.forName("org.bukkit.craftbukkit." + nmsVersion + ".inventory.CraftItemStack");
// Bukkit Result ItemStack from NMS Result ItemStack
ItemStack nmsSelling = (ItemStack) craftItemStack.getMethod("asBukkitCopy", selling.getClass()).invoke(null, selling);