inventory-framework icon indicating copy to clipboard operation
inventory-framework copied to clipboard

click.closeForPlayer(): Container is not available in current context [Bukkit 1.8.9]

Open sqlongithub opened this issue 1 year ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

🐛 Describe the bug

When rendering a (layout) item with .withItem(), and setting an onClick handler with .onClick(click -> {}), closing the inventory with click.closeForPlayer() throws an exception with the message:

Container is not available in the current context: some.package.inventoryframework.context.SlotClickContext 
   at some.package.inventoryframework.context.PlatformContext.getContainerOrThrow(PlatformContext.java:111)

I'm not sure if this is because of layouts, but I wouldn't assume so.

✔️ Expected behavior

The inventory should close normally.

👣 Steps to Reproduce

  1. Compile the latest version of inventory-framework from github, and include it in your project
  2. Create a View
  3. In onInit() define a Layout for the View
  4. In onFirstRender(RenderContext render), render an item in the Layout with
render.layoutSlot('A').withItem(new ItemStack(Material.STICK)).onClick(click -> {
    click.setCancelled(true);
    click.closeForPlayer();
}).cancelOnClick();
  1. Open the GUI somehow
  2. Click on an item that is rendered as layoutSlot A
  3. Check the server console or logs

💻 Platform

  • [X] Bukkit
  • [ ] Sponge
  • [ ] Other

⭐ Server Version

1.8.9

📚 Library Version

v3.1.0-rc (compiled from github)

✍️ Additional context

No response

sqlongithub avatar Mar 05 '24 16:03 sqlongithub

Thx!! Working on it 🤙🏽

devnatan avatar Mar 13 '24 11:03 devnatan