This repository has been archived by the owner on Apr 27, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from booleanbyte/eol
Normalize line endings to Unix style
- Loading branch information
Showing
15 changed files
with
1,848 additions
and
1,848 deletions.
There are no files selected for viewing
762 changes: 381 additions & 381 deletions
762
src/main/java/com/github/steveice10/opennbt/SNBTIO.java
Large diffs are not rendered by default.
Oops, something went wrong.
244 changes: 122 additions & 122 deletions
244
src/main/java/com/github/steveice10/opennbt/tag/builtin/ByteArrayTag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,122 @@ | ||
package com.github.steveice10.opennbt.tag.builtin; | ||
|
||
import java.io.DataInput; | ||
import java.io.DataOutput; | ||
import java.io.IOException; | ||
|
||
import com.github.steveice10.opennbt.SNBTIO.StringifiedNBTReader; | ||
import com.github.steveice10.opennbt.SNBTIO.StringifiedNBTWriter; | ||
|
||
/** | ||
* A tag containing a byte array. | ||
*/ | ||
public class ByteArrayTag extends Tag { | ||
private byte[] value; | ||
|
||
/** | ||
* Creates a tag with the specified name. | ||
* | ||
* @param name The name of the tag. | ||
*/ | ||
public ByteArrayTag(String name) { | ||
this(name, new byte[0]); | ||
} | ||
|
||
/** | ||
* Creates a tag with the specified name. | ||
* | ||
* @param name The name of the tag. | ||
* @param value The value of the tag. | ||
*/ | ||
public ByteArrayTag(String name, byte[] value) { | ||
super(name); | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public byte[] getValue() { | ||
return this.value.clone(); | ||
} | ||
|
||
/** | ||
* Sets the value of this tag. | ||
* | ||
* @param value New value of this tag. | ||
*/ | ||
public void setValue(byte[] value) { | ||
if(value == null) { | ||
return; | ||
} | ||
|
||
this.value = value.clone(); | ||
} | ||
|
||
/** | ||
* Gets a value in this tag's array. | ||
* | ||
* @param index Index of the value. | ||
* @return The value at the given index. | ||
*/ | ||
public byte getValue(int index) { | ||
return this.value[index]; | ||
} | ||
|
||
/** | ||
* Sets a value in this tag's array. | ||
* | ||
* @param index Index of the value. | ||
* @param value Value to set. | ||
*/ | ||
public void setValue(int index, byte value) { | ||
this.value[index] = value; | ||
} | ||
|
||
/** | ||
* Gets the length of this tag's array. | ||
* | ||
* @return This tag's array length. | ||
*/ | ||
public int length() { | ||
return this.value.length; | ||
} | ||
|
||
@Override | ||
public void read(DataInput in) throws IOException { | ||
this.value = new byte[in.readInt()]; | ||
in.readFully(this.value); | ||
} | ||
|
||
@Override | ||
public void write(DataOutput out) throws IOException { | ||
out.writeInt(this.value.length); | ||
out.write(this.value); | ||
} | ||
|
||
@Override | ||
public void destringify(StringifiedNBTReader in) throws IOException { | ||
String s = in.readUntil(true, ']'); | ||
String[] valueStrings = s.substring(s.indexOf(';') + 1, s.length() - 1).replaceAll(" ", "").split(","); | ||
value = new byte[valueStrings.length]; | ||
for(int i = 0; i < value.length; i++) { | ||
value[i] = Byte.parseByte(valueStrings[i]); | ||
} | ||
} | ||
|
||
@Override | ||
public void stringify(StringifiedNBTWriter out, boolean linebreak, int depth) throws IOException { | ||
StringBuilder sb = new StringBuilder("[B; "); | ||
for(byte b : value) { | ||
sb.append(b); | ||
sb.append(','); | ||
sb.append(' '); | ||
} | ||
sb.setLength(sb.length() - 2); | ||
sb.append(']'); | ||
out.append(sb.toString()); | ||
} | ||
|
||
@Override | ||
public ByteArrayTag clone() { | ||
return new ByteArrayTag(this.getName(), this.getValue()); | ||
} | ||
} | ||
package com.github.steveice10.opennbt.tag.builtin; | ||
|
||
import java.io.DataInput; | ||
import java.io.DataOutput; | ||
import java.io.IOException; | ||
|
||
import com.github.steveice10.opennbt.SNBTIO.StringifiedNBTReader; | ||
import com.github.steveice10.opennbt.SNBTIO.StringifiedNBTWriter; | ||
|
||
/** | ||
* A tag containing a byte array. | ||
*/ | ||
public class ByteArrayTag extends Tag { | ||
private byte[] value; | ||
|
||
/** | ||
* Creates a tag with the specified name. | ||
* | ||
* @param name The name of the tag. | ||
*/ | ||
public ByteArrayTag(String name) { | ||
this(name, new byte[0]); | ||
} | ||
|
||
/** | ||
* Creates a tag with the specified name. | ||
* | ||
* @param name The name of the tag. | ||
* @param value The value of the tag. | ||
*/ | ||
public ByteArrayTag(String name, byte[] value) { | ||
super(name); | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public byte[] getValue() { | ||
return this.value.clone(); | ||
} | ||
|
||
/** | ||
* Sets the value of this tag. | ||
* | ||
* @param value New value of this tag. | ||
*/ | ||
public void setValue(byte[] value) { | ||
if(value == null) { | ||
return; | ||
} | ||
|
||
this.value = value.clone(); | ||
} | ||
|
||
/** | ||
* Gets a value in this tag's array. | ||
* | ||
* @param index Index of the value. | ||
* @return The value at the given index. | ||
*/ | ||
public byte getValue(int index) { | ||
return this.value[index]; | ||
} | ||
|
||
/** | ||
* Sets a value in this tag's array. | ||
* | ||
* @param index Index of the value. | ||
* @param value Value to set. | ||
*/ | ||
public void setValue(int index, byte value) { | ||
this.value[index] = value; | ||
} | ||
|
||
/** | ||
* Gets the length of this tag's array. | ||
* | ||
* @return This tag's array length. | ||
*/ | ||
public int length() { | ||
return this.value.length; | ||
} | ||
|
||
@Override | ||
public void read(DataInput in) throws IOException { | ||
this.value = new byte[in.readInt()]; | ||
in.readFully(this.value); | ||
} | ||
|
||
@Override | ||
public void write(DataOutput out) throws IOException { | ||
out.writeInt(this.value.length); | ||
out.write(this.value); | ||
} | ||
|
||
@Override | ||
public void destringify(StringifiedNBTReader in) throws IOException { | ||
String s = in.readUntil(true, ']'); | ||
String[] valueStrings = s.substring(s.indexOf(';') + 1, s.length() - 1).replaceAll(" ", "").split(","); | ||
value = new byte[valueStrings.length]; | ||
for(int i = 0; i < value.length; i++) { | ||
value[i] = Byte.parseByte(valueStrings[i]); | ||
} | ||
} | ||
|
||
@Override | ||
public void stringify(StringifiedNBTWriter out, boolean linebreak, int depth) throws IOException { | ||
StringBuilder sb = new StringBuilder("[B; "); | ||
for(byte b : value) { | ||
sb.append(b); | ||
sb.append(','); | ||
sb.append(' '); | ||
} | ||
sb.setLength(sb.length() - 2); | ||
sb.append(']'); | ||
out.append(sb.toString()); | ||
} | ||
|
||
@Override | ||
public ByteArrayTag clone() { | ||
return new ByteArrayTag(this.getName(), this.getValue()); | ||
} | ||
} |
Oops, something went wrong.