Skip to content

Commit

Permalink
Switched from NbtItem to Nbt.modify
Browse files Browse the repository at this point in the history
  • Loading branch information
sh0inx committed May 17, 2024
1 parent 4120244 commit 84c9a3c
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.iridium.iridiumskyblock.managers;

import com.iridium.iridiumcore.dependencies.nbtapi.NBT;
import com.iridium.iridiumcore.dependencies.nbtapi.NBTCompound;
import com.iridium.iridiumcore.dependencies.nbtapi.NBTFile;
import com.iridium.iridiumcore.dependencies.nbtapi.NBTItem;
import com.iridium.iridiumcore.dependencies.paperlib.PaperLib;
import com.iridium.iridiumcore.dependencies.xseries.XMaterial;
import com.iridium.iridiumcore.dependencies.xseries.XBiome;
Expand Down Expand Up @@ -690,19 +690,26 @@ public ItemStack getIslandCrystal(int amount) {
ItemStack itemStack = ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getConfiguration().islandCrystal, Collections.singletonList(
new Placeholder("amount", String.valueOf(amount))
));
NBTItem nbtItem = new NBTItem(itemStack);
NBTCompound nbtCompound = nbtItem.getOrCreateCompound("iridiumskyblock");
nbtCompound.setInteger("islandCrystals", amount);
return nbtItem.getItem();

NBT.modify(itemStack, readWriteItemNBT -> {
readWriteItemNBT.getOrCreateCompound("iridiumskyblock").setInteger("islandCrystals", amount);
});

return itemStack;
}

public int getIslandCrystals(ItemStack itemStack) {
if (itemStack == null || itemStack.getType() == Material.AIR) return 0;
NBTCompound nbtCompound = new NBTItem(itemStack).getOrCreateCompound("iridiumskyblock");
if (nbtCompound.hasKey("islandCrystals")) {
return nbtCompound.getInteger("islandCrystals");
}
return 0;

int amount = 0;

if (NBT.get(itemStack, readableItemNBT -> {
return readableItemNBT.getCompound("iridiumskyblock").hasTag("islandCrystals");
})) return NBT.get(itemStack, readableItemNBT -> {
return readableItemNBT.getCompound("iridiumskyblock").getInteger("islandCrystals");
});

return amount;
}

public List<User> getMembersOnIsland(Island island) {
Expand Down

0 comments on commit 84c9a3c

Please sign in to comment.