LogoLogo
JavaDocsVersions
  • Introduction
  • Getting started
    • Dependencies
    • Your first server
  • Feature
    • Adventure
    • Player capabilities
    • Events
      • Implementation
      • Server list ping
    • Items
    • Entities
      • AI
    • Tags
    • Schedulers
    • Commands
    • Inventories
    • Player UUID
    • Player skin
    • Permissions
    • Advancements
    • Map rendering
      • GLFWMapRendering
    • Query system
    • Open to LAN
  • Thread Architecture
    • Thread safety in the JVM
    • Acquirable API
      • The inside
  • World
    • Instances
    • Chunk management
      • Anvil Loader
    • Blocks
    • Coordinates
    • Generation
    • Batch
  • Extension System
    • Extensions
Powered by GitBook
On this page
  • Adding an inventory condition
  • InventoryPreClickEvent (see the events page)
  • InventoryClickEvent (see the events page)

Was this helpful?

Export as PDF
  1. Feature

Inventories

Inventories take a large place in Minecraft, they are used both for items storage and client<->server communication.

In order to create one, you can simply call its constructor by specifying an InventoryType and its name

// Create the inventory
Inventory inventory = new Inventory(InventoryType.CHEST_1_ROW, "The inventory name");

// Open the inventory for the player 
// (Opening the same inventory for multiple players would result in a shared interface)
player.openInventory(inventory);

// Close the current player inventory
player.closeInventory();

Sometimes you will want to add callbacks to your inventory actions (clicks). There are currently 3 ways of interacting with them.

Adding an inventory condition

Inventory conditions are specific to only one inventory. You are able to cancel the interaction by using InventoryConditionResult#setCancel

inventory.addInventoryCondition((player, slot, clickType, inventoryConditionResult) -> {
   player.sendMessage("click type inventory: " + clickType);
   System.out.println("slot inv: " + slot);
   inventoryConditionResult.setCancel(false);
});

Really similar to inventory conditions except that it listens to every inventory (you can obviously add checks when needed, but its goal is to be more "general")

This event only listens to successful actions (not canceled) and is fired after setting the items in the inventory.

PreviousCommandsNextPlayer UUID

Last updated 1 year ago

Was this helpful?

InventoryPreClickEvent (see )

InventoryClickEvent (see )

the events page
the events page