From bb45ef13d7ed6f45c1bf122411b41541fe08b304 Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Fri, 18 Mar 2022 17:52:25 +0100 Subject: [PATCH] Replace deprecated NBTItem calls --- .../listeners/PlayerInteractListener.java | 7 +++---- .../songoda/epicvouchers/voucher/Voucher.java | 16 ++++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/songoda/epicvouchers/listeners/PlayerInteractListener.java b/src/main/java/com/songoda/epicvouchers/listeners/PlayerInteractListener.java index 248dc5f..31c64b3 100644 --- a/src/main/java/com/songoda/epicvouchers/listeners/PlayerInteractListener.java +++ b/src/main/java/com/songoda/epicvouchers/listeners/PlayerInteractListener.java @@ -1,7 +1,6 @@ package com.songoda.epicvouchers.listeners; -import com.songoda.core.nms.NmsManager; -import com.songoda.core.nms.nbt.NBTItem; +import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem; import com.songoda.epicvouchers.EpicVouchers; import com.songoda.epicvouchers.utils.CachedSet; import com.songoda.epicvouchers.voucher.Voucher; @@ -27,9 +26,9 @@ public class PlayerInteractListener implements Listener { ItemStack item = e.getItem(); if (item != null && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)) { - NBTItem itemNbt = NmsManager.getNbt().of(item); + NBTItem itemNbt = new NBTItem(item); - boolean itemHasVoucher = itemNbt.has("epicvouchers:voucher"); + boolean itemHasVoucher = itemNbt.hasKey("epicvouchers:voucher"); String itemVoucherValue = itemNbt.getString("epicvouchers:voucher"); boolean legacyChecked = checkedLegacyVouchers.contains(item); diff --git a/src/main/java/com/songoda/epicvouchers/voucher/Voucher.java b/src/main/java/com/songoda/epicvouchers/voucher/Voucher.java index 851fb16..7dfb12b 100644 --- a/src/main/java/com/songoda/epicvouchers/voucher/Voucher.java +++ b/src/main/java/com/songoda/epicvouchers/voucher/Voucher.java @@ -2,8 +2,7 @@ package com.songoda.epicvouchers.voucher; import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.ServerVersion; -import com.songoda.core.nms.NmsManager; -import com.songoda.core.nms.nbt.NBTItem; +import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem; import com.songoda.core.utils.ItemUtils; import com.songoda.core.utils.TextUtils; import com.songoda.epicvouchers.EpicVouchers; @@ -113,9 +112,10 @@ public class Voucher { item.setItemMeta(meta); } else { item.setItemMeta(meta); - NBTItem nbtItem = NmsManager.getNbt().of(item); - nbtItem.set("Unbreakable", (byte) 1); - item = nbtItem.finish(); + + NBTItem nbtItem = new NBTItem(item); + nbtItem.setByte("Unbreakable", (byte) 1); + item = nbtItem.getItem(); } } @@ -123,10 +123,10 @@ public class Voucher { item = ItemUtils.getCustomHead(texture); } - NBTItem nbtItem = NmsManager.getNbt().of(item); - nbtItem.set("epicvouchers:voucher", key); + NBTItem nbtItem = new NBTItem(item); + nbtItem.setString("epicvouchers:voucher", key); - return nbtItem.finish(); + return nbtItem.getItem(); } public String getName(boolean applyFormatting) {