Class TagCompound

java.lang.Object
com.saicone.rtag.tag.TagCompound

public class TagCompound extends Object
Class to invoke CompoundTag methods across versions.
  • Field Details

  • Method Details

    • newTag

      public static Object newTag()
      Constructs an empty CompoundTag.
      Returns:
      New CompoundTag instance.
    • newTag

      public static Object newTag(String snbt)
      Constructs an CompoundTag with provided NBT string.
      Parameters:
      snbt - NBT String with data.
      Returns:
      New CompoundTag instance.
    • newTag

      public static Object newTag(Map<String,Object> map)
      Constructs an CompoundTag with provided Map of tag values.
      Parameters:
      map - Map with tags.
      Returns:
      New CompoundTag instance.
    • newUncheckedTag

      public static Object newUncheckedTag(Map<String,Object> map)
      Constructs an CompoundTag with provided Map of tag values.
      This method doesn't provide any safe check and assumes that the provided map is completely usable to create a new CompoundTag.
      Parameters:
      map - Map with tags.
      Returns:
      New CompoundTag instance.
    • newTag

      public static Object newTag(RtagMirror mirror, Object object)
      Constructs an CompoundTag with provided object and required RtagMirror to convert Objects.
      This method can convert any supported object to Map of objects using Gson deserializer.
      Parameters:
      mirror - RtagMirror to convert objects into tags.
      object - Object that can be converted to CompoundTag.
      Returns:
      New CompoundTag instance.
      Throws:
      IllegalArgumentException - if the object is not supported.
    • newTag

      public static Object newTag(RtagMirror mirror, Map<String,Object> map)
      Constructs an CompoundTag with provided Map of Objects and required RtagMirror to convert Objects.
      Parameters:
      mirror - RtagMirror to convert objects into tags.
      map - Map with objects.
      Returns:
      New CompoundTag instance.
    • isTagCompound

      public static boolean isTagCompound(Object object)
      Check if the provided object is instance of CompoundTag class.
      Parameters:
      object - the object to check.
      Returns:
      true if the object is an instance of CompoundTag class.
    • clone

      public static Object clone(Object tag)
      Copy provided CompoundTag into new one.
      Parameters:
      tag - CompoundTag instance.
      Returns:
      A copy of original CompoundTag.
    • safeClone

      public static Object safeClone(Object tag)
      Copy provided CompoundTag into new one without exceptions.
      Parameters:
      tag - CompoundTag instance.
      Returns:
      A copy of original CompoundTag.
    • getValue

      public static Map<String,Object> getValue(Object tag)
      Get current tag map.
      Parameters:
      tag - CompoundTag instance.
      Returns:
      a Map of tags.
    • getValue

      public static Map<String,Object> getValue(RtagMirror mirror, Object tag)
      Get current tag map with converted values.
      Parameters:
      mirror - RtagMirror to convert tags.
      tag - CompoundTag instance.
      Returns:
      A Map of Objects.
    • getJson

      public static String getJson(Object tag)
      Get the provided CompoundTag as Json string.
      Parameters:
      tag - CompoundTag instance.
      Returns:
      A Json string.
    • getJson

      public static String getJson(com.google.gson.Gson gson, Object tag)
      Get the provided CompoundTag as Json string.
      Parameters:
      gson - The Gson instance to use.
      tag - CompoundTag instance.
      Returns:
      A Json string.
    • notHasKey

      public static boolean notHasKey(Object tag, String key)
      The inverse result of hasKey(Object, String).
      Parameters:
      tag - CompoundTag instance.
      key - Key to find.
      Returns:
      True if key exist.
    • hasKey

      public static boolean hasKey(Object tag, String key)
      Check if CompoundTag contains certain key in Map.
      Parameters:
      tag - CompoundTag instance.
      key - Key to find.
      Returns:
      True if key exist.
    • remove

      public static Object remove(Object tag, String key)
      Remove certain key from CompoundTag.
      Parameters:
      tag - CompoundTag instance.
      key - Key to remove.
      Returns:
      The previous value associated with key, or null if there was no mapping for key.
    • set

      public static Object set(Object tag, String key, Object value)
      Put certain Tag value to CompoundTag.
      Parameters:
      tag - CompoundTag instance.
      key - Value key.
      value - Value to put.
      Returns:
      The previous value associated with key, or null if there was no mapping for key.
    • setValue

      public static void setValue(Object tag, Map<String,Object> map)
      Override the current map of tag values inside CompoundTag.
      Parameters:
      tag - CompoundTag instance.
      map - Map with tag objects.
    • merge

      public static boolean merge(Object tag, Object value, boolean replace)
      Merge the provided value into CompoundTag.
      Parameters:
      tag - CompoundTag instance.
      value - The value to merge.
      replace - True to replace the repeated values inside CompoundTag.
      Returns:
      true if the value was merged.
    • merge

      public static boolean merge(Object tag, Object value, boolean replace, boolean deep)
      Merge the provided value into CompoundTag.
      Parameters:
      tag - CompoundTag instance.
      value - The value to merge.
      replace - True to replace the repeated values inside CompoundTag.
      deep - True to merge into sub paths instead of main path.
      Returns:
      true if the value was merged.
    • get

      public static Object get(Object tag, String key)
      Get Tag value associated with key.
      Parameters:
      tag - CompoundTag instance.
      key - Value key.
      Returns:
      A Tag value if exist inside compound, null if not.
    • clear

      public static void clear(Object tag)
      Clear the provided CompoundTag tag.
      Parameters:
      tag - CompoundTag instance.