Allows using an existing item stack for an item factory

This commit is contained in:
Kristian Knarvik 2023-05-10 15:37:18 +02:00
parent c18bf8d1d5
commit 1aa33e87c5
4 changed files with 18 additions and 1 deletions

View File

@ -47,6 +47,11 @@ public abstract class AbstractGUI {
instantiate(inventory);
}
/**
* Sets up an abstract GUI using the given inventory
*
* @param inventory <p>The inventory used for this GUI</p>
*/
private void instantiate(Inventory inventory) {
this.uuid = UUID.randomUUID();
this.inventory = inventory;

View File

@ -59,7 +59,6 @@ public class GUIRegistry {
* @param autoDelete <p>Whether to immediately delete the closed GUI</p>
*/
public static void closeGUI(Player player, boolean autoDelete) {
//Run the close action if an anvil GUI is used
AbstractGUI gui = getOpenGUI(player);
//Un-register the player's open GUI
openGUIs.remove(player.getUniqueId());

View File

@ -1,5 +1,8 @@
package net.knarcraft.knargui;
/**
* Empty main class just in case something runs this directly
*/
@SuppressWarnings("unused")
public final class KnarGUI {

View File

@ -30,4 +30,14 @@ public class GUIItemFactory extends AbstractGUIItemFactory<GUIItemFactory> {
setChild(this);
}
/**
* Instantiates a new item factory
*
* @param itemStack <p>The item stack to modify</p>
*/
public GUIItemFactory(ItemStack itemStack) {
super(itemStack);
setChild(this);
}
}