Search in sources :

Example 1 with Game

use of com.ebicep.warlords.game.Game in project Warlords by ebicep.

the class BotManager method sendStatusMessage.

public static void sendStatusMessage(boolean onQuit) {
    if (!Warlords.serverIP.equals("51.81.49.127")) {
        return;
    }
    DateFormat dateFormat = new SimpleDateFormat("hh:mm aa");
    dateFormat.setTimeZone(TimeZone.getTimeZone("EST"));
    EmbedBuilder eb = new EmbedBuilder().setTitle("Server Status", null).setColor(3066993).setFooter(dateFormat.format(new Date()) + " EST");
    eb.setDescription("**Players Online**: " + (onQuit ? Bukkit.getOnlinePlayers().size() - 1 : Bukkit.getOnlinePlayers().size()) + "\n");
    eb.appendDescription("**Players In Game**: " + Warlords.getGameManager().getPlayerCount() + "\n");
    eb.appendDescription("**Players Waiting in lobby**: " + Warlords.getGameManager().getPlayerCountInLobby() + "\n");
    for (GameHolder holder : Warlords.getGameManager().getGames()) {
        Game game = holder.getGame();
        if (game == null) {
            eb.appendDescription("**Game**: " + holder.getMap().getMapName() + " Inactive\n");
        } else {
            if (game.getState() instanceof PreLobbyState) {
                PreLobbyState state = (PreLobbyState) game.getState();
                if (!state.hasEnoughPlayers()) {
                    eb.appendDescription("**Game**: " + game.getMap().getMapName() + " Lobby - Waiting for players" + "\n");
                } else {
                    eb.appendDescription("**Game**: " + game.getMap().getMapName() + " Lobby - " + state.getTimeLeftString() + " Left" + "\n");
                }
            } else if (game.getState() instanceof PlayingState) {
                OptionalInt timeLeft = WinAfterTimeoutOption.getTimeLeft(game);
                String time = Utils.formatTimeLeft(timeLeft.isPresent() ? timeLeft.getAsInt() : (System.currentTimeMillis() - game.createdAt()) / 1000);
                String word = timeLeft.isPresent() ? " Left" : " Elapsed";
                eb.appendDescription("**Game**: " + game.getMap().getMapName() + " - " + time + word + " - " + game.getPoints(Team.BLUE) + ":" + game.getPoints(Team.RED) + "\n");
            } else {
                eb.appendDescription("**Game**: Ending" + "\n");
            }
        }
    }
    StringBuilder stringBuilder = new StringBuilder("**Parties**: ");
    Warlords.partyManager.getParties().forEach(party -> stringBuilder.append(party.getLeaderName()).append(" (").append(party.getPartyPlayers().size()).append("), "));
    stringBuilder.setLength(stringBuilder.length() - 1);
    eb.appendDescription(stringBuilder);
    MessageEmbed messageEmbed = eb.build();
    getTextChannelCompsByName(compGamesServerStatusChannel).ifPresent(textChannel -> {
        if (compStatusMessage == null) {
            textChannel.sendMessageEmbeds(messageEmbed).queue(m -> compStatusMessage = m);
        } else if (textChannel.getLatestMessageId().equals(compStatusMessage.getId())) {
            compStatusMessage.editMessageEmbeds(messageEmbed).queue();
        } else {
            compStatusMessage.delete().queue();
            textChannel.sendMessageEmbeds(messageEmbed).queue(m -> compStatusMessage = m);
        }
    });
    getTextChannelWL2ByName(wl2ServerStatusChannel).ifPresent(textChannel -> {
        if (wl2StatusMessage == null) {
            textChannel.sendMessageEmbeds(messageEmbed).queue(m -> wl2StatusMessage = m);
        } else if (textChannel.getLatestMessageId().equals(wl2StatusMessage.getId())) {
            wl2StatusMessage.editMessageEmbeds(messageEmbed).queue();
        } else {
            wl2StatusMessage.delete().queue();
            textChannel.sendMessageEmbeds(messageEmbed).queue(m -> wl2StatusMessage = m);
        }
    });
}
Also used : Message(net.dv8tion.jda.api.entities.Message) LoginException(javax.security.auth.login.LoginException) Utils(com.ebicep.warlords.util.warlords.Utils) java.util(java.util) JDA(net.dv8tion.jda.api.JDA) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Team(com.ebicep.warlords.game.Team) PlayingState(com.ebicep.warlords.game.state.PlayingState) WinAfterTimeoutOption(com.ebicep.warlords.game.option.WinAfterTimeoutOption) SimpleDateFormat(java.text.SimpleDateFormat) Warlords(com.ebicep.warlords.Warlords) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) TextChannel(net.dv8tion.jda.api.entities.TextChannel) GatewayIntent(net.dv8tion.jda.api.requests.GatewayIntent) Guild(net.dv8tion.jda.api.entities.Guild) Game(com.ebicep.warlords.game.Game) PreLobbyState(com.ebicep.warlords.game.state.PreLobbyState) JDABuilder(net.dv8tion.jda.api.JDABuilder) GameHolder(com.ebicep.warlords.game.GameManager.GameHolder) BukkitTask(org.bukkit.scheduler.BukkitTask) MessageEmbed(net.dv8tion.jda.api.entities.MessageEmbed) DateFormat(java.text.DateFormat) Bukkit(org.bukkit.Bukkit) MessageEmbed(net.dv8tion.jda.api.entities.MessageEmbed) PreLobbyState(com.ebicep.warlords.game.state.PreLobbyState) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) GameHolder(com.ebicep.warlords.game.GameManager.GameHolder) Game(com.ebicep.warlords.game.Game) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) PlayingState(com.ebicep.warlords.game.state.PlayingState) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with Game

