Skip to content

Commit

Permalink
Merge pull request #6 from TheNullicorn/dev
Browse files Browse the repository at this point in the history
Update v1.1.1
  • Loading branch information
TheNullicorn authored May 24, 2021
2 parents a0a1162 + 347cb62 commit a99ecea
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.nullicorn</groupId>
<artifactId>Nedit</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/me/nullicorn/nedit/NBTOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@ public NBTOutputStream(OutputStream out, boolean compress) throws IOException {
* @throws IOException If the compound could not be written
*/
public void writeFully(NBTCompound compound) throws IOException {
writeCompound(compound, false);
if (out instanceof GZIPOutputStream) {
((GZIPOutputStream) out).finish();
if (compound == null) {
writeTagType(TagType.END);
} else {
writeTagType(TagType.COMPOUND);
writeString("");
writeCompound(compound, false);

if (out instanceof GZIPOutputStream) {
((GZIPOutputStream) out).finish();
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/me/nullicorn/nedit/NBTWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public static void write(@NotNull NBTCompound data, @NotNull OutputStream output
* @param data NBT compound to serialize
* @param outputStream Output stream to write the serialized NBT to
* @param useCompression If true, the serialized data will be gzipped
* @throws IOException If the NBT data could not be serialized or the outpt stream could not be written to
* @throws IOException If the NBT data could not be serialized or the output stream could not be
* written to
*/
public static void write(@NotNull NBTCompound data, @NotNull OutputStream outputStream, boolean useCompression) throws IOException {
try (NBTOutputStream out = new NBTOutputStream(outputStream, useCompression)) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/me/nullicorn/nedit/type/NBTCompound.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
*/
public class NBTCompound extends HashMap<String, Object> {

/**
* @return Whether or not this compound contains a tag whose {@code name} and {@code type} match
* those provided
*/
public boolean containsTag(String key, TagType type) {
return TagType.fromObject(get(key)) == type;
}

/**
* @param key A dot-separated path to the desired field
* @param defaultValue The value to return if the field does not exist
Expand Down

0 comments on commit a99ecea

Please sign in to comment.