Interface GuiLayoutService
Menu backgrounds
Since 1.15.0 this service also reaches the resource-pack textures that the background
blocks of guis.yml give menus. Zentrix decides a menu's texture after the menu has
placed its buttons and before it opens, and again whenever the menu redraws, from what it shows.
Add-ons can read what an open menu shows (getOpenMenu(org.bukkit.entity.Player)), give server owners conditions
and values to write in those rules (registerBackgroundCondition(org.bukkit.plugin.Plugin, java.lang.String, dev.itsharshxd.zentrix.api.gui.background.MenuBackgroundCondition),
registerBackgroundValue(org.bukkit.plugin.Plugin, java.lang.String, dev.itsharshxd.zentrix.api.gui.background.MenuBackgroundValue)), choose a texture themselves
(registerBackgroundResolver(org.bukkit.plugin.Plugin, java.lang.String, dev.itsharshxd.zentrix.api.gui.background.MenuBackgroundResolver)), and have an open menu decided again when something their
conditions depend on changes (refreshBackground(org.bukkit.entity.Player)).
Background methods must be called on the main thread. Registrations end on their own when the registering plugin is disabled.
- Since:
- 1.6.0
-
Method Summary
Modifier and TypeMethodDescriptiongetOpenMenu(@NotNull org.bukkit.entity.Player player) What the Zentrix menu a player has open shows, and the texture it was given.booleanbooleanisRegistered(@NotNull String guiId) default booleanrefreshBackground(@NotNull org.bukkit.entity.Player player) Decides the texture of the menu a player has open again, now, and updates its title when it changed.booleanregister(@NotNull GuiLayoutDefinition definition) default @NotNull RegistrationregisterBackgroundCondition(@NotNull org.bukkit.plugin.Plugin owner, @NotNull String name, @NotNull MenuBackgroundCondition condition) Adds a condition server owners can write in thewhenof background rules, asnamespace:name.default @NotNull RegistrationregisterBackgroundResolver(@NotNull org.bukkit.plugin.Plugin owner, @NotNull String menuId, @NotNull MenuBackgroundResolver resolver) Lets an add-on choose the texture of one menu, or of every menu, itself.default @NotNull RegistrationregisterBackgroundValue(@NotNull org.bukkit.plugin.Plugin owner, @NotNull String name, @NotNull MenuBackgroundValue value) Adds a value server owners can compare in thewhenof background rules, asnamespace:name.voidreload()@NotNull GuiLayout@NotNull GuiLayoutbooleanunregister(@NotNull String guiId)
-
Method Details
-
getRegisteredIds
-
isRegistered
-
isBuiltIn
-
register
-
unregister
-
resolve
-
resolve
-
reload
void reload() -
getOpenMenu
@NotNull default @NotNull Optional<MenuView> getOpenMenu(@NotNull @NotNull org.bukkit.entity.Player player) What the Zentrix menu a player has open shows, and the texture it was given.- Parameters:
player- the viewer- Returns:
- the menu, or empty when the player has no Zentrix menu open, or one that placed
nothing through a
guis.ymllayout - Throws:
IllegalStateException- when called off the main thread- Since:
- 1.15.0
-
refreshBackground
default boolean refreshBackground(@NotNull @NotNull org.bukkit.entity.Player player) Decides the texture of the menu a player has open again, now, and updates its title when it changed. Menus are decided when they open and redraw; call this when something an add-on condition, value or resolver depends on changes while the menu stays open.- Parameters:
player- the viewer- Returns:
- whether the player had a menu with a background to decide
- Throws:
IllegalStateException- when called off the main thread- Since:
- 1.15.0
-
registerBackgroundCondition
@NotNull default @NotNull Registration registerBackgroundCondition(@NotNull @NotNull org.bukkit.plugin.Plugin owner, @NotNull @NotNull String name, @NotNull @NotNull MenuBackgroundCondition condition) Adds a condition server owners can write in thewhenof background rules, asnamespace:name.guis.ymlis read again when the registration starts or ends, so rules that use the condition work as soon as it is registered and are reported as unknown once it is gone. Conditions registered while the server starts are in place before any rule is checked.- Parameters:
owner- the registering plugin, whose namespace the name is written undername- the name within the plugin, usinga-z,0-9,_and-condition- the condition- Returns:
- the registration, to remove the condition early
- Throws:
IllegalArgumentException- when the name is invalid, or the plugin already registered a condition or value under it- Since:
- 1.15.0
-
registerBackgroundValue
@NotNull default @NotNull Registration registerBackgroundValue(@NotNull @NotNull org.bukkit.plugin.Plugin owner, @NotNull @NotNull String name, @NotNull @NotNull MenuBackgroundValue value) Adds a value server owners can compare in thewhenof background rules, asnamespace:name. Conditions and values share one set of names per plugin.- Parameters:
owner- the registering plugin, whose namespace the name is written undername- the name within the plugin, usinga-z,0-9,_and-value- the value- Returns:
- the registration, to remove the value early
- Throws:
IllegalArgumentException- when the name is invalid, or the plugin already registered a condition or value under it- Since:
- 1.15.0
- See Also:
-
registerBackgroundResolver
@NotNull default @NotNull Registration registerBackgroundResolver(@NotNull @NotNull org.bukkit.plugin.Plugin owner, @NotNull @NotNull String menuId, @NotNull @NotNull MenuBackgroundResolver resolver) Lets an add-on choose the texture of one menu, or of every menu, itself. SeeMenuBackgroundResolverfor the order resolvers are asked in.Menus that are open keep their title until they redraw or are
refreshed. In the Free edition, which keepsguis.ymlat its defaults, the registration is refused and returned inactive.- Parameters:
owner- the registering pluginmenuId- the menu's ID inguis.yml, orMenuBackgroundResolver.ALL_MENUSresolver- the resolver- Returns:
- the registration, to remove the resolver early
- Since:
- 1.15.0
-