public class StreamSerializer
extends java.lang.Object
| Constructor and Description |
|---|
StreamSerializer() |
| Modifier and Type | Method and Description |
|---|---|
NbtCompound |
deserializeCompound(java.io.DataInputStream input)
Read or deserialize an NBT compound from a input stream.
|
org.bukkit.inventory.ItemStack |
deserializeItemStack(java.io.DataInputStream input)
Read or deserialize an item stack from an underlying input stream.
|
org.bukkit.inventory.ItemStack |
deserializeItemStack(java.lang.String input)
Deserialize an item stack from a base-64 encoded string.
|
java.lang.String |
deserializeString(java.io.DataInputStream input,
int maximumLength)
Deserialize a string using the standard Minecraft UTF-16 encoding.
|
int |
deserializeVarInt(java.io.DataInputStream source)
Read a variable integer from an input stream.
|
static StreamSerializer |
getDefault()
Retrieve a default stream serializer.
|
void |
serializeCompound(java.io.DataOutputStream output,
NbtCompound compound)
Write or serialize a NBT compound to the given output stream.
|
void |
serializeItemStack(java.io.DataOutputStream output,
org.bukkit.inventory.ItemStack stack)
Write or serialize an item stack to the given output stream.
|
java.lang.String |
serializeItemStack(org.bukkit.inventory.ItemStack stack)
Serialize an item stack as a base-64 encoded string.
|
void |
serializeString(java.io.DataOutputStream output,
java.lang.String text)
Serialize a string using the standard Minecraft UTF-16 encoding.
|
void |
serializeVarInt(java.io.DataOutputStream destination,
int value)
Write a variable integer to an output stream.
|
public static StreamSerializer getDefault()
public int deserializeVarInt(@Nonnull
java.io.DataInputStream source)
throws java.io.IOException
source - - the source.java.io.IOException - The source stream threw an exception.public void serializeVarInt(@Nonnull
java.io.DataOutputStream destination,
int value)
throws java.io.IOException
destination - - the destination.value - - the value to write.java.io.IOException - The destination stream threw an exception.public org.bukkit.inventory.ItemStack deserializeItemStack(@Nonnull
java.io.DataInputStream input)
throws java.io.IOException
To supply a byte array, wrap it in a ByteArrayInputStream
and DataInputStream.
input - - the target input stream.java.io.IOException - If the operation failed due to reflection or corrupt data.public NbtCompound deserializeCompound(@Nonnull java.io.DataInputStream input) throws java.io.IOException
input - - the target input stream.java.io.IOException - If the operation failed due to reflection or corrupt data.public java.lang.String deserializeString(@Nonnull
java.io.DataInputStream input,
int maximumLength)
throws java.io.IOException
Note that strings cannot exceed 32767 characters, regardless if maximum lenght.
input - - the input stream.maximumLength - - the maximum lenght of the string.java.io.IOExceptionpublic org.bukkit.inventory.ItemStack deserializeItemStack(@Nonnull
java.lang.String input)
throws java.io.IOException
input - - base-64 encoded string.java.io.IOException - If the operation failed due to reflection or corrupt data.public void serializeItemStack(@Nonnull
java.io.DataOutputStream output,
org.bukkit.inventory.ItemStack stack)
throws java.io.IOException
To supply a byte array, wrap it in a ByteArrayOutputStream
and DataOutputStream.
Note: An ItemStack can be written to a stream even if it's NULL.
output - - the target output stream.stack - - the item stack that will be written, or NULL to represent air/nothing.java.io.IOException - If the operation fails due to reflection problems.public void serializeCompound(@Nonnull
java.io.DataOutputStream output,
NbtCompound compound)
throws java.io.IOException
Note: An NBT compound can be written to a stream even if it's NULL.
output - - the target output stream.compound - - the NBT compound to be serialized, or NULL to represent nothing.java.io.IOException - If the operation fails due to reflection problems.public void serializeString(@Nonnull
java.io.DataOutputStream output,
java.lang.String text)
throws java.io.IOException
Note that strings cannot exceed 32767 characters, regardless if maximum lenght.
output - - the output stream.text - - the string to serialize.java.io.IOException - If the data in the string cannot be written.public java.lang.String serializeItemStack(org.bukkit.inventory.ItemStack stack)
throws java.io.IOException
Note: An ItemStack can be written to the serialized text even if it's NULL.
stack - - the item stack to serialize, or NULL to represent air/nothing.java.io.IOException - If the operation fails due to reflection problems.