From 56869c3218aa95a48005255d0d87f0f1d11ba77e Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 18 Jan 2020 15:08:35 +0100 Subject: [PATCH] Removing Pair<> --- .../schematicsystem/commands/GUI.java | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java index 3fbd253..63ac2b3 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java @@ -5,12 +5,10 @@ import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.sql.*; -import javafx.util.Pair; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import java.util.*; @@ -19,7 +17,7 @@ class GUI { private GUI(){} static void changeType(Player p, Schematic schem){ - List> types = new LinkedList<>(); + List> types = new LinkedList<>(); for(SchematicType type : SchematicType.values()){ if(!type.isAssignable()) continue; @@ -28,13 +26,13 @@ class GUI { if(type.fightType()) item.setEnchanted(true); - types.add(new Pair<>(item, type)); + types.add(new SWListInv.SWListEntry<>(item, type)); } - SWListInv inv = new SWListInv<>(p, "Typ ändern", (clickType, schematicType) -> { + SWListInv inv = new SWListInv<>(p, "Typ ändern", types, (clickType, schematicType) -> { SchematicCommand.changetype(p, schem, schematicType); p.closeInventory(); - }, types); + }); inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.open(); } @@ -59,34 +57,34 @@ class GUI { } static void delmembers(Player p, Schematic schem){ - List> members = new LinkedList<>(); + List> members = new LinkedList<>(); for(SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())){ SteamwarUser user = SteamwarUser.get(member.getMember()); - members.add(new Pair<>(SWItem.getPlayerSkull(Bukkit.getOfflinePlayer(user.getUUID())), member)); + members.add(new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(Bukkit.getOfflinePlayer(user.getUUID())), member)); } - SWListInv inv = new SWListInv<>(p, "Mitglieder entfernen", (clickType, member) -> { + SWListInv inv = new SWListInv<>(p, "Mitglieder entfernen", members, (clickType, member) -> { member.remove(); p.closeInventory(); delmembers(p, schem); - }, members); + }); inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.open(); } private static void changeItem(Player p, Schematic schem){ - List> materials = new LinkedList<>(); + List> materials = new LinkedList<>(); for(Material material : Material.values()){ SWItem item = new SWItem(material, "§7" + material.name()); if(item.getItemMeta() != null && material.isItem()) - materials.add(new Pair<>(item, material)); + materials.add(new SWListInv.SWListEntry<>(item, material)); } - SWListInv inv = new SWListInv<>(p, "Item ändern", (clickType, material) -> { + SWListInv inv = new SWListInv<>(p, "Item ändern", materials, (clickType, material) -> { schem.setItem(material.name()); p.closeInventory(); info(p, schem); - }, materials); + }); inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.open(); } @@ -139,13 +137,11 @@ class GUI { inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), click -> {}); SteamwarUser owneruser = SteamwarUser.get(schem.getSchemOwner()); - SWItem owner = new SWItem(); - ItemStack head = new ItemStack(SWItem.getMaterial("SKULL_ITEM"), 1, (short)3); - SkullMeta headmeta = (SkullMeta)head.getItemMeta(); + SWItem owner = SWItem.getPlayerSkull(owneruser.getUserName()); + SkullMeta headmeta = (SkullMeta)owner.getItemMeta(); headmeta.setOwningPlayer(Bukkit.getOfflinePlayer(owneruser.getUUID())); headmeta.setDisplayName("§7von §e" + owneruser.getUserName()); - head.setItemMeta(headmeta); - owner.setItemStack(head); + owner.setItemMeta(headmeta); inv.setItem(6, owner); } @@ -158,7 +154,7 @@ class GUI { } static void list(Player p, int pid){ - List> schemList = new LinkedList<>(); + List> schemList = new LinkedList<>(); List schems = Schematic.getSchemsAccessibleByUser(pid); for(Schematic schem : schems) { @@ -169,19 +165,19 @@ class GUI { m = SWItem.getMaterial(schem.getItem()); SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), click -> {}); - schemList.add(new Pair<>(item, schem)); + schemList.add(new SWListInv.SWListEntry<>(item, schem)); } - SWListInv inv = new SWListInv<>(p, "§eSchematicliste", (clickType, schem) -> { + SWListInv inv = new SWListInv<>(p, "§eSchematicliste", schemList, (clickType, schem) -> { p.closeInventory(); info(p, schem); - }, schemList); + }); inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.open(); } static boolean listSearch(Player player, String search) { - List> schemList = new LinkedList<>(); + List> schemList = new LinkedList<>(); List filteredSchems = new ArrayList<>(); for(Schematic currentSchem : Schematic.getSchemsAccessibleByUser(player.getUniqueId())) { @@ -200,13 +196,13 @@ class GUI { m = SWItem.getMaterial(currentSchem.getItem()); SWItem item = new SWItem(m, "§e" + currentSchem.getSchemName(), Collections.singletonList("§7" + currentSchem.getSchemType().name()), !currentSchem.getSchemType().writeable(), click -> {}); - schemList.add(new Pair<>(item, currentSchem)); + schemList.add(new SWListInv.SWListEntry<>(item, currentSchem)); } - SWListInv inv = new SWListInv<>(player, "§eSuchergebnisse", (clickType, schem) -> { + SWListInv inv = new SWListInv<>(player, "§eSuchergebnisse", schemList, (clickType, schem) -> { player.closeInventory(); info(player, schem); - }, schemList); + }); inv.setCallback(-999, (ClickType click) -> player.closeInventory()); inv.open(); return true;