From a41b7d27b412b92de1d0afa2c4cbd3dc8dc314f6 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Fri, 26 Jun 2020 21:14:40 +0200 Subject: [PATCH] Update ItemStackUtil --- .../com/songoda/skyblock/utils/item/ItemStackUtil.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java b/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java index 87eee00b..c608c4da 100644 --- a/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java +++ b/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java @@ -2,8 +2,10 @@ package com.songoda.skyblock.utils.item; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.utils.version.NMSUtil; import org.bukkit.Material; +import org.bukkit.Server; import org.bukkit.inventory.ItemStack; import java.io.*; @@ -24,10 +26,11 @@ public final class ItemStackUtil { Object NBTTagCompound = NMSUtil.getNMSClass("NBTCompressedStreamTools") .getMethod("a", DataInputStream.class).invoke(null, dataInputStream); Object craftItemStack; - - if (NMSUtil.getVersionNumber() > 12) { + + assert NMSItemStackClass != null; + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { craftItemStack = NMSItemStackClass.getMethod("a", NBTTagCompoundClass).invoke(null, NBTTagCompound); - } else if (NMSUtil.getVersionNumber() > 10) { + } else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) { craftItemStack = NMSItemStackClass.getConstructor(NBTTagCompoundClass).newInstance(NBTTagCompound); } else { craftItemStack = NMSItemStackClass.getMethod("createStack", NBTTagCompoundClass).invoke(null,