Search in sources :

Example 1 with Option

use of com.ebicep.warlords.game.option.Option in project Warlords by ebicep.

the class Game method start.

public void start() {
    if (state != null) {
        throw new IllegalStateException("Game already started");
    }
    for (GameAddon addon : addons) {
        addon.modifyGame(this);
    }
    this.options = Collections.unmodifiableList(options);
    state = this.map.initialState(this);
    for (Option option : options) {
        option.register(this);
    }
    for (Team team : TeamMarker.getTeams(this)) {
        this.points.put(team, 0);
    }
    state.begin();
    for (GameAddon addon : addons) {
        addon.stateHasChanged(this, null, state);
    }
    new GameRunnable(this) {

        @Override
        public void run() {
            Game.this.run();
        }
    }.runTaskTimer(0, 1);
// this.printDebuggingInformation();
}
Also used : GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Option(com.ebicep.warlords.game.option.Option)

Example 2 with Option

use of com.ebicep.warlords.game.option.Option in project Warlords by ebicep.

the class Game method close.

@Override
public void close() {
    if (this.closed) {
        return;
    }
    this.closed = true;
    List<Throwable> exceptions = new ArrayList<>();
    for (BukkitTask task : gameTasks) {
        task.cancel();
    }
    gameTasks.clear();
    for (Listener listener : eventHandlers) {
        HandlerList.unregisterAll(listener);
    }
    eventHandlers.clear();
    try {
        removeAllPlayers();
    } catch (Throwable e) {
        exceptions.add(e);
    }
    for (Option option : options) {
        try {
            option.onGameCleanup(this);
        } catch (Throwable e) {
            exceptions.add(e);
        }
    }
    this.acceptsPlayers = false;
    this.acceptsSpectators = false;
    this.nextState = null;
    if (this.state != null && !(this.state instanceof ClosedState)) {
        try {
            this.state.end();
        } catch (Throwable e) {
            exceptions.add(e);
        }
        this.state = new ClosedState(this);
    }
    this.options = Collections.emptyList();
    if (!exceptions.isEmpty()) {
        RuntimeException e = new RuntimeException("Problems closing the game", exceptions.get(0));
        for (int i = 1; i < exceptions.size(); i++) {
            e.addSuppressed(exceptions.get(i));
        }
        throw e;
    }
}
Also used : Listener(org.bukkit.event.Listener) RegisteredListener(org.bukkit.plugin.RegisteredListener) BukkitTask(org.bukkit.scheduler.BukkitTask) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Option(com.ebicep.warlords.game.option.Option) ClosedState(com.ebicep.warlords.game.state.ClosedState)

Example 3 with Option

use of com.ebicep.warlords.game.option.Option in project Warlords by ebicep.

the class EndState method begin.