use of com.ebicep.warlords.game.Game in project Warlords by ebicep.

the class GameListCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
    if (!sender.hasPermission("warlords.game.list")) {
        sender.sendMessage("§cYou do not have permission to do that.");
        return true;
    }
    for (GameHolder holder : Warlords.getGameManager().getGames()) {
        StringBuilder message = new StringBuilder();
        message.append(ChatColor.GRAY).append("[").append(ChatColor.AQUA).append(holder.getName()).append(ChatColor.GRAY).append("|").append(ChatColor.AQUA).append(toTitleHumanCase(holder.getMap().name()));
        Game game = holder.getGame();
        if (game == null) {
            message.append(']').append(ChatColor.GOLD).append(" <inactive>");
        } else {
            if (holder.getMap().getCategories().size() > 1) {
                message.append(ChatColor.GRAY).append("/").append(ChatColor.AQUA).append(toTitleHumanCase(game.getGameMode()));
            }
            message.append(ChatColor.GRAY).append("] ");
            // message.append('(').append(ChatColor.GOLD).append(game.getGameId()).append(ChatColor.GRAY).append(") ");
            EnumSet<GameAddon> addons = game.getAddons();
            if (!addons.isEmpty()) {
                message.append(ChatColor.GRAY).append('(');
                for (GameAddon addon : addons) {
                    message.append(ChatColor.GREEN).append(addon.name());
                    message.append(ChatColor.GRAY).append(',');
                }
                message.setLength(message.length() - 1);
                message.append("] ");
            }
            message.append(ChatColor.GOLD).append(game.getState().getClass().getSimpleName()).append(ChatColor.GRAY).append(" [ ").append(ChatColor.GREEN).append(game.getPlayers().size()).append(ChatColor.GRAY).append("/").append(ChatColor.GREEN).append(game.getMinPlayers()).append(ChatColor.GRAY).append("..").append(ChatColor.GREEN).append(game.getMaxPlayers()).append(ChatColor.GRAY).append("] ");
            OptionalInt timeLeft = WinAfterTimeoutOption.getTimeLeft(game);
            String time = Utils.formatTimeLeft(timeLeft.isPresent() ? timeLeft.getAsInt() : (System.currentTimeMillis() - game.createdAt()) / 1000);
            String word = timeLeft.isPresent() ? " Left" : " Elapsed";
            message.append(time).append(word);
        }
        sender.sendMessage(message.toString());
    }
    return true;
}
Also used : GameHolder(com.ebicep.warlords.game.GameManager.GameHolder) Game(com.ebicep.warlords.game.Game) OptionalInt(java.util.OptionalInt) GameAddon(com.ebicep.warlords.game.GameAddon)

