So as im working on my biggest project im trying to improve the code and features as much as i can Rn im using the "noob" way of doing custom stuff,place a colored name on a item and use it for checks. Question is should i start using NBT over this? Im also concerned i will lose version compatibility once i go into NBTs. If ur familiar please explain me the goods/bads of using them
Do not use NBT instead use the spigot-api persistence api. getPersistentDataContainer Code (Text): ItemStack its = new ItemStack(Material.STONE); ItemMeta meta = its.getItemMeta(); // write meta.getPersistentDataContainer().set(new NamespacedKey(javaPlugin, "your_special_key"), PersistentDataType.STRING, "Your Custom Value"); its.setItemMeta(meta); //read String yourCustomValue = meta.getPersistentDataContainer().get(new NamespacedKey(javaPlugin, "your_special_key"), PersistentDataType.STRING);
As of Spigot version idk, you can add custom NBT-Tags using the PersistentDataHolder API. This is a convenient way of doing all NBT-stuff while not loosing version-compatibility