From 90357e4fd2ea14771157153632d645dccb9d0e30 Mon Sep 17 00:00:00 2001 From: jojo Date: Wed, 8 Jul 2020 13:05:41 +0200 Subject: [PATCH] Add TNTTracerGUI start --- .../tracer/RecordingCallback_15.java | 10 ++ .../bausystem/tracer/TNTFrameCallback_15.java | 11 +++ .../bausystem/tracer/TNTTraceCallback_15.java | 11 +++ .../bausystem/tracer/TNTTracerGUI_15.java | 92 +++++++++++++++++++ .../bausystem/tracer/TNTTracer15.java | 1 - 5 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 BauSystem_15/src/de/steamwar/bausystem/tracer/RecordingCallback_15.java create mode 100644 BauSystem_15/src/de/steamwar/bausystem/tracer/TNTFrameCallback_15.java create mode 100644 BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTraceCallback_15.java create mode 100644 BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracerGUI_15.java diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/RecordingCallback_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/RecordingCallback_15.java new file mode 100644 index 0000000..f265432 --- /dev/null +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/RecordingCallback_15.java @@ -0,0 +1,10 @@ +package de.steamwar.bausystem.tracer; + +import org.bukkit.inventory.ItemStack; + +@FunctionalInterface +public interface RecordingCallback_15 { + + ItemStack run(); + +} diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTFrameCallback_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTFrameCallback_15.java new file mode 100644 index 0000000..2ad3b64 --- /dev/null +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTFrameCallback_15.java @@ -0,0 +1,11 @@ +package de.steamwar.bausystem.tracer; + +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +@FunctionalInterface +public interface TNTFrameCallback_15 { + + ItemStack[] run(Player p); + +} diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTraceCallback_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTraceCallback_15.java new file mode 100644 index 0000000..2be953b --- /dev/null +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTraceCallback_15.java @@ -0,0 +1,11 @@ +package de.steamwar.bausystem.tracer; + +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +@FunctionalInterface +public interface TNTTraceCallback_15 { + + ItemStack[] run(Player p); + +} diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracerGUI_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracerGUI_15.java new file mode 100644 index 0000000..adf472d --- /dev/null +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracerGUI_15.java @@ -0,0 +1,92 @@ +package de.steamwar.bausystem.tracer; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.Arrays; +import java.util.List; + +public class TNTTracerGUI_15 { + + private static TNTFrameCallback_15 tntFrameCallback_15; + private static TNTTraceCallback_15 tntTraceCallback_15; + private static RecordingCallback_15 recordingCallback_15; + + private static Inventory getEmpty(String title) { + Inventory inventory = Bukkit.createInventory(null, 54, title); + ItemStack i1 = createItem(Material.LIGHT_GRAY_STAINED_GLASS_PANE, false, ""); + for (int i = 0; i < 9; i++) { + inventory.setItem(i, i1); + } + ItemStack i2 = createItem(Material.RED_STAINED_GLASS, false, ""); + for (int i = 9; i < 54; i++) { + inventory.setItem(i, i2); + } + return inventory; + } + + public static ItemStack createItem(Material material, boolean selected, String name, String... lore) { + ItemStack item = new ItemStack(material, 1); + ItemMeta im = item.getItemMeta(); + + if (im == null) return item; + if (name == null) name = "§f"; + if (name.isEmpty()) name = "§f"; + im.setDisplayName(name); + if (selected) { + im.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, true); + } + im.addItemFlags(ItemFlag.HIDE_ENCHANTS); + + if (lore != null) { + List lorelist = Arrays.asList(lore); + im.setLore(lorelist); + } + + item.setItemMeta(im); + return item; + } + + private static void frameControls(Inventory inventory, int page, int allPages) { + inventory.setItem(1, createItem(Material.HONEYCOMB, false, "§eShow§8/§eHide")); + inventory.setItem(4, createItem(Material.BARRIER, false, "§eClear ausgewählte Positionen")); + inventory.setItem(5, createItem(Material.OBSERVER, false, "§eToggle AUTO-Trace")); + inventory.setItem(6, recordingCallback_15.run()); + inventory.setItem(8, createItem(Material.PAPER, false, "§7PAGE §e§l" + page + "§8/§e§l" + allPages)); + } + + private static Inventory getFrameInventory(Player p, int page) { + ItemStack[] items = tntFrameCallback_15.run(p); + + Inventory inventory = getEmpty("§7§lTRACE §8- §e§lAufnahmen"); + if (items.length == 0) { + frameControls(inventory, page + 1, 1); + } else { + frameControls(inventory, page + 1, items.length / 45 + (items.length % 45 == 0 ? 0 : 1)); + } + return inventory; + } + + public static void init(TNTFrameCallback_15 tntFrameCallback_15, TNTTraceCallback_15 tntTraceCallback_15, RecordingCallback_15 recordingCallback_15) { + TNTTracerGUI_15.tntFrameCallback_15 = tntFrameCallback_15; + TNTTracerGUI_15.tntTraceCallback_15 = tntTraceCallback_15; + TNTTracerGUI_15.recordingCallback_15 = recordingCallback_15; + } + + public enum Menu { + FRAME, + TRACE, + BLOCK + } + + public static void show(Player p, int page, Menu menu) { + + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java index d55f639..347fc13 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/TNTTracer15.java @@ -9,7 +9,6 @@ import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.scheduler.BukkitTask;