menuManager

Methods
4
Fields
None

Getting one

menuManager

Methods

MethodReturnsDescription
addPlayerMenuItem(string)()menuText takes the first free of the client's player-option slots 5 to 8 (none free, nothing happens), low priority, so every player's me…
removePlayerMenuItem(string)()Take the first player menu item of that text (any case) back out of the menu (its slot emptied); a text no plugin added does nothing. Shown…
addManagedCustomMenu(WidgetMenuOption, ((MenuEntry) -> ())?)()Manage customMenuOption on each of its widgets. From now on every right-click menu with a CC_OP entry of one of them (no widget selecte…
removeManagedCustomMenu(WidgetMenuOption)()Stop managing customMenuOption (menus built from now on leave it out).

Method details

addPlayerMenuItem

addPlayerMenuItem: (MenuManager, string) -> ()

menuText takes the first free of the client's player-option slots 5 to 8 (none free, nothing happens), low priority, so every player's menu shows it as an entry of type CLIENT_PLAYER (identifier the player's index, deprioritized, announced by MenuEntryAdded like the game's own player options): a click on it posts MenuOptionClicked and sends nothing to the server, and interactPlayer never clicks it as a game option. When the game's SET_PLAYER_OP takes its slot, it moves to the next free one. After a client reset (a world hop, a logout) the item is written back on the next client cycle. The text is kept as the client keeps it: NUL characters removed, at most 256 bytes; an empty text adds nothing (the client shows no option for an empty slot). Called before the client's first cycle (a startUp), it is written at that cycle.

Only a client whose menu Bento hooks can be written: on another nothing is shown, and the first call from each plugin logs a warning saying so. There, show the item from onMenuEntryAdded(event): for a player option entry (event:getType() from MenuAction.PLAYER_FIRST_OPTION:getId() to PLAYER_EIGHTH_OPTION:getId()), once per player, client:getMenu():createMenuEntry(-1):setOption(menuText) :setTarget(event:getTarget()):setType(MenuAction.CLIENT_PLAYER) :setIdentifier(event:getIdentifier()):setDeprioritized(true), then onClick(fn).

removePlayerMenuItem

removePlayerMenuItem: (MenuManager, string) -> ()

Take the first player menu item of that text (any case) back out of the menu (its slot emptied); a text no plugin added does nothing. Shown nowhere on a client whose menu Bento does not hook, as addPlayerMenuItem is not.

addManagedCustomMenu

addManagedCustomMenu: (MenuManager, WidgetMenuOption, ((MenuEntry) -> ())?) -> ()

Manage customMenuOption on each of its widgets. From now on every right-click menu with a CC_OP entry of one of them (no widget selected) also shows the option: an entry of type CLIENT, param1 the widget, added once per menu after every MenuEntryAdded subscriber above priority 0 and before every one at 0, the oldest option on top. Clicking it runs callback(entry) after every MenuOptionClicked subscriber, and sends nothing to the server. Adding an option again replaces its callback and keeps its place. A plugin that stops takes its options out. Shown only on a client whose menu Bento hooks.