Loadouts and inventory storage works. :D

This commit is contained in:
taoneill 2011-01-16 21:47:15 -05:00
parent b1ceaa3f46
commit efa3b63ea9
2 changed files with 11 additions and 21 deletions

View File

@ -88,7 +88,7 @@ public class War extends JavaPlugin {
this.defaultLifepool = 7;
this.defaultFriendlyFire = false;
this.defaultAutoAssignOnly = false;
getLogger().info("Loading War secrets...");
getLogger().info("Loading War files...");
WarMapper.load(this, this.getServer().getWorlds()[0]);
getLogger().info("War v" + version + " is on.");
}

View File

@ -36,7 +36,7 @@ public class Warzone {
private HashMap<Integer, ItemStack> loadout;
private boolean drawZoneOutline;
private HashMap<String, List<ItemStack>> inventories = new HashMap<String, List<ItemStack>>();
private HashMap<String, ItemStack[]> inventories = new HashMap<String, ItemStack[]>();
private World world;
private Material[] originalSoutheastBlocks;
private Material[] originalNorthwestBlocks;
@ -343,11 +343,7 @@ public class Warzone {
private void handleRespawn(Team team, Player player){
// Reset inventory to loadout
PlayerInventory playerInv = player.getInventory();
// BUKKIT
// for(int i = 0; i < playerInv.getSize(); i++){
// playerInv.setItem(index, new ItemStack(Material.))
// playerInv.setItem(i, null);
// }
playerInv.clear();
for(Integer slot : loadout.keySet()) {
// if(slot == 101) {
// playerInv.setLeggings(loadout.get(slot));
@ -367,7 +363,6 @@ public class Warzone {
} else if (team.getMaterial() == Material.IRON_BLOCK) {
playerInv.setHelmet(new ItemStack(Material.IRON_BOOTS));
}
//player.setHealth(20);
}
@ -439,23 +434,18 @@ public class Warzone {
public void keepPlayerInventory(Player player) {
PlayerInventory inventory = player.getInventory();
List<ItemStack> invToStore = new ArrayList<ItemStack>();
for(int i=0; i < inventory.getSize(); i++) {
invToStore.add(i, inventory.getItem(i));
}
inventories.put(player.getName(), invToStore);
ItemStack[] contents = inventory.getContents();
inventories.put(player.getName(), contents);
}
public void restorePlayerInventory(Player player) {
List<ItemStack> originalContents = inventories.remove(player.getName());
ItemStack[] originalContents = inventories.remove(player.getName());
PlayerInventory playerInv = player.getInventory();
// BUKKIT
// for(int i = 0; i < playerInv.getSize(); i++) {
// playerInv.setItem(i, new ItemStack(Material.AIR));
// }
// for(int i = 0; i < playerInv.getSize(); i++) {
// playerInv.setItem(i, originalContents.get(i));
// }
playerInv.clear();
playerInv.remove(Material.DIAMOND_BOOTS.getId());
playerInv.remove(Material.GOLD_BOOTS.getId());
playerInv.remove(Material.IRON_BOOTS.getId());
playerInv.setContents(originalContents);
}
public boolean hasMonument(String monumentName) {