Create Bukkit GUIs super easily!
All you need to do is copy the files into your plugin. You do not need to copy Consumer.java
if you are sure that the plugin will only be run on Java 8
GUIWindow gui = new GUIWindow(title, rows);
GUIItem guiItem = new GUIItem(itemToShow, whenClicked);
gui.setItem(x, y, guiItem);
The parameters for the constructors are
String title
- The title of your GUI windowint rows
- How many rows the GUI will have
ItemStack itemToShow
- The item that a GUIItem will display as in the GUIWindowConsumer<InventoryClickEvent> whenClicked
- What action to perform when clicked
ItemStack redstone = new ItemStack(Material.REDSTONE);
GUIWindow gui = new GUIWindow("Get some redstone!", 3);
GUIItem guiItem = new GUIItem(redstone, new Consumer<>() {
@Override
public void accept (InventoryClickEvent event){
event.getWhoClicked().getInventory().addItem(redstone));
}
}
gui.setItem(4, 1, guiItem);
ItemStack redstone = new ItemStack(Material.REDSTONE);
GUIWindow gui = new GUIWindow("Get some redstone!", 3);
GUIItem guiItem = new GUIItem(redstone, event -> event.getWhoClicked().getInventory().addItem(redstone));
gui.setItem(4, 1, guiItem);
- There are also setOpenEvent() and setCloseEvent() methods!
- in
setItem (x, y, guiItem)
, x and y can also be replaced with a singleint
to place it in a raw position - a
Consumer
is basically just aRunnable
that passes an argument into therun
method - If you only need the GUI for a short period of time, use the
unregister()
method when you don't need it anymore