Example 3 with Game

use of com.ebicep.warlords.game.Game in project Warlords by ebicep.

the class SpectateCommand method openSpectateMenu.

public static void openSpectateMenu(Player player) {
    Menu menu = new Menu("Current Games", 9 * 3);
    int column = 0;
    int row = 0;
    for (GameHolder holder : Warlords.getGameManager().getGames()) {
        Game game = holder.getGame();
        if (game != null && game.acceptsSpectators()) {
            menu.setItem(column, row, new ItemBuilder(Material.BOOK).name(ChatColor.GREEN + "Game " + game.getGameId()).lore(ChatColor.DARK_GRAY + "Map - " + ChatColor.RED + game.getMap().getMapName(), ChatColor.DARK_GRAY + "GameMode - " + ChatColor.RED + game.getGameMode(), ChatColor.DARK_GRAY + "Addons - " + ChatColor.RED + game.getAddons(), ChatColor.DARK_GRAY + "Players - " + ChatColor.RED + game.playersCount()).get(), (m, e) -> {
                if (game.isClosed()) {
                    player.sendMessage(ChatColor.RED + "This game is no longer running");
                    openSpectateMenu(player);
                    return;
                }
                if (!game.acceptsSpectators()) {
                    player.sendMessage(ChatColor.RED + "This game does not accepts spectators");
                    openSpectateMenu(player);
                    return;
                }
                Optional<Game> currentGame = Warlords.getGameManager().getPlayerGame(player.getUniqueId());
                if (currentGame.isPresent() && currentGame.get().getPlayerTeam(player.getUniqueId()) != null) {
                    player.sendMessage(ChatColor.RED + "You cannot use this command inside a game!");
                } else if (currentGame.isPresent() && currentGame.get().equals(game)) {
                    player.sendMessage(ChatColor.RED + "You are already spectating this game");
                } else {
                    if (currentGame.isPresent()) {
                        currentGame.get().removePlayer(player.getUniqueId());
                    }
                    game.addPlayer(player, true);
                }
            });
            column++;
            if (column > 8) {
                column = 0;
                row++;
            }
        }
    }
    Optional<Game> currentGame = Warlords.getGameManager().getPlayerGame(player.getUniqueId());
    if (currentGame.isPresent()) {
        menu.setItem(4, 2, new ItemBuilder(Material.BARRIER).name(ChatColor.GREEN + "Return to the lobby").get(), (m, e) -> {
            Optional<Game> currentGame1 = Warlords.getGameManager().getPlayerGame(player.getUniqueId());
            if (currentGame1.isPresent() && currentGame1.get().getPlayerTeam(player.getUniqueId()) != null) {
                player.sendMessage(ChatColor.RED + "You cannot use this command inside a game!");
            } else {
                currentGame1.get().removePlayer(player.getUniqueId());
            }
        });
    }
    menu.openForPlayer(player);
}
Also used : ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) GameHolder(com.ebicep.warlords.game.GameManager.GameHolder) Game(com.ebicep.warlords.game.Game) Menu(com.ebicep.warlords.menu.Menu)

Example 4 with Game

use of com.ebicep.warlords.game.Game in project Warlords by ebicep.

the class DatabaseGameCTF method createHolograms.

