diff --git a/BauSystem_Main/src/de/steamwar/bausystem/cannonsimulator/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/cannonsimulator/TNTSimulator.java index c716b98..ee7be08 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/cannonsimulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/cannonsimulator/TNTSimulator.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.cannonsimulator; import de.steamwar.bausystem.BauSystem; +import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; @@ -116,7 +117,7 @@ public class TNTSimulator { // tnt Name swInventory.setItem(45, new SWItem(Material.NAME_TAG, "§eName", clickType -> { - TNTSimulatorAnvil tntSimulatorAnvil = new TNTSimulatorAnvil(player, "Name", "»" + tntSpawn.getName()); + SWAnvilInv tntSimulatorAnvil = new SWAnvilInv(player, "Name", tntSpawn.getName()); tntSimulatorAnvil.setCallback(s -> { if (s.startsWith("»")) s = s.substring(1); tntSpawn.setName(s); @@ -285,7 +286,7 @@ public class TNTSimulator { } private static void changeCount(Player player, int defaultValue, Consumer result, Runnable failure) { - TNTSimulatorAnvil swAnvilInv = new TNTSimulatorAnvil(player, "Zahl", defaultValue + ""); + SWAnvilInv swAnvilInv = new SWAnvilInv(player, "Zahl", defaultValue + ""); swAnvilInv.setItem(Material.PAPER); swAnvilInv.setCallback(s -> { try { @@ -298,7 +299,7 @@ public class TNTSimulator { } private static void changePosition(Player player, double defaultValue, Consumer result, Runnable failure) { - TNTSimulatorAnvil swAnvilInv = new TNTSimulatorAnvil(player, "Position", defaultValue + ""); + SWAnvilInv swAnvilInv = new SWAnvilInv(player, "Position", defaultValue + ""); swAnvilInv.setItem(Material.PAPER); swAnvilInv.setCallback(s -> { try { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/cannonsimulator/TNTSimulatorAnvil.java b/BauSystem_Main/src/de/steamwar/bausystem/cannonsimulator/TNTSimulatorAnvil.java deleted file mode 100644 index 1250f8b..0000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/cannonsimulator/TNTSimulatorAnvil.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * / - */ - -package de.steamwar.bausystem.cannonsimulator; - -import de.steamwar.core.Core; -import de.steamwar.inventory.SWItem; -import net.wesjd.anvilgui.AnvilGUI; -import net.wesjd.anvilgui.AnvilGUI.Response; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.function.Consumer; - -public class TNTSimulatorAnvil { - - private final AnvilGUI.Builder builder; - private final Player player; - private Consumer callback; - - public TNTSimulatorAnvil(Player p, String t, String defaultValue) { - this.builder = (new AnvilGUI.Builder()).plugin(Core.getInstance()).title(t).text("" + defaultValue).onComplete(this::onResult); - this.player = p; - } - - public void setItem(Material m) { - this.builder.itemLeft((new SWItem(m, "").getItemStack())); - } - - public void setCallback(Consumer callback) { - this.callback = callback; - } - - public void open() { - this.builder.open(this.player); - } - - private Response onResult(Player player, String s) { - this.callback.accept(s); - return Response.close(); - } - -}