Metadata-Version: 2.4
Name: endstone-inventoryui
Version: 2.0.0
Summary: Inventory UI plugin for Endstone servers
Project-URL: Homepage, https://github.com/Shock95/endstone-inventoryui
Author: Shock95
License: MIT License
        
        Copyright (c) 2025 Shock95
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: endstone,plugin
Requires-Dist: bedrock-protocol-packets-ng==0.0.9
Description-Content-Type: text/markdown

# endstone-inventoryui

Virtual inventory plugin for Endstone

## API

### MenuType

Enum for menu container types:

- `MenuType.CHEST` — single chest (27 slots)
- `MenuType.DOUBLE_CHEST` — double chest (54 slots)
- `MenuType.DISPENSER` — dispenser (9 slots)
- `MenuType.HOPPER` — hopper (5 slots)

### Menu

```python
Menu(type: MenuType, name: str = "")
```

**Properties:**

- `inventory` — the `MenuInventory` instance for this menu. Implements an API similar to Endstone's `Inventory`.
- `name` — display name shown at the top of the menu
- `type` — the `MenuType` used to create this menu

**Methods:**

- `set_name(name: str)` — set the display name
- `set_listener(listener)` — set the click callback (see [MenuTransaction](#menutransaction))
- `set_open_listener(listener)` — callback when a player opens the menu: `(player: Player) -> None`
- `set_close_listener(listener)` — callback when a player closes the menu: `(player: Player) -> None`
- `send_to(player: Player)` — display the menu to a player. If the player already has a menu open, this menu is queued and shown after the current one closes.
- `close(player: Player) -> bool` — close this menu for a player
- `close_all()` — close this menu for all players currently viewing it
- `get_viewers() -> list[Player]` — list players who currently have this menu open

### MenuTransaction

**Properties:**

- `player` — the player who clicked
- `slot` — virtual inventory slot index
- `item_clicked` — item in the virtual slot before the action
- `item_clicked_with` — item in the other slot involved (player inventory or cursor)
- `action_type` — the underlying `ItemStackRequestActionType`
- `source` — source slot info from the request
- `destination` — destination slot info from the request

**Methods:**

- `proceed() -> MenuTransactionResult` — allow the transaction to proceed
- `discard() -> MenuTransactionResult` — discard transaction

## Usage

```python
from endstone import Player
from endstone.inventory import ItemStack
from endstone_inventoryui import Menu, MenuType, MenuTransaction, MenuTransactionResult

menu = Menu(MenuType.CHEST)

menu.inventory.set_item(0, ItemStack("minecraft:diamond", 1))
menu.inventory.set_item(1, ItemStack("minecraft:emerald", 1))


def on_click(tr: MenuTransaction) -> MenuTransactionResult:
    if tr.slot == 0:
        tr.player.send_message("You clicked the diamond!")
        return tr.discard()
    elif tr.slot == 1:
        tr.player.send_message("You clicked the emerald!")
        return tr.discard()

    return tr.proceed()


menu.set_listener(on_click)
menu.send_to(player)
```

See the [example plugin](./example) for a full project.
