Installation English
Gustavo Arantes edited this page Aug 22, 2020
·
4 revisions
Please use the release jar or clone the repository and install it at your local maven repository.
<!-- This adds the Arantes Maven repository to the build -->
<repositories>
<repository>
<id>arantes-repo</id>
<url>https://mvn.arantes.dev/repository/maven-releases/</url>
</repository>
</repositories>
<dependencies>
<!-- This adds the InventoryMenuLib artifact to the build -->
<dependency>
<groupId>dev.arantes</groupId>
<artifactId>InventoryMenuLib</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
Download a jar release here. After you have the jar just put as a dependency in your project.
You can compiled it together with your plugin or put the jar file inside your plugins folder.
First, you have to register the listener like so:
public void onEnable() {
// ...
new InventoryListener(this);
// ...
}
The shape system:
- '#' = Content
- '<' = Previous page
- '>' = Next page
- 'x' (or any other char) = Border
The last row should be ignored during the shape process, making the shape having a maximum of 5 rows.
// Create the menu with the name and the shape.
// {page} is replaced by the page number
PaginatedGUI gui = new PaginatedGUIBuilder(
"§8Menu | page: {page}",
"xxxxxxxxx" +
"x#######x" +
"<#######>" +
"x#######x" +
"xxxxxxxxx"
)
// Define the material of the border and the name.
// You can also define actions if you want the border to be clickable
.setBorder(new ItemButton(Material.STAINED_GLASS_PANE, 1, "§eBorder", ""))
// Set an item in the 4 position of the hotbar (lastrow)
.setHotbarButton(
(byte) 4,
new ItemButton(Material.COMPASS, 1, "§cClose")
.addAction(ClickType.LEFT, (InventoryClickEvent e) ->
e.getWhoClicked().closeInventory())
)
// Set the item for the next page button.
.setNextPageItem(Material.ARROW, 1, "§6Next page")
// Set the item for the previous page buttom.
.setPreviousPageItem(Material.ARROW, 1, "§6Previous page")
// Set the content
.setContent(
new ItemButton(Material.DIAMOND, 1, "Item"),
new ItemButton(Material.DIAMOND, 1, "Item"),
new ItemButton(Material.DIAMOND, 1, "Item"),
new ItemButton(Material.DIAMOND, 1, "Item")
)
// Build and return the PaginatedGUI
.build();
// Show the first page to a Player.
gui.show(player);
// First we created the inventory passing the Title and the size (3 * 9 -> 3 row inventory).
final InventoryGUI gui = new InventoryGUI("Inventory Title", 3 * 9);
// Create a button
final ItemButton btn = new ItemButton(previousPageItem);
// Add action for a specific Click Type
btn.addAction(ClickType.RIGHT, (InventoryClickEvent e) -> {
e.getWhoClicked().sendMessage("You RIGHT clicked the item!");
});
// Set the default action
// The default action will be triggered if you don't have a click type registered
// for the user action.
// In this example, we registered the RIGHT CLICK above, so if the user
// use any click other than the RIGHT one the default action will be triggered.
btn.setDefaultAction((InventoryClickEvent e) -> {
e.getWhoClicked().sendMessage("You CLICKED the item.");
});
// Set the button in the inventory slot 5.
gui.setButton(5, btn);
// Show the inventory to the player
gui.show(player);
Copyright (c) Gustavo Arantes