-
Notifications
You must be signed in to change notification settings - Fork 2
Why?
On average, Woody (theoretically triumph-gui fork) is 2.31x faster than triumph-gui on average (when setting up a menu, such as adding, etc etc)
Without benchmarks, I'm basically typing BS.
With THESE benchmarks, you'll believe me (Calculated with System.nanoTime()
)
The following benchmarks was calculated on:
- AMD Athlon X2 64 Dual Core 3800+ Processor
- 3GB DDR2 677MHz Ram (or exactly 2.8gb ram)
(If you aren't a computer nerd, what that means is that if you have any newer CPU than 2005 or have 800MHz+ ram, it'll only get faster than these benchmarks, if you somehow have worse specs, you probably can't even run minecraft 🙏)
Those are just 2 benchmarks of some of my best benchmarks executing: Woody:
Menu exampleMenu = new Menu(3, "Example Menu");
exampleMenu.getFiller().fillBorders(new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7));
exampleMenu.setCloseAction((event, result) -> event.getPlayer().sendMessage("You closed the menu!")); // notice result
exampleMenu.addAllModifiers();
MenuItem item = ItemBuilder.of(Material.IRON_SWORD).buildItem(event -> {
event.getWhoClicked().sendMessage("You clicked the iron sword!");
});
MenuItem itemTwo = ItemBuilder.of(Material.DIAMOND_SWORD).buildItem(event -> {
event.getWhoClicked().sendMessage("You clicked the diamond sword!");
});
exampleMenu.addItem(item, itemTwo);
exampleMenu.get(10)
.filter(itemOne -> itemOne.getType() == Material.IRON_SWORD)
.map(MenuItem::getUniqueId)
.ifPresent(uuid -> Bukkit.getLogger().info(uuid.toString()));
return exampleMenu;
triumph-gui:
Gui gui = new Gui(3, "Example Menu", EnumSet.noneOf(InteractionModifier.class));
gui.getFiller().fillBorder(ItemBuilder.from(new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7)).asGuiItem());
gui.setCloseGuiAction(event -> event.getPlayer().sendMessage("You closed the menu!"));
gui.disableAllInteractions();
GuiItem item = ItemBuilder.from(Material.IRON_SWORD).asGuiItem(event -> {
event.getWhoClicked().sendMessage("You clicked the iron sword!");
});
GuiItem itemTwo = ItemBuilder.from(Material.DIAMOND_SWORD).asGuiItem(event -> {
event.getWhoClicked().sendMessage("You clicked the diamond sword!");
});
gui.addItem(item, itemTwo);
// no access to UUID except reflection
Optional.ofNullable(gui.getGuiItem(10))
.filter(itemOne -> itemOne.getItemStack().getType() == Material.IRON_SWORD)
.ifPresent(itemOne -> Bukkit.getLogger().info(itemOne.getItemStack().toString()));
return gui;
Notice that they're very similar syntax-wise except for a few method names
MenuItem ease-of-editing:
MenuItem item = ...;
item = item.editor().emptyLore().setName("&aCool Right?").done();
MenuLayoutBuilder menu building: (Experimental)
Map<Character, MenuItem> charAsItem = ImmutableMaps.of(
'X', ItemBuilder.of(Material.STONE).buildItem()
);
Menu menu = MenuLayoutBuilder.bind(charAsItem)
.row("XXXXXXXXX")
.row("X X")
.row("X X")
.row("X X")
.row("XXXXXXXXX")