Skip to content

Improve Menu Type example #800

Open
Open

Description

@TurboJax

The example contains a Map<Player,InventoryView>, and even has a comment (shown below) explaining that using Player objects as keys and values is bad design, so could it just be changed to use player ids?

// A map to store all inventory views in. Generally it is not recommended
// to use Player objects as keys or values, but in this case it is acceptable
// because the inventory view is also bound to a player object, meaning we
// couldn't reuse it after a player rejoins anyways.

Also, could there be an example for listening to an InventoryClickEvent? It's not that necessary, since the same sort of logic is displayed in the PlayerQuitEvent handler. If it were to be added, it could prevent you from putting shulker boxes in your stash.

Activity

  1. TurboJax commented on Sep 21, 2026

    @TurboJax
    Author

    Just realized a better reason for the InventoryClickEvent demo is to show how you can check if a clicked view is a custom view. There's obviously title comparison, but other than that you'd need to maintain a list of all the players who have the menu open.
    This should be able to be done by adding a UUID to a set when they view is opened then removing it with an InventoryCloseEvent listener.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions