inventory-framework
inventory-framework copied to clipboard
Inline Views
Introduce a "contextless"-like inlined View type to create views that'll be used only for simple interactions like a confirmation menu. The difference between a menu with context and one without context is that many things will no longer be handled, reducing the overhead of the View, making it much faster and simpler.
Design proposals
private void confirm(Player player);
private void cancel(Player player);
// ...
View confirmationView = View.create("Confirmation", 3, view -> {
view.slot(1, item).onClick(ctx -> confirm(ctx.getPlayer()));
view.slot(2, item).onClick(ctx -> cancel(ctx.getPlayer()));
});
confirmationView.open(player);
Or
private void confirm(Player player);
private void cancel(Player player);
// ...
ViewItem confirmItem = item(...).onClick(ctx -> confirm(ctx.getPlayer());
ViewItem cancelItem = item(...).onClick(ctx -> cancel(ctx.getPlayer());
createView("Confirmation", 3)
.with(slot(1, confirmItem))
.with(slot(2, cancelItem))
.build()
.open(player);
This View must use a definitely smaller amount of memory, it must probably be limited in terms of functionality and must be discarded if the player closes it.