Persistence - Jannyboy11/InvSee-plus-plus GitHub Wiki
If you made changes to your SpectatorInventory (e.g. using .addItem(..)
or .remove(..)
), then it is strongly recommended to save the inventory back to the player's data storage. If you want your changes to the target's inventory or enderchest to persist, then this is a strict requirement!
To save the changes made to the target's main inventory:
InvseeAPI api = ...
MainSpectatorInventory inventory = ...
api.saveInventory(inventory);
Idem for the target's ender chest:
InvseeAPI api = ...
EnderSpectatorInventory enderChest = ...
api.saveEnderChest(enderChest);
InvseeAPI#saveInventory
and InvseeAPI#saveEnderChest
return a CompletableFuture<Void>
- this future completes successfully when the inventory is actually saved. InvSee++ calls these methods itself on an InventoryCloseEvent
, meaning you won't have to do this yourself if all that you do is using the SpectatorInventory to have an admin player spectate a regular player.
Do not worry about this. InvSee++ already sets the contents of the real player's inventory to what is in the SpectatorInventory. Then, it 'shallow copies' the player's inventory into the SpectatorInventory, meaning you always get an accurate up-to-date view on the contents of the player's inventories!
Idem. InvSee++ handles this by making sure the two admins are receiving the same SpectatorInventory instance, meaning they can see eachothers modifications!