Search in sources :

Example 1 with WinAfterTimeoutOption

use of com.ebicep.warlords.game.option.WinAfterTimeoutOption 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)

Example 2 with WinAfterTimeoutOption

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

the class DebugMenuGameOptions method openTimerMenu.

public static void openTimerMenu(Player player, Game game) {
    TimerDebugAble timerDebugAble = (TimerDebugAble) game.getState();
    Menu menu = new Menu("Timer", 9 * 4);
    menu.setItem(2, 1, new ItemBuilder(Material.WOOD_BUTTON).name(ChatColor.GREEN + "Reset").get(), (m, e) -> timerDebugAble.resetTimer());
    menu.setItem(4, 1, new ItemBuilder(Material.STONE_BUTTON).name(ChatColor.GREEN + "Skip").get(), (m, e) -> timerDebugAble.skipTimer());
    menu.setItem(6, 1, new ItemBuilder(Material.WATCH).name(ChatColor.GREEN + "Set").get(), (m, e) -> {
        for (Option option : game.getOptions()) {
            if (option instanceof WinAfterTimeoutOption) {
                int timeLeft = ((WinAfterTimeoutOption) option).getTimeRemaining();
                openTimerSetMenu(player, game, timeLeft / 60, timeLeft % 60);
                break;
            }
        }
    });
    menu.setItem(3, 3, MENU_BACK, (m, e) -> openGameEditorMenu(player, game));
    menu.setItem(4, 3, MENU_CLOSE, ACTION_CLOSE_MENU);
    menu.openForPlayer(player);
}
Also used : ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) WinAfterTimeoutOption(com.ebicep.warlords.game.option.WinAfterTimeoutOption) TimerDebugAble(com.ebicep.warlords.game.state.TimerDebugAble) 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)2 WinAfterTimeoutOption (com.ebicep.warlords.game.option.WinAfterTimeoutOption)2 Menu (com.ebicep.warlords.menu.Menu)2 ItemBuilder (com.ebicep.warlords.util.bukkit.ItemBuilder)2 TimerDebugAble (com.ebicep.warlords.game.state.TimerDebugAble)1