diff --git a/pom.xml b/pom.xml index 2178b6a..c40cf6f 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ com.songoda EpicVouchers 4.0.0 - 2.1.17 + 2.1.18 clean install EpicVouchers-${project.version} diff --git a/src/main/java/com/songoda/epicvouchers/voucher/Voucher.java b/src/main/java/com/songoda/epicvouchers/voucher/Voucher.java index 98cc050..d860908 100644 --- a/src/main/java/com/songoda/epicvouchers/voucher/Voucher.java +++ b/src/main/java/com/songoda/epicvouchers/voucher/Voucher.java @@ -1,5 +1,8 @@ package com.songoda.epicvouchers.voucher; +import com.songoda.core.compatibility.ServerVersion; +import com.songoda.core.nms.NmsManager; +import com.songoda.core.nms.nbt.NBTItem; import com.songoda.core.utils.TextUtils; import com.songoda.epicvouchers.EpicVouchers; import com.songoda.epicvouchers.events.ForceRedeemEvent; @@ -94,15 +97,22 @@ public class Voucher { meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } - if (unbreakable) { - meta.setUnbreakable(true); - } - if (hideAttributes) { meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE); } - item.setItemMeta(meta); + + if (unbreakable) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { + meta.setUnbreakable(true); + item.setItemMeta(meta); + } else { + item.setItemMeta(meta); + NBTItem nbtItem = NmsManager.getNbt().of(item); + nbtItem.set("Unbreakable", (byte) 1); + item = nbtItem.finish(); + } + } return item; }