Small cleanup
This commit is contained in:
@@ -41,11 +41,10 @@ public class Serialization {
|
|||||||
return Base64Coder.encodeLines(outputStream.toByteArray());
|
return Base64Coder.encodeLines(outputStream.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Inventory fromBase64(String data) {
|
public static Inventory fromBase64(String data, int number) {
|
||||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
|
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
|
||||||
NBTTagList itemList = (NBTTagList) NBTBase.b(new DataInputStream(inputStream));
|
NBTTagList itemList = (NBTTagList) NBTBase.b(new DataInputStream(inputStream));
|
||||||
Inventory inventory = new CraftInventoryCustom(null, itemList.size(), ChatColor.DARK_RED + "Vault");
|
Inventory inventory = new CraftInventoryCustom(null, itemList.size(), ChatColor.DARK_RED + "Vault #" + String.valueOf(number));
|
||||||
|
|
||||||
for (int i = 0; i < itemList.size(); i++) {
|
for (int i = 0; i < itemList.size(); i++) {
|
||||||
NBTTagCompound inputObject = (NBTTagCompound) itemList.get(i);
|
NBTTagCompound inputObject = (NBTTagCompound) itemList.get(i);
|
||||||
|
|
||||||
|
|||||||
@@ -42,15 +42,14 @@ public class VaultManager {
|
|||||||
*
|
*
|
||||||
* TODO: Check to see if the path exists before we get it!
|
* TODO: Check to see if the path exists before we get it!
|
||||||
*/
|
*/
|
||||||
public void loadVault(Player sender, String holder, int number) {
|
public void loadVault(Player player, String holder, int number) {
|
||||||
YamlConfiguration playerFile = playerVaultFile(holder);
|
YamlConfiguration playerFile = playerVaultFile(holder);
|
||||||
String data = playerFile.getString("vault" + number);
|
String data = playerFile.getString("vault" + number);
|
||||||
Player player = (Player) sender;
|
|
||||||
if(data == null) {
|
if(data == null) {
|
||||||
Inventory inv = Bukkit.createInventory(player, 54, ChatColor.DARK_RED + "Vault #" + String.valueOf(number));
|
Inventory inv = Bukkit.createInventory(player, 54, ChatColor.DARK_RED + "Vault #" + String.valueOf(number));
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
} else {
|
} else {
|
||||||
Inventory inv = Serialization.fromBase64(data);
|
Inventory inv = Serialization.fromBase64(data, number);
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,7 +65,7 @@ public class VaultManager {
|
|||||||
YamlConfiguration playerFile = playerVaultFile(player.getName());
|
YamlConfiguration playerFile = playerVaultFile(player.getName());
|
||||||
String data = playerFile.getString("vault" + number);
|
String data = playerFile.getString("vault" + number);
|
||||||
if(data == null) {
|
if(data == null) {
|
||||||
Inventory inv = Bukkit.createInventory(player, 54, ChatColor.DARK_RED + "Vault #" + String.valueOf(number));
|
Inventory inv = Bukkit.createInventory(player, 54, ChatColor.GREEN + "Vault #" + String.valueOf(number));
|
||||||
return inv;
|
return inv;
|
||||||
} else {
|
} else {
|
||||||
Inventory inv = Serialization.fromBase64(data);
|
Inventory inv = Serialization.fromBase64(data);
|
||||||
|
|||||||
Reference in New Issue
Block a user