13
0

Removing Pair<>

Dieser Commit ist enthalten in:
Lixfel 2020-01-18 15:08:35 +01:00
Ursprung c28997aa58
Commit 56869c3218

Datei anzeigen

@ -5,12 +5,10 @@ import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv; import de.steamwar.inventory.SWListInv;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.sql.*; import de.steamwar.sql.*;
import javafx.util.Pair;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import java.util.*; import java.util.*;
@ -19,7 +17,7 @@ class GUI {
private GUI(){} private GUI(){}
static void changeType(Player p, Schematic schem){ static void changeType(Player p, Schematic schem){
List<Pair<SWItem, SchematicType>> types = new LinkedList<>(); List<SWListInv.SWListEntry<SchematicType>> types = new LinkedList<>();
for(SchematicType type : SchematicType.values()){ for(SchematicType type : SchematicType.values()){
if(!type.isAssignable()) if(!type.isAssignable())
continue; continue;
@ -28,13 +26,13 @@ class GUI {
if(type.fightType()) if(type.fightType())
item.setEnchanted(true); item.setEnchanted(true);
types.add(new Pair<>(item, type)); types.add(new SWListInv.SWListEntry<>(item, type));
} }
SWListInv<SchematicType> inv = new SWListInv<>(p, "Typ ändern", (clickType, schematicType) -> { SWListInv<SchematicType> inv = new SWListInv<>(p, "Typ ändern", types, (clickType, schematicType) -> {
SchematicCommand.changetype(p, schem, schematicType); SchematicCommand.changetype(p, schem, schematicType);
p.closeInventory(); p.closeInventory();
}, types); });
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open(); inv.open();
} }
@ -59,34 +57,34 @@ class GUI {
} }
static void delmembers(Player p, Schematic schem){ static void delmembers(Player p, Schematic schem){
List<Pair<SWItem, SchematicMember>> members = new LinkedList<>(); List<SWListInv.SWListEntry<SchematicMember>> members = new LinkedList<>();
for(SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())){ for(SchematicMember member : SchematicMember.getSchemMembers(schem.getSchemName(), schem.getSchemOwner())){
SteamwarUser user = SteamwarUser.get(member.getMember()); 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<SchematicMember> inv = new SWListInv<>(p, "Mitglieder entfernen", (clickType, member) -> { SWListInv<SchematicMember> inv = new SWListInv<>(p, "Mitglieder entfernen", members, (clickType, member) -> {
member.remove(); member.remove();
p.closeInventory(); p.closeInventory();
delmembers(p, schem); delmembers(p, schem);
}, members); });
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open(); inv.open();
} }
private static void changeItem(Player p, Schematic schem){ private static void changeItem(Player p, Schematic schem){
List<Pair<SWItem, Material>> materials = new LinkedList<>(); List<SWListInv.SWListEntry<Material>> materials = new LinkedList<>();
for(Material material : Material.values()){ for(Material material : Material.values()){
SWItem item = new SWItem(material, "§7" + material.name()); SWItem item = new SWItem(material, "§7" + material.name());
if(item.getItemMeta() != null && material.isItem()) if(item.getItemMeta() != null && material.isItem())
materials.add(new Pair<>(item, material)); materials.add(new SWListInv.SWListEntry<>(item, material));
} }
SWListInv<Material> inv = new SWListInv<>(p, "Item ändern", (clickType, material) -> { SWListInv<Material> inv = new SWListInv<>(p, "Item ändern", materials, (clickType, material) -> {
schem.setItem(material.name()); schem.setItem(material.name());
p.closeInventory(); p.closeInventory();
info(p, schem); info(p, schem);
}, materials); });
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open(); inv.open();
} }
@ -139,13 +137,11 @@ class GUI {
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), click -> {}); inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + schem.getSchemType().name(), click -> {});
SteamwarUser owneruser = SteamwarUser.get(schem.getSchemOwner()); SteamwarUser owneruser = SteamwarUser.get(schem.getSchemOwner());
SWItem owner = new SWItem(); SWItem owner = SWItem.getPlayerSkull(owneruser.getUserName());
ItemStack head = new ItemStack(SWItem.getMaterial("SKULL_ITEM"), 1, (short)3); SkullMeta headmeta = (SkullMeta)owner.getItemMeta();
SkullMeta headmeta = (SkullMeta)head.getItemMeta();
headmeta.setOwningPlayer(Bukkit.getOfflinePlayer(owneruser.getUUID())); headmeta.setOwningPlayer(Bukkit.getOfflinePlayer(owneruser.getUUID()));
headmeta.setDisplayName("§7von §e" + owneruser.getUserName()); headmeta.setDisplayName("§7von §e" + owneruser.getUserName());
head.setItemMeta(headmeta); owner.setItemMeta(headmeta);
owner.setItemStack(head);
inv.setItem(6, owner); inv.setItem(6, owner);
} }
@ -158,7 +154,7 @@ class GUI {
} }
static void list(Player p, int pid){ static void list(Player p, int pid){
List<Pair<SWItem, Schematic>> schemList = new LinkedList<>(); List<SWListInv.SWListEntry<Schematic>> schemList = new LinkedList<>();
List<Schematic> schems = Schematic.getSchemsAccessibleByUser(pid); List<Schematic> schems = Schematic.getSchemsAccessibleByUser(pid);
for(Schematic schem : schems) { for(Schematic schem : schems) {
@ -169,19 +165,19 @@ class GUI {
m = SWItem.getMaterial(schem.getItem()); m = SWItem.getMaterial(schem.getItem());
SWItem item = new SWItem(m, "§e" + schem.getSchemName(), Collections.singletonList("§7" + schem.getSchemType().name()), !schem.getSchemType().writeable(), click -> {}); 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<Schematic> inv = new SWListInv<>(p, "§eSchematicliste", (clickType, schem) -> { SWListInv<Schematic> inv = new SWListInv<>(p, "§eSchematicliste", schemList, (clickType, schem) -> {
p.closeInventory(); p.closeInventory();
info(p, schem); info(p, schem);
}, schemList); });
inv.setCallback(-999, (ClickType click) -> p.closeInventory()); inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open(); inv.open();
} }
static boolean listSearch(Player player, String search) { static boolean listSearch(Player player, String search) {
List<Pair<SWItem, Schematic>> schemList = new LinkedList<>(); List<SWListInv.SWListEntry<Schematic>> schemList = new LinkedList<>();
List<Schematic> filteredSchems = new ArrayList<>(); List<Schematic> filteredSchems = new ArrayList<>();
for(Schematic currentSchem : Schematic.getSchemsAccessibleByUser(player.getUniqueId())) { for(Schematic currentSchem : Schematic.getSchemsAccessibleByUser(player.getUniqueId())) {
@ -200,13 +196,13 @@ class GUI {
m = SWItem.getMaterial(currentSchem.getItem()); m = SWItem.getMaterial(currentSchem.getItem());
SWItem item = new SWItem(m, "§e" + currentSchem.getSchemName(), Collections.singletonList("§7" + currentSchem.getSchemType().name()), !currentSchem.getSchemType().writeable(), click -> {}); 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<Schematic> inv = new SWListInv<>(player, "§eSuchergebnisse", (clickType, schem) -> { SWListInv<Schematic> inv = new SWListInv<>(player, "§eSuchergebnisse", schemList, (clickType, schem) -> {
player.closeInventory(); player.closeInventory();
info(player, schem); info(player, schem);
}, schemList); });
inv.setCallback(-999, (ClickType click) -> player.closeInventory()); inv.setCallback(-999, (ClickType click) -> player.closeInventory());
inv.open(); inv.open();
return true; return true;