Removes anvil GUI

Anvil GUI basically doesn't work. It's impossible to get the new name of the renamed item without using awful things like NMS.
This commit is contained in:
Kristian Knarvik 2023-01-19 23:08:23 +01:00
parent 035d894e88
commit c18bf8d1d5
2 changed files with 0 additions and 56 deletions

View File

@ -1,53 +0,0 @@
package net.knarcraft.knargui;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.AnvilInventory;
import java.util.function.BiConsumer;
/**
* A user-interface using an anvil GUI
*/
@SuppressWarnings("unused")
public abstract class AnvilGUI extends AbstractGUI {
private BiConsumer<String, Player> action;
public AnvilGUI(String inventoryName) {
super(0, inventoryName, InventoryType.ANVIL);
}
/**
* Gets the text the user has written in the renaming field
*
* @return <p>The text in the renaming field</p>
*/
public String getText() {
AnvilInventory anvilInventory = (AnvilInventory) this.getInventory();
return anvilInventory.getRenameText();
}
/**
* Sets an action to be run if this GUI is closed
*
* <p>The action will be passed the current value of the anvil text</p>
*
* @param action <p>The action to be run</p>
*/
public void setCloseAction(BiConsumer<String, Player> action) {
this.action = action;
}
/**
* Runs the action this GUI should run when closing
*
* @param player <p>The player that closed this GUI</p>
*/
public void runCloseAction(Player player) {
if (action != null) {
this.action.accept(getText(), player);
}
}
}

View File

@ -61,9 +61,6 @@ public class GUIRegistry {
public static void closeGUI(Player player, boolean autoDelete) { public static void closeGUI(Player player, boolean autoDelete) {
//Run the close action if an anvil GUI is used //Run the close action if an anvil GUI is used
AbstractGUI gui = getOpenGUI(player); AbstractGUI gui = getOpenGUI(player);
if (gui instanceof AnvilGUI anvilGUI) {
anvilGUI.runCloseAction(player);
}
//Un-register the player's open GUI //Un-register the player's open GUI
openGUIs.remove(player.getUniqueId()); openGUIs.remove(player.getUniqueId());