Package net.kyori.adventure.nbt.api
Interface BinaryTagHolder
public interface BinaryTagHolder
Holds a compound binary tag.
Instead of including an entire NBT implementation in Adventure, it was decided to use this "holder" interface instead. This opens the door for platform specific implementations.
See net.kyori.adventure.nbt.impl
for a platform agnostic implementation.
- Since:
- 4.0.0
-
Method Summary
Modifier and Type Method Description static <T, EX extends Exception>
@NonNull BinaryTagHolderencode(@NonNull T nbt, @NonNull Codec<? super T,String,?,EX> codec)
Encodesnbt
usingcodec
.<T, DX extends Exception>
@NonNull Tget(@NonNull Codec<T,String,DX,?> codec)
Gets the held value as a binary tag.static @NonNull BinaryTagHolder
of(@NonNull String string)
Creates an encoded binary tag holder.@NonNull String
string()
Gets the raw string value.
-
Method Details
-
encode
static <T, EX extends Exception> @NonNull BinaryTagHolder encode(@NonNull T nbt, @NonNull Codec<? super T,String,?,EX> codec) throws EX extends ExceptionEncodesnbt
usingcodec
.- Type Parameters:
T
- the binary tag typeEX
- encode exception type- Parameters:
nbt
- the binary tagcodec
- the codec- Returns:
- the encoded binary tag holder
- Throws:
EX
- if an error occurred while encoding the binary tag- Since:
- 4.0.0
-
of
Creates an encoded binary tag holder.- Parameters:
string
- the encoded binary tag value- Returns:
- the encoded binary tag
- Since:
- 4.0.0
-
string
@NonNull String string()Gets the raw string value.- Returns:
- the raw string value
- Since:
- 4.0.0
-
get
<T, DX extends Exception> @NonNull T get(@NonNull Codec<T,String,DX,?> codec) throws DX extends ExceptionGets the held value as a binary tag.- Type Parameters:
T
- the binary tag typeDX
- decode thrown exception type- Parameters:
codec
- the codec- Returns:
- the binary tag
- Throws:
DX
- if an error occurred while retrieving the binary tag- Since:
- 4.0.0
-