@Override
public void begin() {
    for (Option option : game.getOptions()) {
        option.onGameEnding(game);
    }
    this.resetTimer();
    boolean teamBlueWins = winEvent != null && winEvent.getDeclaredWinner() == Team.BLUE;
    boolean teamRedWins = winEvent != null && winEvent.getDeclaredWinner() == Team.RED;
    List<WarlordsPlayer> players = game.warlordsPlayers().collect(Collectors.toList());
    if (players.isEmpty())
        return;
    sendMessageToAllGamePlayer(game, "" + ChatColor.GREEN + ChatColor.BOLD + "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬", false);
    sendMessageToAllGamePlayer(game, "" + ChatColor.WHITE + ChatColor.BOLD + "  Warlords", true);
    sendMessageToAllGamePlayer(game, "", false);
    if (teamBlueWins) {
        sendMessageToAllGamePlayer(game, ChatColor.YELLOW + "Winner" + ChatColor.GRAY + " - " + ChatColor.BLUE + "BLU", true);
    } else if (teamRedWins) {
        sendMessageToAllGamePlayer(game, ChatColor.YELLOW + "Winner" + ChatColor.GRAY + " - " + ChatColor.RED + "RED", true);
    } else {
        if (game.getAddons().contains(GameAddon.IMPOSTER_MODE)) {
            sendMessageToAllGamePlayer(game, ChatColor.YELLOW + "Winner" + ChatColor.GRAY + " - " + ChatColor.LIGHT_PURPLE + "GAME END", true);
        } else {
            sendMessageToAllGamePlayer(game, ChatColor.YELLOW + "Winner" + ChatColor.GRAY + " - " + ChatColor.LIGHT_PURPLE + "DRAW", true);
        }
    }
    sendMessageToAllGamePlayer(game, "", false);
    TextComponent mvp = new TextComponent("" + ChatColor.LIGHT_PURPLE + ChatColor.BOLD + "✚ MVP ✚");
    mvp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.LIGHT_PURPLE + "Total Flag Captures (everyone): " + ChatColor.GOLD + NumberFormat.addCommaAndRound(players.stream().mapToInt(WarlordsPlayer::getFlagsCaptured).sum()) + "\n" + ChatColor.LIGHT_PURPLE + "Total Flag Returns (everyone): " + ChatColor.GOLD + NumberFormat.addCommaAndRound(players.stream().mapToInt(WarlordsPlayer::getFlagsCaptured).sum())).create()));
    sendCenteredHoverableMessageToAllGamePlayer(game, Collections.singletonList(mvp));
    players = players.stream().sorted(Comparator.comparing(WarlordsPlayer::getTotalCapsAndReturnsWeighted).reversed()).collect(Collectors.toList());
    TextComponent playerMvp = new TextComponent(ChatColor.AQUA + players.get(0).getName());
    playerMvp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.LIGHT_PURPLE + "Flag Captures: " + ChatColor.GOLD + players.get(0).getFlagsCaptured() + "\n" + ChatColor.LIGHT_PURPLE + "Flag Returns: " + ChatColor.GOLD + players.get(0).getFlagsReturned()).create()));
    sendCenteredHoverableMessageToAllGamePlayer(game, Collections.singletonList(playerMvp));
    sendMessageToAllGamePlayer(game, "", false);
    TextComponent totalDamage = new TextComponent("" + ChatColor.RED + ChatColor.BOLD + "✚ TOP DAMAGE ✚");
    totalDamage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.RED + "Total Damage (everyone)" + ChatColor.GRAY + ": " + ChatColor.GOLD + NumberFormat.addCommaAndRound(players.stream().mapToLong(wp -> wp.getMinuteStats().total().getDamage()).sum())).create()));
    sendCenteredHoverableMessageToAllGamePlayer(game, Collections.singletonList(totalDamage));
    players = players.stream().sorted(Comparator.comparing((WarlordsPlayer wp) -> wp.getMinuteStats().total().getDamage()).reversed()).collect(Collectors.toList());
    List<TextComponent> leaderboardPlayersDamage = new ArrayList<>();
    for (int i = 0; i < players.size() && i < 3; i++) {
        WarlordsPlayer warlordsPlayer = players.get(i);
        TextComponent player = new TextComponent(ChatColor.AQUA + warlordsPlayer.getName() + ChatColor.GRAY + ": " + ChatColor.GOLD + NumberFormat.getSimplifiedNumber(warlordsPlayer.getMinuteStats().total().getDamage()));
        player.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.DARK_GRAY + "Lv" + ChatColor.GRAY + ExperienceManager.getLevelForSpec(warlordsPlayer.getUuid(), warlordsPlayer.getSpecClass()) + " " + ChatColor.GOLD + warlordsPlayer.getSpec().getClassName() + ChatColor.GREEN + " (" + warlordsPlayer.getSpec().getClass().getSimpleName() + ")").create()));
        leaderboardPlayersDamage.add(player);
        if (i != players.size() - 1 && i != 2) {
            leaderboardPlayersDamage.add(ChatUtils.SPACER);
        }
    }
    sendCenteredHoverableMessageToAllGamePlayer(game, leaderboardPlayersDamage);
    sendMessageToAllGamePlayer(game, "", false);
    TextComponent totalHealing = new TextComponent("" + ChatColor.GREEN + ChatColor.BOLD + "✚ TOP HEALING ✚");
    totalHealing.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.GREEN + "Total Healing (everyone)" + ChatColor.GRAY + ": " + ChatColor.GOLD + NumberFormat.addCommaAndRound(players.stream().mapToLong(wp -> wp.getMinuteStats().total().getHealing()).sum())).create()));
    sendCenteredHoverableMessageToAllGamePlayer(game, Collections.singletonList(totalHealing));
    players = players.stream().sorted(Comparator.comparing((WarlordsPlayer wp) -> wp.getMinuteStats().total().getHealing()).reversed()).collect(Collectors.toList());
    List<TextComponent> leaderboardPlayersHealing = new ArrayList<>();
    for (int i = 0; i < players.size() && i < 3; i++) {
        WarlordsPlayer warlordsPlayer = players.get(i);
        TextComponent player = new TextComponent(ChatColor.AQUA + warlordsPlayer.getName() + ChatColor.GRAY + ": " + ChatColor.GOLD + NumberFormat.getSimplifiedNumber(warlordsPlayer.getMinuteStats().total().getHealing()));
        player.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.DARK_GRAY + "Lv" + ChatColor.GRAY + ExperienceManager.getLevelForSpec(warlordsPlayer.getUuid(), warlordsPlayer.getSpecClass()) + " " + ChatColor.GOLD + warlordsPlayer.getSpec().getClassName() + ChatColor.GREEN + " (" + warlordsPlayer.getSpec().getClass().getSimpleName() + ")").create()));
        leaderboardPlayersHealing.add(player);
        if (i != players.size() - 1 && i != 2) {
            leaderboardPlayersHealing.add(ChatUtils.SPACER);
        }
    }
    sendCenteredHoverableMessageToAllGamePlayer(game, leaderboardPlayersHealing);
    sendMessageToAllGamePlayer(game, "", false);
    TextComponent yourStatistics = new TextComponent("" + ChatColor.GOLD + ChatColor.BOLD + "✚ YOUR STATISTICS ✚");
    yourStatistics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.WHITE + "Total Kills (everyone): " + ChatColor.GREEN + NumberFormat.addCommaAndRound(players.stream().mapToInt(wp -> wp.getMinuteStats().total().getKills()).sum()) + "\n" + ChatColor.WHITE + "Total Assists (everyone): " + ChatColor.GREEN + NumberFormat.addCommaAndRound(players.stream().mapToInt(wp -> wp.getMinuteStats().total().getAssists()).sum()) + "\n" + ChatColor.WHITE + "Total Deaths (everyone): " + ChatColor.GREEN + NumberFormat.addCommaAndRound(players.stream().mapToInt(wp -> wp.getMinuteStats().total().getDeaths()).sum())).create()));
    sendCenteredHoverableMessageToAllGamePlayer(game, Collections.singletonList(yourStatistics));
    for (WarlordsPlayer wp : PlayerFilter.playingGame(game)) {
        Player player = Bukkit.getPlayer(wp.getUuid());
        if (player == null)
            continue;
        TextComponent kills = new TextComponent(ChatColor.WHITE + "Kills: " + ChatColor.GOLD + NumberFormat.addCommaAndRound(wp.getMinuteStats().total().getKills()));
        TextComponent assists = new TextComponent(ChatColor.WHITE + "Assists: " + ChatColor.GOLD + NumberFormat.addCommaAndRound(wp.getMinuteStats().total().getAssists()));
        TextComponent deaths = new TextComponent(ChatColor.WHITE + "Deaths: " + ChatColor.GOLD + NumberFormat.addCommaAndRound(wp.getMinuteStats().total().getDeaths()));
        kills.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(wp.getStatString("Kills")).create()));
        assists.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(wp.getStatString("Assists")).create()));
        deaths.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(wp.getStatString("Deaths")).create()));
        ChatUtils.sendCenteredMessageWithEvents(player, Arrays.asList(kills, ChatUtils.SPACER, assists, ChatUtils.SPACER, deaths));
        TextComponent damage = new TextComponent(ChatColor.WHITE + "Damage: " + ChatColor.GOLD + NumberFormat.addCommaAndRound(wp.getMinuteStats().total().getDamage()));
        TextComponent heal = new TextComponent(ChatColor.WHITE + "Healing: " + ChatColor.GOLD + NumberFormat.addCommaAndRound(wp.getMinuteStats().total().getHealing()));
        TextComponent absorb = new TextComponent(ChatColor.WHITE + "Absorbed: " + ChatColor.GOLD + NumberFormat.addCommaAndRound(wp.getMinuteStats().total().getAbsorbed()));
        damage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(wp.getStatString("Damage")).create()));
        heal.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(wp.getStatString("Healing")).create()));
        absorb.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(wp.getStatString("Absorbed")).create()));
        ChatUtils.sendCenteredMessageWithEvents(player, Arrays.asList(damage, ChatUtils.SPACER, heal, ChatUtils.SPACER, absorb));
        player.setGameMode(GameMode.ADVENTURE);
        player.setAllowFlight(true);
        if (!game.getAddons().contains(GameAddon.IMPOSTER_MODE)) {
            if (winEvent == null || winEvent.getDeclaredWinner() == null) {
                player.playSound(player.getLocation(), "defeat", 500, 1);
                PacketUtils.sendTitle(player, "§d§lDRAW", "", 0, 100, 0);
            } else if (wp.getTeam() == winEvent.getDeclaredWinner()) {
                player.playSound(player.getLocation(), "victory", 500, 1);
                PacketUtils.sendTitle(player, "§6§lVICTORY!", "", 0, 100, 0);
            } else {
                player.playSound(player.getLocation(), "defeat", 500, 1);
                PacketUtils.sendTitle(player, "§c§lDEFEAT", "", 0, 100, 0);
            }
        }
    }
    if (game.playersCount() >= 12 && previousGames.get(previousGames.size() - 1).isCounted()) {
        sendMessageToAllGamePlayer(game, "", false);
        sendMessageToAllGamePlayer(game, ChatColor.YELLOW.toString() + ChatColor.BOLD + "✚ EXPERIENCE SUMMARY ✚", true);
        for (WarlordsPlayer wp : PlayerFilter.playingGame(game)) {
            Player player = Bukkit.getPlayer(wp.getUuid());
            if (player == null)
                continue;
            LinkedHashMap<String, Long> expSummary = ExperienceManager.getExpFromGameStats(wp, false);
            long experienceEarnedUniversal = expSummary.values().stream().mapToLong(Long::longValue).sum();
            long experienceEarnedSpec = ExperienceManager.getSpecExpFromSummary(expSummary);
            long experienceOnSpec = ExperienceManager.getExperienceForSpec(wp.getUuid(), wp.getSpecClass());
            long experienceUniversal = ExperienceManager.getUniversalLevel(wp.getUuid());
            StringBuilder specExpSummary = new StringBuilder();
            StringBuilder universalExpSummary = new StringBuilder();
            expSummary.forEach((s, aLong) -> {
                if (!s.equals("First Game of the Day") && !s.equals("Second Game of the Day") && !s.equals("Third Game of the Day")) {
                    specExpSummary.append(ChatColor.AQUA).append(s).append(ChatColor.WHITE).append(": ").append(ChatColor.DARK_GRAY).append("+").append(ChatColor.DARK_GREEN).append(aLong).append("\n");
                }
                universalExpSummary.append(ChatColor.AQUA).append(s).append(ChatColor.WHITE).append(": ").append(ChatColor.DARK_GRAY).append("+").append(ChatColor.DARK_GREEN).append(aLong).append("\n");
            });
            specExpSummary.setLength(specExpSummary.length() - 1);
            universalExpSummary.setLength(universalExpSummary.length() - 1);
            TextComponent classSpecExp = new TextComponent(ChatColor.GRAY + "+" + ChatColor.DARK_GREEN + NumberFormat.addCommaAndRound(experienceEarnedSpec) + " " + ChatColor.GOLD + wp.getSpec().getClassName() + " Experience " + ChatColor.GRAY + "(" + wp.getSpecClass().specType.chatColor + wp.getSpecClass().name + ChatColor.GRAY + ")");
            classSpecExp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(specExpSummary.toString()).create()));
            ChatUtils.sendCenteredMessageWithEvents(player, Collections.singletonList(classSpecExp));
            ExperienceManager.giveLevelUpMessage(player, experienceOnSpec, experienceOnSpec + experienceEarnedSpec);
            TextComponent universalExp = new TextComponent(ChatColor.GRAY + "+" + ChatColor.DARK_AQUA + NumberFormat.addCommaAndRound(experienceEarnedUniversal) + " " + ChatColor.GOLD + "Universal Experience ");
            universalExp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(universalExpSummary.toString()).create()));
            ChatUtils.sendCenteredMessageWithEvents(player, Collections.singletonList(universalExp));
            ExperienceManager.giveLevelUpMessage(player, experienceUniversal, experienceUniversal + experienceEarnedUniversal);
        }
    }
    sendMessageToAllGamePlayer(game, "" + ChatColor.GREEN + ChatColor.BOLD + "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬", false);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) GameAddon(com.ebicep.warlords.game.GameAddon) java.util(java.util) PacketUtils(com.ebicep.warlords.util.bukkit.PacketUtils) Team(com.ebicep.warlords.game.Team) DatabaseGameBase.previousGames(com.ebicep.warlords.database.repositories.games.pojos.DatabaseGameBase.previousGames) Player(org.bukkit.entity.Player) ChatUtils(com.ebicep.warlords.util.chat.ChatUtils) NumberFormat(com.ebicep.warlords.util.java.NumberFormat) Collectors(java.util.stream.Collectors) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) WarlordsGameTriggerWinEvent(com.ebicep.warlords.events.WarlordsGameTriggerWinEvent) TextComponent(net.md_5.bungee.api.chat.TextComponent) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder) GameMode(org.bukkit.GameMode) Game(com.ebicep.warlords.game.Game) ExperienceManager(com.ebicep.warlords.player.ExperienceManager) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) ChatColor(org.bukkit.ChatColor) Option(com.ebicep.warlords.game.option.Option) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) Bukkit(org.bukkit.Bukkit) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) Player(org.bukkit.entity.Player) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) Option(com.ebicep.warlords.game.option.Option) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 4 with Option

