Releases: Noxcrew/interfaces-kotlin
v2.0.1
What's Changed
- Increased default coroutine timeout to 5 seconds
- Lazy/state properties now require passing a nullable view object which is closed if an error occurs while updating
- Added a helper method for creating a paginated transform that only updates when its contents are changed
- Added a new refresh mode that only updates when a menu is opened with
reload = true
- Added openOrThrow to
BaseInventoryMenu
with extra debugging on what caused a menu opening to fail - Fixed lazy/state properties not re-running evaluation if a previous attempt timed out
- Fixed views re-opening when already open on world switch
- Fixed closing a view not cleaning up pending operations causing menus to be softlocked into thinking a rendering job was already running when it was not
Full Changelog: v2.0.0...v2.0.1
v2.0.0
What's Changed
Interfaces 2.0.0 features a rewrite of the rendering logic to allow menus to be cached, re-used, or use lazy elements which allow you to improve the responsiveness of menus by re-using previous work. Furthermore, a new exception handling system has been introduced which catches any exceptions that occur during rendering and gives better methods for gracefully handling exceptions and providing errors to users.
The library has had a major version bump as the new features require you to rework your menus to use the new features properly. Any old menus should still function the same way, but we recommend trying out the new caching features.
New Library Features
Transforms now have various additional properties that you can use to customise how they should be rendered:
- Transforms can define a BlockingMode, this decides whether the transform needs to be rendered before the menu can be opened or not.
- Transforms can define a RefreshMode. If requested, transforms are not re-rendered when re-opening a menu and are only re-rendered when their triggers are triggered.
- Stateful Transforms can now be added which cache themselves based on the different values of a core property. This is primarily used for pagination where each page is cached as long as only the page property changes. In this type of menu you are now required to introduce a custom second property if you want the transform itself to be redrawn. Triggering the page transform does not trigger a redraw.
Furthermore, elements within a transform can now separately lazily draw by implementing LazyElement
. Any lazy element has a separate decoration pass which starts after the menu is already drawn. Decoration passes can be used for e.g. friends lists where you have to fetch a lot of data on each individual element and you do not want this to block rendering the menu.
Caching
Interfaces can now be cached. You can now cache interfaces you open and safely re-open them later instead of rebuilding the object. This means you should not design your menus to rely on views being reconstructed and instead you should introduce properties that trigger refreshes. For legacy support, all menus have no caching by default. Call useCachingDefaults
when configuring your menu to turn on caching mode which will only re-render transforms whose properties change.
Interfaces now have multiple steps they go through when rendering:
- Rendering starts with triggering updates on any triggers that implement
LazyProperty
orStateProperty
. By default, newly opened root menus (no parent or only a player interface as parent) will re-evaluate a property whereas all other menus only reload them if the properties are not yet loaded. As an example, imagine a menu showing your quests, you can store the available quests in a lazy property. When the menu is opened from the hotbar it can re-use the cached InterfaceView but first re-evaluates the available quest property. Then, after returning from a submenu the quests are not reloaded again. - After properties have been re-evaluated all blocking transforms are drawn, then the menu is opened. Non-blocking transforms are drawn afterwards and the menu is updated after each transform is drawn.
- Finally lazy elements are decorated one-by-one, again with the menu updating in between.
Some common bebefits of this caching include:
- Preventing entire menus from being reloaded/redrawn after returning from a sub-menu, like inspecting a certain item
- Avoiding slow lazily loaded menus from redoing work while clicking between pages
Generally, the intent of caching is to reduce workload when users are jumping back and forth between menus, while still refreshing properly when menus are entirely closed and re-opened. Lazily loading menus also helps offer a better experience when menus are backed by many network calls which can cause delays. Using improved exception handling every rendering action is given a proper timeout and can be nicely handled instead of causing unexpected results as it did in past versions.
Exception Handling
Menus now need to be provided with an implementation of InterfacesExceptionHandler
, of which the library contains a standard implementation. This handler can decide how to handle all different types of exceptions that can occur while rendering. It can select whether to ignore an exception, retry the operation, or close the menu in response. All exceptions are also properly logged and various previously silent exceptions are now properly caught and logged.
Other Changes
- chore: Expose TitleState by @LichtHund in #17
- chore: Rework pane mapping by @LichtHund in #18
- Fix IncompatibleClassChangeError with allowClickingOwnInventoryIfClickingEmptySlotsIsPrevented by @nentify in #16
- There is now a small system to profile rendering of menus, enable
debugRenderingTime
when configuring a menu and debug logs will be printed which indicate how long each rendering step takes for your menu.
New Contributors
Full Changelog: v1.3.2...v2.0.0
v1.3.2
This is a re-release of the existing 1.3.2 version that was not properly published to Maven.
What's Changed
- Updated to 1.21.1
- feature: Add ClickContext#interact to allow determining if the click is from an interact event by @kezz in #9
- feature: More grid position generator API by @kezz in #10
- feature: Better coroutine exception handling by @kezz in #12
- chore: Use launch over async to prevent error supression by @LichtHund in #13
- Paper-API is now marked as a non-required dependency which should allow developers to swap it out for their own versions more easily
- Added a function to re-open the last opened background interface
- Changed InterfaceView#close to be non-suspending so it can be safely used in non-suspending situations that want to close a previously suspendingly opened interface
- Reduced how often a player interface is drawn when opened
- The coroutine scope used by interfaces is now available to other plugins
- Chat queries can now indicate whether the menu should be re-opened
- Edited the default reopen reasons, causing background interfaces to be re-opened in more cases
- Fixed an issue where re-opening an interface counted as closing the menu and not as switching views
- Fixed an issue with property updates causing multiple re-renders in certain cases
- Fixed safety issues with mutex usage causing multiple renders
- Fixed issue where closed views could get reopened
- Fixed issue where rendering continued after the coroutine that opened the menu was cancelled
- Fixed isTreeOpened not being recursive causing menus to be marked as non-reopenable even if a descendant sub-menu was still open
Full Changelog: v1.2.0...v1.3.2
v1.2.0
What's Changed
- Updated to Minecraft 1.20.6
- Properly support using interfaces in paper plugins by @FllipEis in #7
- Interfaces are no longer drawn if the viewing player has disconnected
- Changed callCloseHandlerOnViewSwitch to default to false to match behavior before v1.1.10
- Chat queries are now suspending with their contents running before the old view is re-opened
- Implemented logic to deal with shift clicking and double clicking in allowed slots to prevent these actions editing GUI items
- Add new builder options onlyCancelItemInteraction and prioritiseBlockInteractions which give more control over the handling of players right clicking in player inventories
- Fixed transforms being entirely broken in v1.1.10
- Fixed chat queries getting instantly cancelled (closes #8)
- Fixed InterfaceView#close having incorrect default parameters causing issues with re-opening menus
- Fixed many issues around preventClickingEmptySlots = false and how this allowed unintended modifications to be made
New Contributors
Full Changelog: v1.1.10...v1.2.0
v1.1.10
<dependency>
<groupId>com.noxcrew.interfaces</groupId>
<artifactId>interfaces</artifactId>
<version>1.1.10</version>
</dependency>
What's Changed
- New structure for InterfacesProperties which adds various extra configuration options to interfaces
- Menu close handlers are now always called, even when opening a different menu
- Added option to persist items placed into an interface when opening another
- Added support for allow certain items in an interface to be moved
- Added support to prevent moving unmovable items through number keys & swapping off-hand
- Added support to prevent moving unmovable items by drag clicking
- You can no longer drop items from an interface
- Items from an interface are no longer dropped on death
- An open player interface is re-opened after respawning
- Added additional details to the DrawPaneEvent
- Updated implementation of DelegateTrigger to address GC issues
- Updated to Kotlin 1.9.22
Full Changelog: v1.0.1...v1.1.10
v1.0.1
<dependency>
<groupId>com.noxcrew.interfaces</groupId>
<artifactId>interfaces</artifactId>
<version>1.0.1</version>
</dependency>
What's Changed
- Add missing configuration to publish sources by @LichtHund in #1
Full Changelog: v1.0.0...v1.0.1
v1.0.0
First release.
<dependency>
<groupId>com.noxcrew.interfaces</groupId>
<artifactId>interfaces</artifactId>
<version>1.0.0</version>
</dependency>
Full Changelog: https://github.com/Noxcrew/interfaces-kotlin/commits/v1.0.0