Files
betterMcGuis/docs/05_PAGINATED_AND_ADVANCED_GUIS.md

90 lines
3.2 KiB
Markdown

# 📚 Menus Paginés, Onglets & Animations - betterMcGuis
Ce guide explore les types d'inventaires avancés : **PaginatedGui**, **TabbedGui** et **AnimatedGui**.
---
## 📑 Sommaire
- [1. Menus Paginés (`PaginatedGui`)](#1-menus-paginés-paginatedgui)
- [2. Menus à Onglets (`TabbedGui`)](#2-menus-à-onglets-tabbedgui)
- [3. Menus Animés (`AnimatedGui`)](#3-menus-animés-animatedgui)
---
## 1. Menus Paginés (`PaginatedGui`)
Le `PaginatedGui` prend en charge le calcul automatique des pages, la disposition des boutons de navigation et les indicateurs dynamiques.
```java
var shop = BetterMcGuis.paginated("Boutique", 5)
.fillBorder(Material.BLACK_STAINED_GLASS_PANE)
// Personnalisation des boutons de navigation
.previousButton(38, ItemBuilder.of(Material.ARROW).name("<yellow>◀ Page Précédente</yellow>").asGuiItem())
.nextButton(42, ItemBuilder.of(Material.ARROW).name("<yellow>Page Suivante ▶</yellow>").asGuiItem())
// Indicateur de page personnalisée
.pageIndicator(40, (page, total) -> ItemBuilder.of(Material.PAPER)
.name("<gold><bold>Page " + page + " / " + total + "</bold></gold>")
.asGuiItem()
);
// Ajout de 100 items au catalogue
for (int i = 1; i <= 100; i++) {
shop.addPageItem(ItemBuilder.of(Material.GOLD_INGOT)
.name("<yellow>Lingot #" + i + "</yellow>")
.asGuiItem(ctx -> ctx.replySuccess("Achat réussi !"))
);
}
shop.build().open(player);
```
---
## 2. Menus à Onglets (`TabbedGui`)
Permet de basculer instantanément entre plusieurs catégories d'items **sans fermer ni rouvrir l'inventaire** :
```java
BetterMcGuis.tabbed("Menu Multi-Catégories", 4)
// Onglet 1 : Guerrier
.tab("warrior", 11, ItemBuilder.of(Material.IRON_SWORD).name("<red>Guerrier</red>").asGuiItem(), tabGui -> {
tabGui.setTabItem("warrior", 20, ItemBuilder.of(Material.DIAMOND_SWORD).name("<red>Épée Lourde</red>").asGuiItem());
tabGui.setTabItem("warrior", 24, ItemBuilder.of(Material.SHIELD).name("<gray>Bouclier</gray>").asGuiItem());
})
// Onglet 2 : Archer
.tab("archer", 15, ItemBuilder.of(Material.BOW).name("<green>Archer</green>").asGuiItem(), tabGui -> {
tabGui.setTabItem("archer", 22, ItemBuilder.of(Material.CROSSBOW).name("<green>Arbalète Précise</green>").asGuiItem());
})
.build()
.open(player);
```
---
## 3. Menus Animés (`AnimatedGui`)
Permet d'animer des frames d'inventaires cadencées par tick ou secondes :
```java
AnimatedGui animated = BetterMcGuis.animated()
.title("<gold>Ouverture de Coffre Mystère...</gold>")
.rows(3)
// Frame 1
.frame(f -> f.item(13, ItemBuilder.of(Material.CHEST).name("<yellow>Chargement.</yellow>").asGuiItem()))
// Frame 2
.frame(f -> f.item(13, ItemBuilder.of(Material.ENDER_CHEST).name("<gold>Chargement..</gold>").asGuiItem()))
// Frame 3 : Révélation du lot !
.frame(f -> f.item(13, ItemBuilder.of(Material.NETHER_STAR).name("<gradient:#00f2fe:#4facfe>Bravo ! Trésor Obtenu !</gradient>").asGuiItem()))
.loop(false)
.build();
animated.open(player);
animated.startAnimation(monPlugin, Duration.ofMillis(600));
```
---
> 📖 **Étape suivante** : Découvrez le cycle de vie et les événements dans [06_LIFECYCLE_AND_EVENTS.md](06_LIFECYCLE_AND_EVENTS.md).