{solved]property(AcceptsItems.of(item)) problème


#1

Salut.
Petite question, j’aimerais limiter l’ajout de certains items dans un inventaire. J’aimerais qu’on puisse ajouter seulement un item qui a une key spécial.
Le problème c’est qu’on peut toujours ajouter n’importe quoi.

translate.google.fr:
Hello.
Small question, I would like to limit the addition of certain items in an inventory. I wish we could add only one item that has a special key.
The problem is that you can always add anything.

Code

ItemStack ac = ItemStack.builder().itemType(ItemTypes.EMERALD).build();
ac.offer(new MyInventoryData(new HashMap<Integer, ItemStack>()));

LinkedList<ItemStack> item = new LinkedList<>();
item.add(ac);

Inventory inventory = Inventory.builder().of(InventoryArchetypes.CHEST)
.property(InventoryTitle.of(Text.of(“SecretName”)))
.property(InventoryDimension.of(9, 3))
.property(AcceptsItems.of(item))
.build(Tool.getInstance());
player.openInventory(inventory);