Hashmap still returns empty

This commit is contained in:
Trent Hensler
2013-02-13 01:14:08 -06:00
parent f8048ef9eb
commit b4790c8c18
6 changed files with 80 additions and 110 deletions
@@ -11,6 +11,7 @@ import net.minecraft.server.v1_4_R1.NBTBase;
import net.minecraft.server.v1_4_R1.NBTTagCompound;
import net.minecraft.server.v1_4_R1.NBTTagList;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_4_R1.inventory.CraftInventoryCustom;
import org.bukkit.craftbukkit.v1_4_R1.inventory.CraftItemStack;
import org.bukkit.inventory.Inventory;
@@ -44,7 +45,7 @@ public class Serialization {
public static Inventory fromBase64(String data) {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
NBTTagList itemList = (NBTTagList) NBTBase.b(new DataInputStream(inputStream));
Inventory inventory = new CraftInventoryCustom(null, itemList.size());
Inventory inventory = new CraftInventoryCustom(null, itemList.size(), ChatColor.DARK_RED + "Vault");
for (int i = 0; i < itemList.size(); i++) {
NBTTagCompound inputObject = (NBTTagCompound) itemList.get(i);
@@ -5,7 +5,7 @@ import java.io.IOException;
import java.util.logging.Level;
import me.shock.playervaults.Main;
import me.shock.playervaults.commands.Feedback;
import me.shock.playervaults.commands.Commands;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -22,9 +22,10 @@ public class VaultManager {
public VaultManager(Main instance) {
this.plugin = instance;
}
Feedback feedback = new Feedback();
Commands commands = new Commands();
String title;
private static String directory = "plugins" + File.separator + "PlayerVaults" + File.separator + "vaults";
private String directory = "plugins" + File.separator + "PlayerVaults" + File.separator + "vaults";
/**
* Method to save player's vault.
@@ -34,7 +35,7 @@ public class VaultManager {
* @throws IOException
*/
public void saveVault(Inventory inv, Player player, int number) throws IOException {
if(feedback.hasKey(player.getName())) {
if(commands.inVault.containsKey(player.getName())) {
System.out.println("savevault");
// Get the player's file and serialize the inventory.
String ser = Serialization.toBase64(inv);
@@ -59,13 +60,12 @@ public class VaultManager {
String data = playerFile.getString("vault" + "" + number + "");
Player player = (Player) sender;
if(data == null) {
Inventory inv = Bukkit.createInventory(player, 54);
Inventory inv = Bukkit.createInventory(player, 54, ChatColor.DARK_RED + "Vault");
player.openInventory(inv);
} else {
Inventory inv = Serialization.fromBase64(data);
player.openInventory(inv);
}
player.sendMessage(title + " Opening " + ChatColor.GREEN + " " + number);
return;
}