v2.0.0 - TEN N' TUT!
After so much hype (I was hyping up about 3 members and me), It has finally arrived, and the amount of work I put into this version will not disappoint you.
This wasn't supposed to take 3 months, but I've been distro-hopping and losing my work without backing it up.
Features: 1. Additions, 2. Performance, 3. Flexibility, 4. Extensibility, 5. Bug Fixes.
Just to go over a simple fixes beforehand, I've fixed:
- Slot.FIRST and Slot.getFirst() returning the SECOND slot ever since release ;-;
- Menu#getFiller will not cast to Filler.class, instead it will directly return the filler.
- removed unnecessary "updating" field modifications that would also poorly be handled and disallow openAction and closeAction to execute.
- some others I forgor they're too small
Deprecations
- Slot#isSlot is now deprecated due to confusion (I was the only one confused :D), use Slot#isValid instead.
- PaginatedMenu#setNextPageItem and PaginatedMenu#setPreviousPageItem are now deprecated,
Use PaginatedMenu#setPageItem, or even better, use Menu.builder#nextPageItem and Menu.builder#previousPageItem
Improvements (Generic)
- Menus now removed; plugin initialization is 100% automatic now.
Improvements (Performance)
-
Updated from Java 8 to Java 11.
This is a really good update not just for me, but for others too!
It improves internal performance, JVM performance, allows for more stabilization, and will make me and you write less code in the long run!When writing states I wrote my own replace method because Java 8 and under uses Regex to replace strings, which isn't a good idea.
Java 9 and above optimizes such methods in String, and adds nice API to Stream and the collections API overall that improves memory consumption! -
Woody now compiled differently.
Applying the error_prone compilation to the compiler arguments in the project, now woody can compile more efficient runtime code, and detect errors better, and integrate error_prone and lombok annotations better.Also now that Slot.FIRST and Slot.NaS are now compile time constants
-
MenuIterator now has slightly optimized iteration.
-
Added Menu#allModifiersAdded to optimize performance slightly if all modifiers are actually in the Enum set by checking the size instead of checking #contains
-
fillRow now only affects the slots it needs to affect.
on a related improvement, fillArea will now use bitwise to get the first area slot, improving performance, not because bitwise is used, but because we can now have the first slot and avoid unnecessary looping -
LegacyNbt is rewritten; using a guava Table (or a safer wrapper for Map<R, Map<C, V>>
instead of reflection, to optimize performance. -
Improve performance for Menu#addItem by avoiding recursion as much as possible (by directing the size checking in another method)
-
List Modifier.ALL was replaced to EnumSet Modifier.ALL to avoid copying of the List and improve boilerplate handling
Internal Reductions & breaking changes
-
Removed Page, PageIterator.
Pagination wasn't rewritten as much as 1.4.0 since it's similar, but PaginatedMenu and Menu now internally work off a new class called ItemData, to improve following the DRY principle (saving my time) and to lower the amount of lines! -
PaginatedBuilder and NormalBuilder was removed in favor of MenuBuilder which is both of those combined.
-
getRows() and getSize() replaced with rows() and size()
-
MenuException removed
-
BaseMenu removed in favor of Menu.
-
Decorator was now removed, now PageDecoration implements MenuFiller instead of Decorator, allowing for extra flexibility with Filler and PageDecoration
Additions
-
New Stating API
New States that would automatically change values of in the lore, for example:MenuItem item = ...; item.addState(State.of("%players-size%", () -> Bukkit.getOnlinePlayers().size(), item)); item.addState(State.of("%cool-player%", () -> "FlameyosFlow", item)); // to automatically update every item with a state on menus menu.setUpdateStatesOnUpdate(true);
Includes a supplier of IntSupplier, DoubleSupplier, LongSupplier and just a Supplier which is normal.
Would definitely save the hassle of you getting your hands dirty and ugly looking. 😜 -
Reworked Animating API and stabilized it.
Now animations made manual animating automatic, better, more flexible, faster, and (unfortunately) more verbose.Important Note: DO NOT SET IT TO A LOW DELAY! These animations are done synchronously (for now) and can block your server from running (It was tested at delay of 0, a.k.a no delay)
A good usage of these new animations:
Menu menu = ...; Animation animation = Animation.builder() .frames( Frame.builder() .setItem(0, ItemBuilder.of(Material.STONE).buildItem(); .addItem( ItemBuilder.of(Material.IRON_SWORD).buildItem(), // others ) // other items .build(), // other frames ) .type(Animation.Type.NORMAL) .delay(10) // 500ms .build(); menu.addAnimation(animation); // you can have as much animations as you want
-
New Adventure API
This API is very similar to IF's adventure support, where you use holders that allow compatibility for Legacy component handling or native component handling, or using StringHolders, it allows for extra flexibility and also being able to use ComponentsSome servers use your plugin on a version under 1.16.5 and/or not on paper? no problem!
The adventure implementation internally will switch to a legacy component handler on older versions.
so you can use adventure on under 1.16.5 anyways!Good usage of this:
Menu menu = Menu.builder() .title(CompHolder.of(Component.text("UO").color(TextColor.color(255, 192, 11))) // uses RGB .rows(6) .normal(); menu.updateTitle(CompHolder.of(Component.text("AC").color(TextColor.color(255, 192, 11))) // MenuItems MenuItem item = ItemBuilder.of(Material.STONE) .title(CompHolder.of(Component.text("A Cool Stone").color(TextColor.color(255, 192, 11))) .buildItem() // so on in MenuData, etc.
-
MenuItem additions:
Apart from the States, now MenuItem clicking can have an optional cooldown (map with lazy initialization to have just about no memory impact if not used)
Here's how it can be initialized:MenuItem item = ...; item.addCooldown(player, 1000); // 1 second cooldown.
That's it for cooldowns,
also now SkullItemEditor is a thing, simple, it edits skulls, that's it.
-
New menu Actions:
Normal & paginated:
BeforeAnimatingEvent, menu.setOnAnimate, called right before the animations start, and if cancelled then the animations will not start on the open of the menu and it moves from 0 viewers.Paginated:
PageChangedEvent, menu.setOnPageChange, called after a page is changed, much more options, and cancellable, and if cancelled then the page will switch to the next page if it was switched to the previous, or it will switch to the previous page if it was switched to the next -
New Filler methods.
fillSide methods with incredibly smart indexing to optimize performance rather than performing mathematical operations or (much worse) looping through the entire menu -
Menu Slot Actions
Now slot actions exist, and they are externally very similar to triumph-gui so I don't need to go much in detail.
Smaller additions
- Slot#equals is now implemented including Slot#equals(int slot)
This took weeks of programming and algorithm research and more, there's just so much more optimizations, improvements and more, so enjoy!