Interface MenuBackgroundResolver

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface MenuBackgroundResolver
Lets an add-on choose a menu's texture itself, instead of the rules in guis.yml.

A resolver is asked every time a menu it covers opens or redraws, after the guis.yml rules have decided, and is shown what they decided. It can keep that, replace it with glyphs of its own, or remove the texture. Resolvers for one menu are asked before resolvers for every menu, each group in the order registered, and the first one that does not keep the result decides.

A menu covered by a resolver is decided even when guis.yml gives it no background, so an add-on can texture any menu on its own. Resolvers are not asked while the server owner has turned backgrounds off with backgrounds.enabled: false. A resolver that throws, or returns glyph names guis.yml does not define, keeps the rules' result and is reported in the console once.

Since:
1.15.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Registers a resolver for every menu instead of a single one.
  • Method Summary

    Modifier and Type
    Method
    Description
    choose(@NotNull MenuConditionContext context, @NotNull MenuBackgroundResult configured)
    Chooses the texture for one viewer's menu.
  • Field Details

    • ALL_MENUS

      static final String ALL_MENUS
      Registers a resolver for every menu instead of a single one.
      See Also:
  • Method Details

    • choose

      @NotNull @NotNull MenuBackgroundChoice choose(@NotNull @NotNull MenuConditionContext context, @NotNull @NotNull MenuBackgroundResult configured)
      Chooses the texture for one viewer's menu. Runs on the main thread.
      Parameters:
      context - the viewer, their menu and the moment
      configured - what the guis.yml rules, or an earlier resolver that kept them, decided; without rules for the menu it has no texture
      Returns:
      the choice; MenuBackgroundChoice.keep() to leave the decision to others