@Override
public void createHolograms() {
    List<Hologram> holograms = new ArrayList<>();
    // readding game holograms
    Hologram lastGameStats = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.lastGameStatsLocation);
    holograms.add(lastGameStats);
    lastGameStats.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Last " + (isPrivate() ? "Comp" : "Pub") + " Game Stats");
    Hologram topDamage = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.topDamageLocation);
    holograms.add(topDamage);
    topDamage.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Top Damage");
    Hologram topHealing = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.topHealingLocation);
    holograms.add(topHealing);
    topHealing.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Top Healing");
    Hologram topAbsorbed = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.topAbsorbedLocation);
    holograms.add(topAbsorbed);
    topAbsorbed.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Top Absorbed");
    Hologram topDHPPerMinute = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.topDHPPerMinuteLocation);
    holograms.add(topDHPPerMinute);
    topDHPPerMinute.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Top DHP per Minute");
    Hologram topDamageOnCarrier = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.topDamageOnCarrierLocation);
    holograms.add(topDamageOnCarrier);
    topDamageOnCarrier.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Top Damage On Carrier");
    Hologram topHealingOnCarrier = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.topHealingOnCarrierLocation);
    holograms.add(topHealingOnCarrier);
    topHealingOnCarrier.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Top Healing On Carrier");
    // last game stats
    int minutes = (15 - (int) Math.round(timeLeft / 60.0)) == 0 ? 1 : 15 - (int) Math.round(timeLeft / 60.0);
    lastGameStats.getLines().appendText(ChatColor.GRAY + date);
    lastGameStats.getLines().appendText(ChatColor.GREEN + map.getMapName() + ChatColor.GRAY + "  -  " + ChatColor.GREEN + timeLeft / 60 + ":" + timeLeft % 60 + (timeLeft % 60 < 10 ? "0" : ""));
    lastGameStats.getLines().appendText(ChatColor.BLUE.toString() + bluePoints + ChatColor.GRAY + "  -  " + ChatColor.RED + redPoints);
    List<DatabaseGamePlayersCTF.DatabaseGamePlayerCTF> bluePlayers = players.blue;
    List<DatabaseGamePlayersCTF.DatabaseGamePlayerCTF> redPlayers = players.red;
    List<DatabaseGamePlayersCTF.DatabaseGamePlayerCTF> allPlayers = new ArrayList<>();
    allPlayers.addAll(bluePlayers);
    allPlayers.addAll(redPlayers);
    List<String> players = new ArrayList<>();
    for (String s : Utils.specsOrdered) {
        StringBuilder playerSpecs = new StringBuilder(ChatColor.AQUA + s).append(": ");
        final boolean[] add = { false };
        allPlayers.stream().filter(o -> o.getSpec().name.equalsIgnoreCase(s)).forEach(p -> {
            playerSpecs.append(bluePlayers.contains(p) ? ChatColor.BLUE : ChatColor.RED).append(p.getName()).append(p.getKDAString()).append(ChatColor.GRAY).append(", ");
            add[0] = true;
        });
        if (add[0]) {
            playerSpecs.setLength(playerSpecs.length() - 2);
            players.add(playerSpecs.toString());
        }
    }
    players.forEach(s -> lastGameStats.getLines().appendText(s));
    // top dmg/healing/absorbed + dhp per game + dmg/heal on carrier
    List<String> topDamagePlayers = new ArrayList<>();
    List<String> topHealingPlayers = new ArrayList<>();
    List<String> topAbsorbedPlayers = new ArrayList<>();
    List<String> topDHPPerGamePlayers = new ArrayList<>();
    List<String> topDamageOnCarrierPlayers = new ArrayList<>();
    List<String> topHealingOnCarrierPlayers = new ArrayList<>();
    Map<ChatColor, Long> totalDamage = new HashMap<>();
    Map<ChatColor, Long> totalHealing = new HashMap<>();
    Map<ChatColor, Long> totalAbsorbed = new HashMap<>();
    allPlayers.stream().sorted(Comparator.comparingLong(DatabaseGamePlayersCTF.DatabaseGamePlayerCTF::getTotalDamage).reversed()).forEach(databaseGamePlayer -> {
        totalDamage.put(bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED, totalDamage.getOrDefault(bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED, 0L) + databaseGamePlayer.getTotalDamage());
        topDamagePlayers.add((bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED) + databaseGamePlayer.getName() + ": " + ChatColor.YELLOW + NumberFormat.addCommaAndRound(databaseGamePlayer.getTotalDamage()));
    });
    allPlayers.stream().sorted(Comparator.comparingLong(DatabaseGamePlayersCTF.DatabaseGamePlayerCTF::getTotalHealing).reversed()).forEach(databaseGamePlayer -> {
        totalHealing.put(bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED, totalHealing.getOrDefault(bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED, 0L) + databaseGamePlayer.getTotalHealing());
        topHealingPlayers.add((bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED) + databaseGamePlayer.getName() + ": " + ChatColor.YELLOW + NumberFormat.addCommaAndRound(databaseGamePlayer.getTotalHealing()));
    });
    allPlayers.stream().sorted(Comparator.comparingLong(DatabaseGamePlayersCTF.DatabaseGamePlayerCTF::getTotalAbsorbed).reversed()).forEach(databaseGamePlayer -> {
        totalAbsorbed.put(bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED, totalAbsorbed.getOrDefault(bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED, 0L) + databaseGamePlayer.getTotalAbsorbed());
        topAbsorbedPlayers.add((bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED) + databaseGamePlayer.getName() + ": " + ChatColor.YELLOW + NumberFormat.addCommaAndRound(databaseGamePlayer.getTotalAbsorbed()));
    });
    allPlayers.stream().sorted((o1, o2) -> {
        Long p1DHPPerGame = o1.getTotalDHP() / minutes;
        Long p2DHPPerGame = o2.getTotalDHP() / minutes;
        return p2DHPPerGame.compareTo(p1DHPPerGame);
    }).forEach(databaseGamePlayer -> {
        topDHPPerGamePlayers.add((bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED) + databaseGamePlayer.getName() + ": " + ChatColor.YELLOW + NumberFormat.addCommaAndRound(databaseGamePlayer.getTotalDHP() / minutes));
    });
    allPlayers.stream().sorted(Comparator.comparingLong(DatabaseGamePlayersCTF.DatabaseGamePlayerCTF::getTotalDamageOnCarrier).reversed()).forEach(databaseGamePlayer -> {
        topDamageOnCarrierPlayers.add((bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED) + databaseGamePlayer.getName() + ": " + ChatColor.YELLOW + NumberFormat.addCommaAndRound(databaseGamePlayer.getTotalDamageOnCarrier()));
    });
    allPlayers.stream().sorted(Comparator.comparingLong(DatabaseGamePlayersCTF.DatabaseGamePlayerCTF::getTotalHealingOnCarrier).reversed()).forEach(databaseGamePlayer -> {
        topHealingOnCarrierPlayers.add((bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED) + databaseGamePlayer.getName() + ": " + ChatColor.YELLOW + NumberFormat.addCommaAndRound(databaseGamePlayer.getTotalHealingOnCarrier()));
    });
    appendTeamDHP(topDamage, totalDamage);
    appendTeamDHP(topHealing, totalHealing);
    appendTeamDHP(topAbsorbed, totalAbsorbed);
    topDamagePlayers.forEach(s -> topDamage.getLines().appendText(s));
    topHealingPlayers.forEach(s -> topHealing.getLines().appendText(s));
    topAbsorbedPlayers.forEach(s -> topAbsorbed.getLines().appendText(s));
    topDHPPerGamePlayers.forEach(s -> topDHPPerMinute.getLines().appendText(s));
    topDamageOnCarrierPlayers.forEach(s -> topDamageOnCarrier.getLines().appendText(s));
    topHealingOnCarrierPlayers.forEach(s -> topHealingOnCarrier.getLines().appendText(s));
    // setting visibility to none
    holograms.forEach(hologram -> {
        hologram.getVisibilitySettings().setGlobalVisibility(VisibilitySettings.Visibility.HIDDEN);
    });
    this.holograms = holograms;
}
Also used : BotManager(com.ebicep.jda.BotManager) Utils(com.ebicep.warlords.util.warlords.Utils) GameAddon(com.ebicep.warlords.game.GameAddon) java.util(java.util) Team(com.ebicep.warlords.game.Team) WinAfterTimeoutOption(com.ebicep.warlords.game.option.WinAfterTimeoutOption) Warlords(com.ebicep.warlords.Warlords) Hologram(me.filoghost.holographicdisplays.api.beta.hologram.Hologram) DatabaseGamePlayerResult(com.ebicep.warlords.database.repositories.games.pojos.DatabaseGamePlayerResult) DatabaseGameBase(com.ebicep.warlords.database.repositories.games.pojos.DatabaseGameBase) NumberFormat(com.ebicep.warlords.util.java.NumberFormat) VisibilitySettings(me.filoghost.holographicdisplays.api.beta.hologram.VisibilitySettings) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) Document(org.springframework.data.mongodb.core.mapping.Document) Field(org.springframework.data.mongodb.core.mapping.Field) WarlordsGameTriggerWinEvent(com.ebicep.warlords.events.WarlordsGameTriggerWinEvent) Game(com.ebicep.warlords.game.Game) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) HolographicDisplaysAPI(me.filoghost.holographicdisplays.api.beta.HolographicDisplaysAPI) DatabaseGamePlayerBase(com.ebicep.warlords.database.repositories.games.pojos.DatabaseGamePlayerBase) ChatColor(org.bukkit.ChatColor) Transient(org.springframework.data.annotation.Transient) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) Hologram(me.filoghost.holographicdisplays.api.beta.hologram.Hologram) ChatColor(org.bukkit.ChatColor)

