diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java
index a4594cd..3b30892 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTrace.java
@@ -21,6 +21,7 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
+import de.steamwar.bausystem.gui.GuiTraceShow;
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.tracer.show.StoredRecords;
@@ -39,6 +40,7 @@ public class CommandTrace implements CommandExecutor {
player.sendMessage("§8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen");
player.sendMessage("§8/§etrace stop §8- §7Stoppt den TNT-Tracer");
player.sendMessage("§8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart");
+ player.sendMessage("§8/§etrace show gui §8- §7Zeigt die Trace show gui");
player.sendMessage("§8/§etrace show §8<§edefault§8|§eadvanced§8> §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen");
player.sendMessage("§8/§etrace hide §8- §7Versteckt alle TNT-Positionen");
player.sendMessage("§8/§etrace delete §8- §7Löscht alle TNT-Positionen");
@@ -90,6 +92,10 @@ public class CommandTrace implements CommandExecutor {
if (args.length < 2) {
TraceShowManager.show(player, new Basic(player, new ShowModeParameter()));
} else {
+ if (args[1].equalsIgnoreCase("gui")) {
+ GuiTraceShow.openGui(player);
+ return false;
+ }
ShowModeParameter showModeParameter = ShowModeParameter.parseArguments(args, 2);
switch (args[1].toLowerCase()) {
case "advanced":
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java
index 5efe116..e2930a2 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTraceTabCompleter.java
@@ -39,7 +39,7 @@ public class CommandTraceTabCompleter implements TabCompleter {
tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() == RecordStatus.IDLE || RecordStateMachine.getRecordStatus() == RecordStatus.IDLE_AUTO), "start"));
tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() != RecordStatus.IDLE && RecordStateMachine.getRecordStatus() != RecordStatus.IDLE_AUTO), "stop"));
tabCompletes.add(new TabComplete((player, args) -> args.length == 1, "toggleauto", "auto", "show", "hide", "delete", "clear"));
- tabCompletes.add(new TabComplete((player, args) -> args.length == 2 && args[0].equalsIgnoreCase("show"), "basic", "advanced"));
+ tabCompletes.add(new TabComplete((player, args) -> args.length == 2 && args[0].equalsIgnoreCase("show"), "basic", "advanced", "gui"));
tabCompletes.add(new TabComplete((player, args) -> args.length > 2 && args[0].equalsIgnoreCase("show") && (args[1].equalsIgnoreCase("basic") || args[1].equalsIgnoreCase("advanced")), "-water"));
tabCompletes.add(new TabComplete((player, args) -> args.length > 2 && args[0].equalsIgnoreCase("show") && args[1].equalsIgnoreCase("advanced"), "-interpolate-xz", "-interpolate-y"));
}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/gui/GuiTraceShow.java b/BauSystem_Main/src/de/steamwar/bausystem/gui/GuiTraceShow.java
new file mode 100644
index 0000000..e8949e9
--- /dev/null
+++ b/BauSystem_Main/src/de/steamwar/bausystem/gui/GuiTraceShow.java
@@ -0,0 +1,134 @@
+/*
+ *
+ * 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.gui;
+
+import de.steamwar.bausystem.BauSystem;
+import de.steamwar.bausystem.tracer.show.ShowMode;
+import de.steamwar.bausystem.tracer.show.ShowModeParameter;
+import de.steamwar.bausystem.tracer.show.TraceShowManager;
+import de.steamwar.bausystem.tracer.show.mode.Advanced;
+import de.steamwar.bausystem.tracer.show.mode.Basic;
+import de.steamwar.inventory.SWInventory;
+import de.steamwar.inventory.SWItem;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class GuiTraceShow {
+
+ private static final Map SHOW_MODE_PARAMETER_HASH_MAP = new HashMap<>();
+
+ public static void openGui(Player player) {
+ ShowModeParameter playerShowMode = new ShowModeParameter();
+ playerShowMode.setInterpolate_Y(false);
+ playerShowMode.setInterpolate_XZ(false);
+ SHOW_MODE_PARAMETER_HASH_MAP.put(player, playerShowMode);
+
+ SWInventory swInventory = new SWInventory(player, 9, BauSystem.PREFIX + "ShowGUI");
+ swInventory.addCloseCallback(clickType -> SHOW_MODE_PARAMETER_HASH_MAP.remove(player));
+
+ SWItem trace_show = new SWItem(Material.LIME_CONCRETE, "§aTraces Angezeigt", new ArrayList<>(), false, clickType -> {});
+ SWItem trace_hide = new SWItem(Material.RED_CONCRETE, "§cTraces Ausgeblendet", new ArrayList<>(), false, clickType -> {});
+ setActiveShow(player, swInventory, trace_show, trace_hide);
+
+ SWItem water = new SWItem(Material.TNT, "§eWasser §7Positionen", Arrays.asList("§7Zeigt alles TNT, welches", "§7im Wasser explodiert ist"), false, clickType -> {});
+ swInventory.setItem(5, water);
+ swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, water));
+
+ SWItem interpolateY = new SWItem(Material.QUARTZ_STAIRS, "§eInterpolation §7Y-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der Y-Achse"), false, clickType -> {});
+ swInventory.setItem(6, interpolateY);
+ swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, interpolateY));
+
+ SWItem interpolateXZ = new SWItem(Material.QUARTZ_SLAB, "§eInterpolation §7XZ-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der XZ-Achse"), false, clickType -> {});
+ swInventory.setItem(7, interpolateXZ);
+ swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, interpolateXZ));
+ // Water Bucket (-water)
+ // TNT (-water-exploded)
+ // Quartz_Stair (-interpolate-y)
+ // Quartz_Slab (-interpolate-xz)
+ swInventory.open();
+ }
+
+ private static void setActiveShow(Player player, SWInventory swInventory, SWItem shown, SWItem hidden) {
+ if (TraceShowManager.hasActiveShow(player)) {
+ swInventory.setItem(1, shown);
+ swInventory.setCallback(1, clickType -> {
+ TraceShowManager.hide(player);
+ player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet");
+ setActiveShow(player, swInventory, shown, hidden);
+ });
+ } else {
+ swInventory.setItem(1, hidden);
+ swInventory.setCallback(1, clickType -> {
+ show(player);
+ player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
+ setActiveShow(player, swInventory, shown, hidden);
+ });
+ }
+ }
+
+ private static void toggleHideTNTinWaterExploded(Player player, SWInventory swInventory, SWItem swItem) {
+ ShowModeParameter showModeParameter = SHOW_MODE_PARAMETER_HASH_MAP.get(player);
+ showModeParameter.setWater(!showModeParameter.isWater());
+ show(player);
+
+ swItem.setEnchanted(showModeParameter.isWater());
+ swInventory.setItem(5, swItem);
+ swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, swItem));
+ }
+
+ private static void toggleInterpolateYPosition(Player player, SWInventory swInventory, SWItem swItem) {
+ ShowModeParameter showModeParameter = SHOW_MODE_PARAMETER_HASH_MAP.get(player);
+ showModeParameter.setInterpolate_Y(!showModeParameter.isInterpolate_Y());
+ show(player);
+
+ swItem.setEnchanted(showModeParameter.isInterpolate_Y());
+ swInventory.setItem(6, swItem);
+ swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, swItem));
+ }
+
+ private static void toggleInterpolateXZPosition(Player player, SWInventory swInventory, SWItem swItem) {
+ ShowModeParameter showModeParameter = SHOW_MODE_PARAMETER_HASH_MAP.get(player);
+ showModeParameter.setInterpolate_XZ(!showModeParameter.isInterpolate_XZ());
+ show(player);
+
+ swItem.setEnchanted(showModeParameter.isInterpolate_XZ());
+ swInventory.setItem(7, swItem);
+ swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, swItem));
+ }
+
+ private static void show(Player player) {
+ ShowModeParameter showModeParameter = SHOW_MODE_PARAMETER_HASH_MAP.get(player);
+ ShowMode showMode;
+ if (showModeParameter.isAdvanced()) {
+ showMode = new Advanced(player, showModeParameter);
+ } else {
+ showMode = new Basic(player, showModeParameter);
+ }
+ TraceShowManager.show(player, showMode);
+ }
+
+}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowModeParameter.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowModeParameter.java
index e3ee044..27900a5 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowModeParameter.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowModeParameter.java
@@ -44,6 +44,22 @@ public class ShowModeParameter {
return interpolate_XZ;
}
+ public void setWater(boolean water) {
+ this.water = water;
+ }
+
+ public void setInterpolate_Y(boolean interpolate_Y) {
+ this.interpolate_Y = interpolate_Y;
+ }
+
+ public void setInterpolate_XZ(boolean interpolate_XZ) {
+ this.interpolate_XZ = interpolate_XZ;
+ }
+
+ public boolean isAdvanced() {
+ return interpolate_Y | interpolate_XZ;
+ }
+
public static ShowModeParameter parseArguments(String[] args, int index) {
ShowModeParameter showModeParameter = new ShowModeParameter();
for (int i = index; i < args.length; i++) {
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java
index 70e8afd..21c09f1 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TraceShowManager.java
@@ -51,4 +51,9 @@ public class TraceShowManager implements Listener {
public void onLeave(PlayerQuitEvent event) {
showModes.remove(event.getPlayer());
}
+
+ public static boolean hasActiveShow(Player player) {
+ return showModes.containsKey(player);
+ }
+
}