Ensure that players inventories are saved often
This commit is contained in:
parent
cfe5f38ed4
commit
6383f6d074
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user