mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2026-01-06 15:51:55 +00:00
feat: add nbt related methods
This commit is contained in:
@@ -233,6 +233,37 @@ public class ItemBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds NBT data to the item
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public ItemBuilder addNBTData(NamespacedKey key, String value) {
|
||||
nbtData.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the NBT data from the item
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public ItemBuilder removeNBTData(NamespacedKey key) {
|
||||
nbtData.remove(key);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This clears the extra NBT data that has been added. This will not clear the default NBT data that is added by the game.
|
||||
* So if you're materially getting an oraxen item, it will not clear the oraxen NBT data.
|
||||
* @return
|
||||
*/
|
||||
public ItemBuilder clearNBTData() {
|
||||
nbtData.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lore of the item. Use #setLore to set the lore!
|
||||
* @return
|
||||
@@ -249,6 +280,10 @@ public class ItemBuilder {
|
||||
return List.copyOf(itemFlags);
|
||||
}
|
||||
|
||||
public List<NamespacedKey> getNBTDataKeys() {
|
||||
return List.copyOf(nbtData.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a item has any enchantments
|
||||
* @return
|
||||
@@ -273,6 +308,10 @@ public class ItemBuilder {
|
||||
return itemFlags.contains(flag);
|
||||
}
|
||||
|
||||
public boolean hasNBTData(NamespacedKey key) {
|
||||
return nbtData.containsKey(key);
|
||||
}
|
||||
|
||||
public ItemStack build() {
|
||||
ItemStack itemStack = Hooks.getItem(material);
|
||||
if (itemStack == null) return null;
|
||||
|
||||
Reference in New Issue
Block a user