Ensure that players inventories are saved often

This commit is contained in:
Sam 2017-11-08 22:37:22 +00:00 committed by Alexander Meech
parent cfe5f38ed4
commit 6383f6d074

View File

@ -29,7 +29,8 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerKitGiveEvent;
@ -130,22 +131,27 @@ public class CakePlayerModule extends CakeModule
}
@EventHandler(priority = EventPriority.LOWEST)
public void saveInventory(CustomDamageEvent event)
public void saveInventory(UpdateEvent event)
{
Player player = event.GetDamageePlayer();
if (player == null || !UtilInv.contains(player, RUNE_OF_HOLDING.getType(), RUNE_OF_HOLDING.getData().getData(), 1))
{
return;
}
PlayerInventory inventory = player.getInventory();
_game.GetPlayers(true).forEach(player ->
{
if (UtilInv.contains(player, RUNE_OF_HOLDING.getType(), RUNE_OF_HOLDING.getData().getData(), 1))
{
return;
}
_storedInventory.put(player, new ItemStack[][]
{
inventory.getContents(),
inventory.getArmorContents()
});
PlayerInventory inventory = player.getInventory();
_storedInventory.put(player, new ItemStack[][]
{
inventory.getContents(),
inventory.getArmorContents()
});
});
}
@EventHandler(priority = EventPriority.LOWEST)