I need a plugin to save the inventory in any file or database for when a player dies, and one administrator can restore it with a command. Is there any plugin that works on 1.6.2?
Save it in a hashmap, before they die. Give it back to them after they die. If you wanna use commands, save it in the same was as below, but them use the same method to give it back to them via commands. If you are unsure on how to do that, just tahg me. Code:java //Declare a global variablespublic Map<String, ItemStack[]> savedInventory = new HashMap<String, ItemStack[]>();public Map<String, ItemStack[]> savedArmourInventory = new HashMap<String, ItemStack[]>(); //Saving the inventory @EventHandler public void savePlayerInventory(PlayerDeathEvent event){Player p = event.getEntity();if(!savedInventory.containsKey(p.getName()) && !savedArmourInventory.containsKey(p.getName())){ savedInventory.put(p.getName(), p.getInventory().getContents().clone()); savedArmourInventory.put(p.getName(), p.getInventory().getArmorContents().clone()); p.sendMessage("Your inventory (" + p.getInventory().getContents().clone().length +" items saved). Armour saved as well");} }//Restoring the inventory@EventHandlerpublic void restorePlayerInventory(PlayerRespawnEvent event){final Player p = event.getPlayer();Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){@Overridepublic void run() {if(savedArmourInventory.containsKey(p.getName())){p.getInventory().setArmorContents(savedArmourInventory.get(p.getName()));savedArmourInventory.remove(p.getName());p.sendMessage("Restored your armour");}if(savedInventory.containsKey(p.getName())){p.getInventory().setContents(savedInventory.get(p.getName()));savedInventory.remove(p.getName());p.sendMessage("Restored" + savedInventory.get(p.getName()).length + "items");}} },20L);}
EdenCampo The damage event makes it easily calculable as to whether or not a player will die. The getHealth() call seems to obstruct the purpose of the original request. Or am I missing something?
I used that event, because i wasn't sure that with the death event, if the inventorys contents would return null or not