diff --git a/SpigotCore_Main/src/de/steamwar/inventory/SWAnvilInv.java b/SpigotCore_Main/src/de/steamwar/inventory/SWAnvilInv.java index e522e97..3ff1aa1 100644 --- a/SpigotCore_Main/src/de/steamwar/inventory/SWAnvilInv.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SWAnvilInv.java @@ -35,6 +35,7 @@ public class SWAnvilInv { private final Player player; private final String defaultText; + private Runnable leftCallback; private Consumer callback; public SWAnvilInv(Player p, String t) { @@ -42,7 +43,7 @@ public class SWAnvilInv { } public SWAnvilInv(Player p, String t, String defaultText) { - builder = new AnvilGUI.Builder().plugin(Core.getInstance()).title(t).text("»" + defaultText).onComplete(this::onResult); + builder = new AnvilGUI.Builder().plugin(Core.getInstance()).title(t).text("»" + defaultText).onClick(this::onResult); this.defaultText = defaultText; player = p; } @@ -68,7 +69,7 @@ public class SWAnvilInv { } public void addLeftCallback(Runnable callback) { - builder.onLeftInputClick(p -> callback.run()); + leftCallback = callback; } public void addCloseCallback(Runnable callback) { @@ -80,7 +81,15 @@ public class SWAnvilInv { builder.open(player); } - private List onResult(Player player, String s) { + private List onResult(Integer slot, AnvilGUI.StateSnapshot state) { + if(slot != AnvilGUI.Slot.OUTPUT) { + if(slot == AnvilGUI.Slot.INPUT_LEFT && leftCallback != null) + leftCallback.run(); + + return Collections.emptyList(); + } + + String s = state.getText(); if(s.startsWith("»")) s = s.substring(1); callback.accept(s);