33import core .nbt .tag .EscapeTag ;
44import core .nbt .tag .Tag ;
55import lombok .Getter ;
6- import org .jspecify .annotations .NonNull ;
6+ import org .jspecify .annotations .NullMarked ;
77import org .jspecify .annotations .Nullable ;
88
99import java .io .DataOutputStream ;
1313import java .nio .charset .StandardCharsets ;
1414import java .util .zip .GZIPOutputStream ;
1515
16+ /**
17+ * A specialized DataOutputStream for writing Named Binary Tag (NBT) data.
18+ * This stream supports GZIP compression and allows for writing various
19+ * types of NBT tags.
20+ */
1621@ Getter
22+ @ NullMarked
1723public final class NBTOutputStream extends DataOutputStream {
18- private final @ NonNull Charset charset ;
24+ private final Charset charset ;
1925
2026 /**
2127 * Create a nbt output stream
2228 *
2329 * @param outputStream the stream to write to
2430 * @throws IOException thrown if something goes wrong
2531 */
26- public NBTOutputStream (@ NonNull OutputStream outputStream ) throws IOException {
32+ public NBTOutputStream (OutputStream outputStream ) throws IOException {
2733 this (outputStream , StandardCharsets .UTF_8 );
2834 }
2935
@@ -34,7 +40,7 @@ public NBTOutputStream(@NonNull OutputStream outputStream) throws IOException {
3440 * @param outputStream the stream to write to
3541 * @throws IOException thrown if something goes wrong
3642 */
37- public NBTOutputStream (@ NonNull OutputStream outputStream , @ NonNull Charset charset ) throws IOException {
43+ public NBTOutputStream (OutputStream outputStream , Charset charset ) throws IOException {
3844 super (new GZIPOutputStream (outputStream ));
3945 this .charset = charset ;
4046 }
@@ -47,7 +53,7 @@ public NBTOutputStream(@NonNull OutputStream outputStream, @NonNull Charset char
4753 * @throws IOException thrown if something goes wrong
4854 * @throws IllegalArgumentException thrown if an escape tag was provided
4955 */
50- public void writeTag (@ Nullable String name , @ NonNull Tag tag ) throws IOException , IllegalArgumentException {
56+ public void writeTag (@ Nullable String name , Tag tag ) throws IOException , IllegalArgumentException {
5157 if (tag instanceof EscapeTag ) throw new IllegalArgumentException ("EscapeTag not allowed" );
5258 var bytes = name != null ? name .getBytes (getCharset ()) : new byte [0 ];
5359 writeByte (tag .getTypeId ());
0 commit comments