When i cancel the InventoryClickEvent in creative i get the item in my hand and it stays in my inventory(so i have a duplicate) how can i fix this?
That's because it's only for clicking an inventory and not canceling other stuff like items on your cursor. See https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryCreativeEvent.html Use InventoryCreativeEvent which is what you want in your case.
event.setCancelled(true); event.setCursor(new ItemStack(Material.AIR)); event.setResult(Event.Result.DENY); after all these things i can still get the duplicate of the item... and yes i did use the InventoryCreativeEvent
Because you can't. Creative mode items is fully controlled by the client, you can spawn almost anything in your inventory.
I had a prison server and wanted my builders to go in creative, but not to duplicate items. So I wrote this code in my InventoryClickEvent: Code (Java): ItemStack stack = event.getCurrentItem(); if (stack == null || stack.getType() == Material.AIR) { stack = event.getCursor(); if (stack == null || stack.getType() == Material.AIR) { return; } } //HERE YOU CAN CHECK IF THE STACK MATCHES A SPECIFIC ITEM AND CANCEL THE EVENT //WITH event.setCancelled(true); This has solved my problem, they can have the item on their cursor, but it will cancel the event when they try to add it to their inventory.
I feel like it is clear enough that this is solved. I would have asked if somebody knew anything or wrote "bump"...
I marked it as solved after you wrote that. I think we should stop writing here since it bloats the thread activity screen ^^