Example 5 with Game

use of com.ebicep.warlords.game.Game in project Warlords by ebicep.

the class GameFreezeWhenOfflineOption method start.

@Override
public void start(Game game) {
    new GameRunnable(game, true) {

        @Override
        public void run() {
            boolean anyOffline = game.offlinePlayersWithoutSpectators().anyMatch(e -> !e.getKey().isOnline());
            if (isFrozen) {
                if (anyOffline) {
                    timer = 0;
                } else if (timer >= UNFREEZE_TIME) {
                    game.removeFrozenCause(FROZEN_MESSAGE);
                    isFrozen = false;
                    timer = 0;
                } else {
                    game.forEachOnlinePlayerWithoutSpectators((p, team) -> {
                        PacketUtils.sendTitle(p, ChatColor.BLUE + "Resuming in... " + ChatColor.GREEN + (UNFREEZE_TIME - timer), "", 0, 40, 0);
                    });
                    timer++;
                }
            } else {
                if (!anyOffline) {
                    timer = 0;
                } else if (timer >= FREEZE_TIME) {
                    game.addFrozenCause(FROZEN_MESSAGE);
                    isFrozen = true;
                    timer = 0;
                } else {
                    timer++;
                }
            }
        }
    }.runTaskTimer(0, 20);
}
Also used : GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Game(com.ebicep.warlords.game.Game) PacketUtils(com.ebicep.warlords.util.bukkit.PacketUtils) ChatColor(org.bukkit.ChatColor) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable)

