How can you make that I can take in my plugin only in a certain inventory no items but in the rest already (Minecraft plugin programming)?
Look who owns the inventory with inventoryholder
and then in the inventoryevents e.setCancelled true
That depends on your spigot version.
First of all, you would need to register a listener with the InventoryClickEvent. When the event is run, you'll need to check the name of the inventory and if it has the name of the inventory whose items should not be removable, you'll need to cancel it.
It looks like this:
@EventHandler
public void onInventoryClick (InventoryClickEvent inventoryClickEvent) {
// Query for the 1.13+
if (inventoryClickEvent.getView (). GetTitle (). Equals ("Inventory")) {
// Item must not be removable
inventoryClickEvent.setCancelled (true);
}
// Query for 1.x - 1.12.2
if (inventoryClickEvent.getTitle (). Equals ("Inventory")) {
// Item must not be removable
inventoryClickEvent.setCancelled (true);
}
}
Very good description - not.
Hehe. I thought that's enough - not xD
You should also cancel the InventoryDragEvent
I'm just not sure, can be.