Errors on implementing a custom Inventory type

I’m developing a plugin for my server that has multiple functions and one of these include a Gravestone system. My idea for the implementation is to have a GravestoneInventory that implements org.bukkit.inventory.Inventory as a way to have complete control of the inventory, preventing more interactions than necessary without using events. However once I try to display this inventory to the player I get the error java.lang.ClassCastException: class net.baterina.commandbook.entities.GravestoneInventory cannot be cast to class org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventory (net.baterina.commandbook.entities.GravestoneInventory is in unnamed module of loader @237d46d8; org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventory is in unnamed module of loader 'app') which I don’t know how to solve. I could not find the CraftInventory class in the api library which probably means it shouldn’t be used directly, and thus cannot be extended for the creation of my own inventory. What is the best approach for implementing a custom inventory? Preferably without having to use events to cancel interactions like adding items.

Inventory is not a class you can implement yourself, basically; People just use standard API inventories and use the events fired for inventories using stuff like the name or InventoryHolder to identify them in the events

Why exactly? Is it a limitation of how paper/bukkit behaves interally or limitations of the minecraft client/protocol? I’m fairly new to the api and don’t know its limitations.

it’s a limitation of how vanilla behaviors and how CB wraps and interfaces with inventories, vanilla was never designed to be modded, and so very little cares to handle the case that somebody might try to implement a random interface in the API

That’s unfortunate, I was hoping I would be able to write some cleaner code for my plugin. Thanks for the help!