use of com.ebicep.warlords.game.option.Option in project Warlords by ebicep.

the class PreLobbyState method begin.

@Override
public void begin() {
    this.maxTimer = game.getMap().getLobbyCountdown();
    this.resetTimer();
    game.setAcceptsPlayers(true);
    game.setAcceptsSpectators(false);
    for (Option option : game.getOptions()) {
        if (option instanceof PreGameItemOption) {
            PreGameItemOption preGameItemOption = (PreGameItemOption) option;
            items[preGameItemOption.getSlot()] = preGameItemOption;
        }
    }
}
Also used : PreGameItemOption(com.ebicep.warlords.game.option.PreGameItemOption) Option(com.ebicep.warlords.game.option.Option) PreGameItemOption(com.ebicep.warlords.game.option.PreGameItemOption)

Example 5 with Option

use of com.ebicep.warlords.game.option.Option in project Warlords by ebicep.

the class DebugMenuGameOptions method openTimerSetMenu.

public static void openTimerSetMenu(Player player, Game game, int minutes, int seconds) {
    Menu menu = new Menu("Timer", 9 * 6);
    if (seconds >= 60) {
        int min = seconds / 60;
        minutes += min;
        seconds = seconds % 60;
    }
    menu.setItem(4, 0, new ItemBuilder(Material.SIGN).name(ChatColor.GREEN.toString() + minutes + ":" + seconds).get(), (m, e) -> {
    });
    int finalMinutes = minutes;
    int finalSeconds = seconds;
    // MINUTES
    menu.setItem(1, 2, new ItemBuilder(Material.REDSTONE_BLOCK).name(ChatColor.GREEN + "Minutes - " + minutes).lore(ChatColor.YELLOW + "Left-Click to ADD" + "\n" + "Right-Click to SUBTRACT").get(), (m, e) -> {
    });
    menu.setItem(2, 2, new ItemBuilder(Material.LEVER).name(ChatColor.GREEN + "1").get(), (m, e) -> openTimerSetMenu(player, game, finalMinutes + (e.isLeftClick() ? 1 : -1), finalSeconds));
    menu.setItem(3, 2, new ItemBuilder(Material.LEVER).name(ChatColor.GREEN + "5").get(), (m, e) -> openTimerSetMenu(player, game, finalMinutes + (e.isLeftClick() ? 5 : -5), finalSeconds));
    // SECONDS
    menu.setItem(1, 3, new ItemBuilder(Material.REDSTONE).name(ChatColor.GREEN + "Seconds - " + seconds).lore(ChatColor.YELLOW + "Left-Click to ADD" + "\n" + "Right-Click to SUBTRACT").get(), (m, e) -> {
    });
    menu.setItem(2, 3, new ItemBuilder(Material.LEVER).name(ChatColor.GREEN + "1").get(), (m, e) -> openTimerSetMenu(player, game, finalMinutes, finalSeconds + (e.isLeftClick() ? 1 : -1)));
    menu.setItem(3, 3, new ItemBuilder(Material.LEVER).name(ChatColor.GREEN + "5").get(), (m, e) -> openTimerSetMenu(player, game, finalMinutes, finalSeconds + (e.isLeftClick() ? 5 : -5)));
    menu.setItem(4, 3, new ItemBuilder(Material.LEVER).name(ChatColor.GREEN + "10").get(), (m, e) -> openTimerSetMenu(player, game, finalMinutes, finalSeconds + (e.isLeftClick() ? 10 : -10)));
    menu.setItem(5, 3, new ItemBuilder(Material.LEVER).name(ChatColor.GREEN + "15").get(), (m, e) -> openTimerSetMenu(player, game, finalMinutes, finalSeconds + (e.isLeftClick() ? 15 : -15)));
    menu.setItem(6, 3, new ItemBuilder(Material.LEVER).name(ChatColor.GREEN + "30").get(), (m, e) -> openTimerSetMenu(player, game, finalMinutes, finalSeconds + (e.isLeftClick() ? 30 : -30)));
    menu.setItem(3, 5, MENU_BACK, (m, e) -> openTimerMenu(player, game));
    menu.setItem(4, 5, MENU_CLOSE, ACTION_CLOSE_MENU);
    menu.setItem(5, 5, new ItemBuilder(Material.WOOL, 1, (byte) 5).name(ChatColor.GREEN + "Set Time - " + minutes + ":" + seconds).get(), (m, e) -> {
        for (Option option : game.getOptions()) {
            if (option instanceof WinAfterTimeoutOption) {
                ((WinAfterTimeoutOption) option).setTimeRemaining(finalMinutes * 60 + finalSeconds);
                openTimerSetMenu(player, game, finalMinutes, finalSeconds);
                break;
            }
        }
    });
    menu.openForPlayer(player);
}
Also used : ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) WinAfterTimeoutOption(com.ebicep.warlords.game.option.WinAfterTimeoutOption) WinAfterTimeoutOption(com.ebicep.warlords.game.option.WinAfterTimeoutOption) Option(com.ebicep.warlords.game.option.Option) Menu(com.ebicep.warlords.menu.Menu)

