package net.knarcraft.minigames.gui; import net.knarcraft.knargui.GUIAction; import net.knarcraft.knargui.item.GUIItemFactory; import net.knarcraft.minigames.MiniGames; import net.knarcraft.minigames.arena.ArenaSession; import net.knarcraft.minigames.arena.parkour.ParkourArenaSession; import net.md_5.bungee.api.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import java.util.List; /** * A GUI used in the parkour arena */ public class ParkourGUI extends ArenaGUI { /** * Instantiates a new parkour gui * * @param player
The player the GUI is created for
*/ public ParkourGUI(Player player) { super(9, "Parkour"); if (MiniGames.getInstance().getPlayerVisibilityManager().isHidingPlayers(player)) { setItem(0, getTogglePlayersItemEnabled()); } else { setItem(0, getTogglePlayersItemDisabled()); } setItem(2, getGiveUpItem()); setItem(4, getLeaveItem()); setItem(6, getRestartItem()); setAnyClickAction(0, getTogglePlayersAction(MiniGames.getInstance().getParkourArenaPlayerRegistry())); setAnyClickAction(2, getGiveUpAction()); setAnyClickAction(4, getLeaveAction()); setAnyClickAction(6, getRestartAction()); } /** * Gets an item describing a give up action * * @returnA give up item
*/ private ItemStack getGiveUpItem() { GUIItemFactory giveUpItemFactory = new GUIItemFactory(Material.RESPAWN_ANCHOR); ListThe give up action
*/ public static GUIAction getGiveUpAction() { return (player) -> { ArenaSession session = MiniGames.getInstance().getSession(player.getUniqueId()); if (session instanceof ParkourArenaSession) { session.triggerLoss(); } }; } }