Inventory.Builder#listener() not firing

I cannot get Inventory.Builder#listener() to fire for a custom inventory I’m creating. I am not sure if I am doing wrong or if this is an issue I should report on GitHub. It’s hard to figure out because I don’t see anything about the inventory builder at all on the Sponge Docs website.

Here’s code to reproduce my problem:

public void onTest(MessageChannelEvent.Chat event, @First Player player) {
	if (!event.getRawMessage().toPlain().equalsIgnoreCase("!test")) return;

	Inventory custom = Inventory.builder()
			.property(InventoryTitle.PROPERTY_NAME, InventoryTitle.of(Text.of("Fancy custom inventory")))
			// Log to the console whenever something in the inventory is clicked on
			.listener(ClickInventoryEvent.class, e ->"Click inside custom inventory"))

			.query(SlotPos.of(1, 1))
			.offer(ItemStack.of(ItemTypes.DIAMOND, 1));


Write “!test” in chat and click the diamond. I’d expect something to be logged in the console, but not getting anything.

  • Am I doing something wrong or is this a bug?
  • What events are applicable for the listener() method?
  • Is there any documentation about the inventory builder? I have no idea how inventory properties, archetypes or queries work at all other than guessing my way through a lot of it. I’ve looked through the Sponge Documentation website but haven’t found anything about the listener() method at all. Googling results in very few results. As with many Sponge things, I just have to guess how to use things. How are new Sponge users supposed to figure these things out? I often feel very lost when working towards the Sponge API because of the lack of documentation or guidance.

Any help or insight would be greatly appreciated :tada:


Someone else reported it as a bug:

A temporary workaround is to use InventoryArchetypes.MENU_GRID and it will work again. Thanks to @RysingDragon for discovering that!