Events - Jannyboy11/InvSee-plus-plus GitHub Wiki

InvSee++ currently provides two events, in the package com.janboerman.invsee.api.event:

SpectatorInventorySaveEvent is called when the contents of a SpectatorInventory is saved to the data file of the target player. This happens when plugins call InvseeAPI#save(..), or when a spectator finishes spectating the SpectatorInventory and closes the window. Note that this event implements Cancellable, so other plugins can prevent a save from happening!

SpectatorInventoryOfflineCreatedEvent is called when a SpectatorInventory is created while the target player is offline. Use this to detect obtain the original contents of an offline player's inventory (or ender chest), before another plugin or spectator modifies it.

To detect whether a SpectatorInventory targeting an online player is opened, use Bukkit's InventoryOpenEvent:

@EventHandler
public void onInventoryOpen(InventoryOpenEvent event) {
    if (event.getInventory() instanceof SpectatorInventory spectatorInventory) {
        //use spectatorInventory here
    }
}