From 3a26c30ae8863b8e982e370b304b0a62818bf191 Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 22 Jan 2021 16:27:18 +0100 Subject: [PATCH] Add SWAnvilInv.defaultText --- .../src/de/steamwar/inventory/SWAnvilInv.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/inventory/SWAnvilInv.java b/SpigotCore_Main/src/de/steamwar/inventory/SWAnvilInv.java index ef05443..8244390 100644 --- a/SpigotCore_Main/src/de/steamwar/inventory/SWAnvilInv.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SWAnvilInv.java @@ -32,39 +32,45 @@ public class SWAnvilInv { private final AnvilGUI.Builder builder; private final Player player; + private final String defaultText; private Consumer callback; - public SWAnvilInv(Player p, String t){ - builder = new AnvilGUI.Builder().plugin(Core.getInstance()).title(t).text("»").onComplete(this::onResult); + public SWAnvilInv(Player p, String t) { + this(p, t, ""); + } + + public SWAnvilInv(Player p, String t, String defaultText) { + builder = new AnvilGUI.Builder().plugin(Core.getInstance()).title(t).text("»" + defaultText).onComplete(this::onResult); + this.defaultText = defaultText; player = p; } - public void setItem(Material m){ + public void setItem(Material m) { setItem(m, new ArrayList<>(), false); } - public void setItem(Material m, byte meta){ + public void setItem(Material m, byte meta) { setItem(m, meta, new ArrayList<>(), false); } - public void setItem(Material m, List lore, boolean e){ + public void setItem(Material m, List lore, boolean e) { setItem(m, (byte)0, lore, e); } - public void setItem(Material m, byte meta, List lore, boolean e){ - builder.itemLeft(new SWItem(m, meta, "»", lore, e, null).getItemStack()); + public void setItem(Material m, byte meta, List lore, boolean e) { + builder.itemLeft(new SWItem(m, meta, "»" + defaultText, lore, e, null).getItemStack()); } - public void setCallback(Consumer callback){ + public void setCallback(Consumer callback) { this.callback = callback; } - public void addCloseCallback(Runnable callback){ + public void addCloseCallback(Runnable callback) { builder.onClose(p -> callback.run()); } - public void open(){ + public void open() { builder.open(player); }