public class StreamSerializer extends Object
| Constructor and Description |
|---|
StreamSerializer() |
| Modifier and Type | Method and Description |
|---|---|
NbtCompound |
deserializeCompound(DataInputStream input)
Read or deserialize an NBT compound from a input stream.
|
org.bukkit.inventory.ItemStack |
deserializeItemStack(DataInputStream input)
Deprecated.
This is a pretty hacky solution for backwards compatibility. See
deserializeItemStack(DataInputStream) |
org.bukkit.inventory.ItemStack |
deserializeItemStack(String input)
Deserialize an item stack from a base-64 encoded string.
|
String |
deserializeString(DataInputStream input,
int maximumLength)
Deserialize a string using the standard Minecraft UTF-16 encoding.
|
int |
deserializeVarInt(DataInputStream source)
Read a variable integer from an input stream.
|
static StreamSerializer |
getDefault()
Retrieve a default stream serializer.
|
void |
serializeCompound(DataOutputStream output,
NbtCompound compound)
Write or serialize a NBT compound to the given output stream.
|
void |
serializeItemStack(DataOutputStream output,
org.bukkit.inventory.ItemStack stack)
Write or serialize an item stack to the given output stream.
|
String |
serializeItemStack(org.bukkit.inventory.ItemStack stack)
Serialize an item stack as a base-64 encoded string.
|
void |
serializeString(DataOutputStream output,
String text)
Serialize a string using the standard Minecraft UTF-16 encoding.
|
void |
serializeVarInt(DataOutputStream destination,
int value)
Write a variable integer to an output stream.
|
public static StreamSerializer getDefault()
public void serializeVarInt(@Nonnull DataOutputStream destination, int value) throws IOException
destination - - the destination.value - - the value to write.IOException - The destination stream threw an exception.public int deserializeVarInt(@Nonnull DataInputStream source) throws IOException
source - - the source.IOException - The source stream threw an exception.public void serializeCompound(@Nonnull DataOutputStream output, NbtCompound compound) throws 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.IOException - If the operation fails due to reflection problems.public NbtCompound deserializeCompound(@Nonnull DataInputStream input) throws IOException
input - - the target input stream.IOException - If the operation failed due to reflection or corrupt data.public void serializeString(@Nonnull DataOutputStream output, String text) throws IOException
Note that strings cannot exceed 32767 characters, regardless if maximum lenght.
output - - the output stream.text - - the string to serialize.IOException - If the data in the string cannot be written.public String deserializeString(@Nonnull DataInputStream input, int maximumLength) throws IOException
Note that strings cannot exceed 32767 characters, regardless if maximum length.
input - - the input stream.maximumLength - - the maximum length of the string.IOException - If deserializing failspublic String serializeItemStack(org.bukkit.inventory.ItemStack stack) throws 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.IOException - If the operation fails due to reflection problems.public org.bukkit.inventory.ItemStack deserializeItemStack(String input) throws IOException
input - - base-64 encoded string.IOException - If the operation failed due to reflection or corrupt data.public void serializeItemStack(DataOutputStream output, org.bukkit.inventory.ItemStack stack) throws 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.IOException - If the operation fails due to reflection problems.@Deprecated public org.bukkit.inventory.ItemStack deserializeItemStack(DataInputStream input) throws IOException
deserializeItemStack(DataInputStream)
To supply a byte array, wrap it in a ByteArrayInputStream
and DataInputStream.
input - - the target input stream.IOException - If the operation failed due to reflection or corrupt data.Copyright © 2012–2017 Comphenix and dmulloy2. Licensed under the GNU GPL v2.