Library ReflectedNBTWrapper / NBT Wrapper lib using reflection

Discussion in 'Resources' started by SkyWolf46, Jan 2, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    SkyWolf46

    Hello developers!
    I want to share my personal library ReflectedNBTWrapper what helps using nbt on your plugin.
    If you have problem to use this library, please notice to me!


    ReflectedNBTWrapper is quite simple library.
    It helps you use NBT on all version.
    Of course, you can use your own NBT Data.

    Custom NBT serializaion / deserializon is work in process.

    * 1.1 update will contains native to nbt exchange.

    Example - Create new NBTCompound
    Code:
    public static ReflectedNBTCompound createSimpleCompound(){
      ReflectedNBTCompound comp = new ReflectedNBTCompound();
      comp.setValue("TestValue",new ReflectedNBTInteger(1));
      return comp;
    }
    Example - Import NBTCompound to Item
    Code:
    public static ItemStack importTag(ItemStack item){
      ReflectedNBTCompound comp = ItemNBTExtrator.extractOrCreateNBT(item);
      comp.setValue("TestValue",new ReflectedNBTInteger(1));
      return ItemNBTImporter.importNBT(item,comp);
    }
    Example - Extract NBTCompound from Item
    Code:
    public static ReflectedNBTCompound extractAndTest(ItemStack item){
      ReflectedNBTCompound comp = ItemNBTExtrator.extractOrCreateNBT(item);
      ReflectedNBTInteger ref = comp.getValue("TestValue");
      if(ref.getValue() == 1)
         System.out.println("Read success");
      return comp;
    }


    Download or View source on my Github.
     
    Last edited: Jan 7, 2020
  2. Offline

    SkyWolf46

    New release updated!

    1.1 Alpha -> 1.2 Release

    1.1.0 Alpha
    • Change from extend(ReflectedNBTBase) to implements(IReflectedNBTBase)
    • Removed abstraction from ReflectedNBTBase
    • Change class file name from ReflectedNBTBase to ReflectedNBTStorage
    • Add unwrapping to ReflectedNBTList
    1.1.1 Alpha
    • Added IReflectedNBTCompound#get(String)
    • Added IReflectedNBTCompound#getNBT(IReflectedNBTBase)
    • Added IReflectedNBTCompound#set(String,Object)
    • Added IReflectedNBTCompound#set(String,IReflectedNBTBase)
    • Change package name to v1_1R1
    1.1.2 Alpha
    • Added ReflectedNBTCompound#keyset()
    • Now ReflectedNBTList implements Iterable
    • Added LinearIterator
    • Changed package name to v1_1_R2
    1.1.3 Alpha
    • Changed IReflectedNBTCompound implemention to IReflectedNBTBase<HashMap<String,Object>>
    • Added IReflectedNBTBase#clear()
    • Added IReflectedNBTBase#collapse(IReflectedNBTBase)
    • Changed package name to v1_1R3
    1.2 Release
    • Added Native to NBT Exchanger at ReflectedNBTStorage
    • Changed package name to v1_2
    • Version stabilized! Change version state to Release.
    1.2.1 Release
    • Now ReflectedNBTStorage#createReflectedNBT(Object) returns parameter if it implements IReflectedNBTWrapper
    • Changed package name to v1_2R1
    1.2.2 Release
    • Fixed ReflectedNBTList#add(Object) throws CollectionMismatchedException after load list from nbt
    • Changed package name to v1_2R2
    1.2.3 Release
    • Fixed ItemNBTImporter.import(ItemStack,ReflectedNBTCompound) make error with integer arrays
    • Warning! If you edit nbt with integer arrays, error will occurred in previous versions.
    • Changed package name to v1_2R3
    You can download releases with clicking version name.
    View or Download source code in my Github.
     
    Last edited: Jan 25, 2020
Thread Status:
Not open for further replies.

Share This Page