From e3eeb3607edcead6e1c938ceae2a4e82d521e999 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 21 Dec 2020 17:27:31 +0100 Subject: [PATCH] Switch to consumer + remove debug message --- .../src/de/steamwar/inventory/SWAnvilInv.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/inventory/SWAnvilInv.java b/SpigotCore_Main/src/de/steamwar/inventory/SWAnvilInv.java index 582538f..ef05443 100644 --- a/SpigotCore_Main/src/de/steamwar/inventory/SWAnvilInv.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SWAnvilInv.java @@ -26,13 +26,14 @@ import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; public class SWAnvilInv { private final AnvilGUI.Builder builder; private final Player player; - private Response callback; + private Consumer callback; public SWAnvilInv(Player p, String t){ builder = new AnvilGUI.Builder().plugin(Core.getInstance()).title(t).text("»").onComplete(this::onResult); @@ -55,7 +56,7 @@ public class SWAnvilInv { builder.itemLeft(new SWItem(m, meta, "»", lore, e, null).getItemStack()); } - public void setCallback(Response callback){ + public void setCallback(Consumer callback){ this.callback = callback; } @@ -70,15 +71,7 @@ public class SWAnvilInv { private AnvilGUI.Response onResult(Player player, String s) { if(s.startsWith("»")) s = s.substring(1); - callback.onResult(s); + callback.accept(s); return AnvilGUI.Response.close(); } - - public void onClose(Player player) { - player.sendMessage("Closing"); - } - - public static interface Response{ - void onResult(String s); - } }