package com.lifeknight.relaymchub.player; import com.lifeknight.relaymcutils.player.CustomDuelsKit; import com.lifeknight.relaymcutils.player.CustomMap; import com.lifeknight.relaymcutils.player.DuelMap; import com.lifeknight.relaymcutils.player.SmartPlayer; import com.lifeknight.relaymcutils.player.settings.GameSetting; import com.lifeknight.relayutils.basic.Miscellaneous; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.List; import java.util.UUID; import static org.bukkit.ChatColor.*; public class PreviewCustomKitGUI extends EditCustomKitGUI { private final boolean library; private final boolean browsing; public PreviewCustomKitGUI(CustomDuelsKit original, HubPlayer owner, boolean library, boolean browsing) { super(original, owner, 0); this.library = library; this.browsing = browsing; this.fill(); } @Override public void fill() { ItemStack armorEmpty = new ItemStack(Material.RED_STAINED_GLASS_PANE); this.addImmutable(HELMET, this.helmet == null ? armorEmpty : this.helmet.clone(), this.helmet == null ? GOLD + "Helmet" : ""); this.addImmutable(CHESTPLATE, this.chestplate == null ? armorEmpty : this.chestplate.clone(), this.chestplate == null ? GOLD + "Chestplate" : this.chestplate.getItemMeta().getDisplayName()); this.addImmutable(LEGGINGS, this.leggings == null ? armorEmpty : this.leggings.clone(), this.leggings == null ? GOLD + "Leggings" : this.leggings.getItemMeta().getDisplayName()); this.addImmutable(BOOTS, this.boots == null ? armorEmpty : this.boots.clone(), this.boots == null ? GOLD + "Boots" : this.boots.getItemMeta().getDisplayName()); this.addImmutable(OFF_HAND, this.offHand == null ? new ItemStack(Material.LIME_STAINED_GLASS_PANE) : this.offHand.clone(), this.offHand == null ? AQUA + "Offhand" : this.offHand.getItemMeta().getDisplayName()); //this.add(REPRESENTATIVE, this.representative == null ? armorEmpty : this.representative.clone(), (player, b, b2) -> this.editSlot(REPRESENTATIVE, b, b2), RED + "Kit Icon"); for (int i = INVENTORY_START; i <= INVENTORY_END; i++) { int finalI = i; int index; if (finalI < 27) { index = finalI % 9 + 18; } else if (finalI < 36) { index = finalI % 9 + 9; } else { index = finalI % 9; } ItemStack itemStack = this.inventory[index]; this.addImmutable(i, itemStack == null ? new ItemStack(Material.LIGHT_BLUE_STAINED_GLASS_PANE) : itemStack, itemStack == null ? YELLOW + "Inventory" : itemStack.getItemMeta().getDisplayName()); } for (int i = HOTBAR_START; i <= HOTBAR_END; i++) { int finalI = i; ItemStack itemStack = this.hotbar[finalI % 9]; this.addImmutable(i, itemStack == null ? new ItemStack(Material.BLUE_STAINED_GLASS_PANE) : itemStack, itemStack == null ? LIGHT_PURPLE + "Hotbar" : itemStack.getItemMeta().getDisplayName()); } if (this.library) { if (this.browsing) { this.add(0, Material.RED_TERRACOTTA, (player, b, b1) -> this.owner.browsePublicKits(false), RED + "Back", GRAY + "Return to browsing public kits."); } else { this.add(0, Material.RED_TERRACOTTA, (p, b, b1) -> this.owner.viewCustomKitHistory(), RED + "Back", GRAY + "Return to your kit history."); } this.add(1, Material.LIME_TERRACOTTA, (player, b, b1) -> this.owner.acceptPreviewKit(), GREEN + "Select Kit", GRAY + "Select this kit."); this.add(2, Material.WRITABLE_BOOK, (player, b, b1) -> this.owner.addToKitLibrary(), GOLD + "Add to Your Library", GRAY + "Add a copy of this kit to your library."); } else { this.add(0, Material.GREEN_TERRACOTTA, (player, b, b1) -> this.owner.acceptKit(), GREEN + "Accept Kit", GRAY + "Play against this player with this kit."); this.add(1, Material.RED_TERRACOTTA, (player, b, b1) -> this.owner.cancelKit(true), RED + "Cancel", GRAY + "Return to kit browsing."); } List description = new ArrayList<>(); description.add(GRAY + "Owner: " + SmartPlayer.getOrCreate(this.customDuelsKit.getOwner()).getRealFormattedName()); description.add(GRAY + "Previous Creators: "); if (this.customDuelsKit.getCreators().isEmpty()) { description.add(DARK_GRAY + " - None"); } else { for (UUID creator : this.customDuelsKit.getCreators()) { description.add(DARK_GRAY + " - " + SmartPlayer.getOrCreate(creator).getRealFormattedName()); } } this.addImmutable(6, Material.PAPER, AQUA + "Info", description); String mapName; String map = Miscellaneous.getFirstEntry(this.customDuelsKit.getMaps()); if (this.owner.previewMap != null) { mapName = this.owner.previewMap.getName(); } else { DuelMap duelMap = DuelMap.getDuelMap(map); if (duelMap != null) { mapName = duelMap.getName(); } else { CustomMap customMap1 = CustomMap.CODE_TO_MAP.get(map); if (customMap1 != null) { mapName = customMap1.getName() + DARK_AQUA + " (Custom)"; } else { mapName = map + DARK_AQUA + " (Custom)"; } } } this.addImmutable(7, Material.MAP, GOLD + mapName); List settings = new ArrayList<>(); for (GameSetting gameSetting : this.gameSettings.gameSettings) { settings.add(gameSetting.getFormattedName() + ": " + gameSetting.getFormattedDataString()); } this.addImmutable(8, Material.COMPARATOR, GOLD + "Settings", settings); } @Override public void setItem(int slot) { } @Override public void save() { } }