Aggregations

Game (com.ebicep.warlords.game.Game)25 Team (com.ebicep.warlords.game.Team)15 ChatColor (org.bukkit.ChatColor)13 Warlords (com.ebicep.warlords.Warlords)12 WarlordsPlayer (com.ebicep.warlords.player.WarlordsPlayer)12 Nonnull (javax.annotation.Nonnull)12 Nullable (javax.annotation.Nullable)12 Player (org.bukkit.entity.Player)11 GameRunnable (com.ebicep.warlords.util.warlords.GameRunnable)9 java.util (java.util)8 GameAddon (com.ebicep.warlords.game.GameAddon)7 Utils (com.ebicep.warlords.util.warlords.Utils)7 ScoreboardHandler (com.ebicep.warlords.game.option.marker.scoreboard.ScoreboardHandler)6 PacketUtils (com.ebicep.warlords.util.bukkit.PacketUtils)6 PlayerFilter (com.ebicep.warlords.util.warlords.PlayerFilter)6 Location (org.bukkit.Location)6 WarlordsGameTriggerWinEvent (com.ebicep.warlords.events.WarlordsGameTriggerWinEvent)5 GameHolder (com.ebicep.warlords.game.GameManager.GameHolder)5 SimpleScoreboardHandler (com.ebicep.warlords.game.option.marker.scoreboard.SimpleScoreboardHandler)5 PlayingState (com.ebicep.warlords.game.state.PlayingState)5