Replace deprecated NBTItem calls

This commit is contained in:
Christian Koop 2022-03-18 17:52:25 +01:00
parent 1802ad3100
commit bb45ef13d7
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
2 changed files with 11 additions and 12 deletions

View File

@ -1,7 +1,6 @@
package com.songoda.epicvouchers.listeners; package com.songoda.epicvouchers.listeners;
import com.songoda.core.nms.NmsManager; import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
import com.songoda.core.nms.nbt.NBTItem;
import com.songoda.epicvouchers.EpicVouchers; import com.songoda.epicvouchers.EpicVouchers;
import com.songoda.epicvouchers.utils.CachedSet; import com.songoda.epicvouchers.utils.CachedSet;
import com.songoda.epicvouchers.voucher.Voucher; import com.songoda.epicvouchers.voucher.Voucher;
@ -27,9 +26,9 @@ public class PlayerInteractListener implements Listener {
ItemStack item = e.getItem(); ItemStack item = e.getItem();
if (item != null && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)) { 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"); String itemVoucherValue = itemNbt.getString("epicvouchers:voucher");
boolean legacyChecked = checkedLegacyVouchers.contains(item); boolean legacyChecked = checkedLegacyVouchers.contains(item);

View File

@ -2,8 +2,7 @@ package com.songoda.epicvouchers.voucher;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.nms.NmsManager; import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
import com.songoda.core.nms.nbt.NBTItem;
import com.songoda.core.utils.ItemUtils; import com.songoda.core.utils.ItemUtils;
import com.songoda.core.utils.TextUtils; import com.songoda.core.utils.TextUtils;
import com.songoda.epicvouchers.EpicVouchers; import com.songoda.epicvouchers.EpicVouchers;
@ -113,9 +112,10 @@ public class Voucher {
item.setItemMeta(meta); item.setItemMeta(meta);
} else { } else {
item.setItemMeta(meta); item.setItemMeta(meta);
NBTItem nbtItem = NmsManager.getNbt().of(item);
nbtItem.set("Unbreakable", (byte) 1); NBTItem nbtItem = new NBTItem(item);
item = nbtItem.finish(); nbtItem.setByte("Unbreakable", (byte) 1);
item = nbtItem.getItem();
} }
} }
@ -123,10 +123,10 @@ public class Voucher {
item = ItemUtils.getCustomHead(texture); item = ItemUtils.getCustomHead(texture);
} }
NBTItem nbtItem = NmsManager.getNbt().of(item); NBTItem nbtItem = new NBTItem(item);
nbtItem.set("epicvouchers:voucher", key); nbtItem.setString("epicvouchers:voucher", key);
return nbtItem.finish(); return nbtItem.getItem();
} }
public String getName(boolean applyFormatting) { public String getName(boolean applyFormatting) {