SteamWar/BauSystem
Archiviert
13
0

Add TNTTracerGUI start

Dieser Commit ist enthalten in:
jojo 2020-07-08 13:05:41 +02:00
Ursprung 44a6156dec
Commit 90357e4fd2
5 geänderte Dateien mit 124 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,10 @@
package de.steamwar.bausystem.tracer;
import org.bukkit.inventory.ItemStack;
@FunctionalInterface
public interface RecordingCallback_15 {
ItemStack run();
}

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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<String> 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) {
}
}

Datei anzeigen

@ -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;