本文整理汇总了Java中org.bukkit.util.io.BukkitObjectInputStream.close方法的典型用法代码示例。如果您正苦于以下问题:Java BukkitObjectInputStream.close方法的具体用法?Java BukkitObjectInputStream.close怎么用?Java BukkitObjectInputStream.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.util.io.BukkitObjectInputStream
的用法示例。
在下文中一共展示了BukkitObjectInputStream.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromBase64
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
/**
*
* A method to get an {@link Inventory} from an encoded, Base64, string.
*
* <p />
*
* Special thanks to Comphenix in the Bukkit forums or also known
* as aadnk on GitHub.
*
* <a href="https://gist.github.com/aadnk/8138186">Original Source</a>
*
* @param data Base64 string of data containing an inventory.
* @return Inventory created from the Base64 string.
* @throws IOException
*/
public static Inventory fromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt(),"Vault");
for (int i = 0; i < inventory.getSize(); i++) {
inventory.setItem(i, (ItemStack) dataInput.readObject());
}
dataInput.close();
return inventory;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
示例2: itemStackArrayFromBase64
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
/**
* Gets an array of ItemStacks from Base64 string.
*
* <p />
*
* Base off of {@link #fromBase64(String)}.
*
* @param data Base64 string to convert to ItemStack array.
* @return ItemStack array created from the Base64 string.
* @throws IOException
*/
public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack[] items = new ItemStack[dataInput.readInt()];
for (int i = 0; i < items.length; i++) {
items[i] = (ItemStack) dataInput.readObject();
}
dataInput.close();
return items;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
示例3: itemStackArrayFromBase64
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack[] items = new ItemStack[dataInput.readInt()];
for (int i = 0; i < items.length; i++) {
items[i] = (ItemStack) dataInput.readObject();
}
dataInput.close();
return items;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
示例4: itemStackArrayFromBase64
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack[] items = new ItemStack[dataInput.readInt()];
// Read the serialized inventory
for (int i = 0; i < items.length; i++) {
items[i] = (ItemStack) dataInput.readObject();
}
dataInput.close();
return items;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
示例5: fromBase64
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
public static Inventory fromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt());
// Read the serialized inventory
for (int i = 0; i < inventory.getSize(); i++) {
inventory.setItem(i, (ItemStack) dataInput.readObject());
}
dataInput.close();
return inventory;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
示例6: deserializeItemStack
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
public static ItemStack deserializeItemStack(String s) {
try {
byte[] b = BukkitObjectUtil.hexStringToByteArray(s);
ByteArrayInputStream bais = new ByteArrayInputStream(b);
BukkitObjectInputStream bois = new BukkitObjectInputStream(bais);
ItemStack items = (ItemStack) bois.readObject();
bois.close();
bais.close();
return items;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
示例7: deserializeItemStacks
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
public static ItemStack[] deserializeItemStacks(String s) {
try {
byte[] b = BukkitObjectUtil.hexStringToByteArray(s);
ByteArrayInputStream bais = new ByteArrayInputStream(b);
BukkitObjectInputStream bois = new BukkitObjectInputStream(bais);
ItemStack[] items = (ItemStack[]) bois.readObject();
bois.close();
bais.close();
return items;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
示例8: deserializePotionEffects
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
public static List<PotionEffect> deserializePotionEffects(String s) {
try {
byte[] b = BukkitObjectUtil.hexStringToByteArray(s);
ByteArrayInputStream bais = new ByteArrayInputStream(b);
BukkitObjectInputStream bois = new BukkitObjectInputStream(bais);
PotionEffect[] eff = (PotionEffect[]) bois.readObject();
bois.close();
bais.close();
return Arrays.asList(eff);
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
示例9: fromBase64
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
public static Inventory fromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt());
// Read the serialized inventory
for (int i = 0; i < inventory.getSize(); i++) {
inventory.setItem(i, (ItemStack) dataInput.readObject());
}
dataInput.close();
return inventory;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
示例10: NationsContainer
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
public NationsContainer(NBTCompoundTag rootTag, Chunk chunk) throws IOException, ClassNotFoundException
{
int x = ((NBTShortTag)rootTag.getTag("X")).getValue() + chunk.getX() * 16;
int y = ((NBTShortTag)rootTag.getTag("Y")).getValue();
int z = ((NBTShortTag)rootTag.getTag("Z")).getValue() + chunk.getZ() * 16;
location = new Location(chunk.getWorld(), x,y,z);
byte[] itemsRaw = ((NBTByteArrayTag)rootTag.getTag("BukkitItemStackArray")).getValue();
ByteArrayInputStream itemsStream = new ByteArrayInputStream(itemsRaw);
BukkitObjectInputStream bois = new BukkitObjectInputStream(itemsStream);
items = (ItemStack[])bois.readObject();
bois.close();
invType = InventoryType.valueOf(((NBTStringTag)rootTag.getTag("InventoryType")).getValue());
}
示例11: stringToInventory
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
/**
* Transfer a string into an inventory
*
* @param data String
* @return Inventory
* @throws IOException Failed.
*/
@Deprecated
public static Inventory stringToInventory(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt());
// Read the serialized inventory
for (int i = 0; i < inventory.getSize(); i++) {
inventory.setItem(i, (ItemStack) dataInput.readObject());
}
dataInput.close();
return inventory;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
示例12: fromBase64
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
public static Inventory fromBase64(String data) {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt());
// Read the serialized inventory
for (int i = 0; i < inventory.getSize(); i++) {
inventory.setItem(i, (ItemStack) dataInput.readObject());
}
dataInput.close();
return inventory;
} catch (Exception e) {
}
return null;
}
示例13: fromBase64
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
/**
*
* A method to get an {@link Inventory} from an encoded, Base64, string.
*
* <p>
*
* Special thanks to Comphenix in the Bukkit forums or also known
* as aadnk on GitHub.
*
* <a href="https://gist.github.com/aadnk/8138186">Original Source</a>
*
* @param data Base64 string of data containing an inventory.
* @return Inventory created from the Base64 string.
* @throws IOException if we were unable to parse the base64 string
*/
public static Inventory fromBase64(String data) throws IOException {
if(data.isEmpty()) return Bukkit.getServer().createInventory(null, 0);
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
int size = dataInput.readInt();
Inventory inventory = Bukkit.getServer().createInventory(null, (int)Math.ceil((double)size / inventoryMultipule) * inventoryMultipule);
// Read the serialized inventory
for (int i = 0; i < size; i++) {
inventory.setItem(i, (ItemStack) dataInput.readObject());
}
dataInput.close();
inputStream.close();
return inventory;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
示例14: itemStackArrayFromBase64
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
/**
* Gets an array of ItemStacks from Base64 string.
*
* <p>
*
* Base off of {@link #fromBase64(String)}.
*
* @param data Base64 string to convert to ItemStack array.
* @return ItemStack array created from the Base64 string.
* @throws IOException if we was unable to parse the base64 string
*/
public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
if(data.isEmpty()) return new ItemStack[] {};
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack[] items = new ItemStack[dataInput.readInt()];
// Read the serialized inventory
for (int i = 0; i < items.length; i++) {
items[i] = (ItemStack) dataInput.readObject();
}
dataInput.close();
return items;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
示例15: fromBase64Obj
import org.bukkit.util.io.BukkitObjectInputStream; //导入方法依赖的package包/类
public static Object fromBase64Obj(String data)
{
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
Object obj = dataInput.readObject();
dataInput.close();
return obj;
} catch (Exception e) {
return null;
}
}