Class TagRegistry

java.lang.Object
com.viaversion.nbt.io.TagRegistry

public final class TagRegistry extends Object
A registry containing different tag classes.
  • Field Details

  • Constructor Details

    • TagRegistry

      public TagRegistry()
  • Method Details

    • register

      public static <T extends Tag> void register(int id, Class<T> tag, TagRegistry.TagSupplier<T> supplier)
      Registers a tag class.
      Parameters:
      id - ID of the tag.
      tag - Tag class to register.
      Throws:
      IllegalArgumentException - if the id is unexpectedly out of bounds, or if the id or tag have already been registered
    • getClassFor

      @Nullable public static @Nullable Class<? extends Tag> getClassFor(int id)
      Gets the tag class with the given id.
      Parameters:
      id - Id of the tag.
      Returns:
      The tag class with the given id, or null if it cannot be found.
    • getIdFor

      public static int getIdFor(Class<? extends Tag> clazz)
      Gets the id of the given tag class.
      Parameters:
      clazz - The tag class to get the id of.
      Returns:
      The id of the given tag class, or -1 if it cannot be found.
    • read

      public static Tag read(int id, DataInput in, TagLimiter tagLimiter, int nestingLevel) throws IOException
      Creates an instance of the tag with the given id, using the String constructor.
      Parameters:
      id - Id of the tag.
      Returns:
      The created tag.
      Throws:
      IllegalArgumentException - if no tags is registered over the provided id
      IOException