Aggregations

Option (com.ebicep.warlords.game.option.Option)7 WarlordsGameTriggerWinEvent (com.ebicep.warlords.events.WarlordsGameTriggerWinEvent)2 Game (com.ebicep.warlords.game.Game)2 GameAddon (com.ebicep.warlords.game.GameAddon)2 Team (com.ebicep.warlords.game.Team)2 WinAfterTimeoutOption (com.ebicep.warlords.game.option.WinAfterTimeoutOption)2 Menu (com.ebicep.warlords.menu.Menu)2 ExperienceManager (com.ebicep.warlords.player.ExperienceManager)2 WarlordsPlayer (com.ebicep.warlords.player.WarlordsPlayer)2 ItemBuilder (com.ebicep.warlords.util.bukkit.ItemBuilder)2 GameRunnable (com.ebicep.warlords.util.warlords.GameRunnable)2 PlayerFilter (com.ebicep.warlords.util.warlords.PlayerFilter)2 Nonnull (javax.annotation.Nonnull)2 Nullable (javax.annotation.Nullable)2 ChatColor (org.bukkit.ChatColor)2 GameMode (org.bukkit.GameMode)2 Player (org.bukkit.entity.Player)2 BotManager (com.ebicep.jda.BotManager)1 Warlords (com.ebicep.warlords.Warlords)1 RecordGamesCommand (com.ebicep.warlords.commands.debugcommands.RecordGamesCommand)1