Package com.viaversion.nbt.io
Class TagRegistry
java.lang.Object
com.viaversion.nbt.io.TagRegistry
A registry containing different tag classes.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetClassFor(int id) Gets the tag class with the given id.static intGets the id of the given tag class.static Tagread(int id, DataInput in, TagLimiter tagLimiter, int nestingLevel) Creates an instance of the tag with the given id, using the String constructor.static <T extends Tag>
voidregister(int id, Class<T> tag, TagRegistry.TagSupplier<T> supplier) Registers a tag class.
-
Field Details
-
END
public static final int END- See Also:
-
-
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
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
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 idIOException
-