Search in sources :

Example 26 with WarlordsPlayer

use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.

the class ShoutCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
    WarlordsPlayer player = BaseCommand.requireWarlordsPlayer(sender);
    if (player != null) {
        // We only have a warlords player if the game is running
        StringBuilder message = new StringBuilder(player.getTeam().teamColor() + "[SHOUT] ");
        message.append(ChatColor.AQUA).append(sender.getName()).append(ChatColor.WHITE).append(": ");
        for (String arg : args) {
            message.append(arg).append(" ");
        }
        for (WarlordsPlayer p : PlayerFilter.playingGame(player.getGame())) {
            p.sendMessage(message.toString());
        }
    }
    return true;
}
Also used : WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer)

Example 27 with WarlordsPlayer

use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.

the class DatabaseGameCTF method getWarlordsPlusEndGameStats.

public static String getWarlordsPlusEndGameStats(Game game) {
    StringBuilder output = new StringBuilder("Winners:");
    int bluePoints = game.getPoints(Team.BLUE);
    int redPoints = game.getPoints(Team.RED);
    if (bluePoints > redPoints) {
        for (WarlordsPlayer player : PlayerFilter.playingGame(game).matchingTeam(Team.BLUE)) {
            output.append(player.getUuid().toString().replace("-", "")).append("[").append(player.getMinuteStats().total().getKills()).append(":").append(player.getMinuteStats().total().getDeaths()).append("],");
        }
        output.setLength(output.length() - 1);
        output.append("Losers:");
        for (WarlordsPlayer player : PlayerFilter.playingGame(game).matchingTeam(Team.RED)) {
            output.append(player.getUuid().toString().replace("-", "")).append("[").append(player.getMinuteStats().total().getKills()).append(":").append(player.getMinuteStats().total().getDeaths()).append("],");
        }
    } else if (redPoints > bluePoints) {
        for (WarlordsPlayer player : PlayerFilter.playingGame(game).matchingTeam(Team.RED)) {
            output.append(player.getUuid().toString().replace("-", "")).append("[").append(player.getMinuteStats().total().getKills()).append(":").append(player.getMinuteStats().total().getDeaths()).append("],");
        }
        output.setLength(output.length() - 1);
        output.append("Losers:");
        for (WarlordsPlayer player : PlayerFilter.playingGame(game).matchingTeam(Team.BLUE)) {
            output.append(player.getUuid().toString().replace("-", "")).append("[").append(player.getMinuteStats().total().getKills()).append(":").append(player.getMinuteStats().total().getDeaths()).append("],");
        }
    } else {
        output.setLength(0);
        for (WarlordsPlayer player : PlayerFilter.playingGame(game).matchingTeam(Team.BLUE)) {
            output.append(player.getUuid().toString().replace("-", "")).append("[").append(player.getMinuteStats().total().getKills()).append(":").append(player.getMinuteStats().total().getDeaths()).append("],");
        }
        for (WarlordsPlayer player : PlayerFilter.playingGame(game).matchingTeam(Team.RED)) {
            output.append(player.getUuid().toString().replace("-", "")).append("[").append(player.getMinuteStats().total().getKills()).append(":").append(player.getMinuteStats().total().getDeaths()).append("],");
        }
    }
    output.setLength(output.length() - 1);
    if (BotManager.numberOfMessagesSentLast30Sec > 15) {
        if (BotManager.numberOfMessagesSentLast30Sec < 20) {
            BotManager.getTextChannelCompsByName("games-backlog").ifPresent(textChannel -> textChannel.sendMessage("SOMETHING BROKEN DETECTED <@239929120035700737> <@253971614998331393>").queue());
        }
    } else {
        if (game.getAddons().contains(GameAddon.PRIVATE_GAME)) {
            BotManager.getTextChannelCompsByName("games-backlog").ifPresent(textChannel -> textChannel.sendMessage(output.toString()).queue());
        }
    }
    lastWarlordsPlusString = output.toString();
    return output.toString();
}
Also used : WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer)

Example 28 with WarlordsPlayer

use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.

the class BasicScoreboardOption method getDateScoreboard.

private static SimpleScoreboardHandler getDateScoreboard(Game game) {
    SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy - kk:mm");
    format.setTimeZone(TimeZone.getTimeZone("EST"));
    SimpleScoreboardHandler simpleScoreboardHandler = new SimpleScoreboardHandler(0, "date") {

        @Nonnull
        @Override
        public List<String> computeLines(@Nullable WarlordsPlayer player) {
            return Collections.singletonList(ChatColor.GRAY + format.format(new Date()));
        }
    };
    new GameRunnable(game) {

        @Override
        public void run() {
            simpleScoreboardHandler.markChanged();
        }
    }.runTaskTimer(GameRunnable.SECOND, GameRunnable.SECOND);
    return simpleScoreboardHandler;
}
Also used : WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) SimpleScoreboardHandler(com.ebicep.warlords.game.option.marker.scoreboard.SimpleScoreboardHandler) SimpleDateFormat(java.text.SimpleDateFormat) Nullable(javax.annotation.Nullable) Date(java.util.Date)

Example 29 with WarlordsPlayer

use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.

the class ImposterModeOption method sendPoll.

public void sendPoll(Team team) {
    poll = new GamePoll.Builder(game).setQuestion("Who is the most SUS on your team?").setTimeLeft(60).setOptions(game.offlinePlayersWithoutSpectators().filter(uuidTeamEntry -> uuidTeamEntry.getValue() == team).map(offlinePlayerTeamEntry -> offlinePlayerTeamEntry.getKey().getName()).collect(Collectors.toList())).setExcludedPlayers(game.offlinePlayersWithoutSpectators().filter(uuidTeamEntry -> uuidTeamEntry.getValue() != team).map(offlinePlayerTeamEntry -> offlinePlayerTeamEntry.getKey().getUniqueId()).collect(Collectors.toList())).setRunnableAfterPollEnded(p -> {
        int mostVotes = Collections.max(p.getOptionsWithVotes().entrySet(), Comparator.comparingInt(Map.Entry::getValue)).getValue();
        List<WarlordsPlayer> votedOut = p.getOptionsWithVotes().entrySet().stream().filter(stringIntegerEntry -> stringIntegerEntry.getValue() == mostVotes).map(Map.Entry::getKey).map(s -> game.warlordsPlayers().filter(warlordsPlayer -> warlordsPlayer.getName().equals(s)).findFirst().get()).collect(Collectors.toList());
        // If multiple top votes and one is imposter then voted wrong
        boolean votedCorrectly = votedOut.size() == 1 && imposters.get(team).stream().anyMatch(warlordsPlayer -> warlordsPlayer == votedOut.get(0));
        new GameRunnable(game, true) {

            int counter = 0;

            @Override
            public void run() {
                String title = "";
                String subtitle = "";
                switch(counter) {
                    case 0:
                    case 1:
                        title = team.teamColor + team.name + " voted...";
                        break;
                    case 2:
                    case 3:
                        if (votedCorrectly) {
                            title = ChatColor.GREEN + "Correctly!";
                        } else {
                            title = ChatColor.RED + "Incorrectly!";
                        }
                        subtitle = team.teamColor + imposters.get(team).get(0).getName() + ChatColor.YELLOW + " was the imposter";
                        break;
                }
                counter++;
                if (counter < 6) {
                    sendTitle(title, subtitle);
                } else if (counter == 6) {
                    game.onlinePlayersWithoutSpectators().forEach(playerTeamEntry -> {
                        Player player = playerTeamEntry.getKey();
                        player.removePotionEffect(PotionEffectType.BLINDNESS);
                        showWinLossMessage(team, player, votedCorrectly, playerTeamEntry.getValue() == team);
                    });
                } else if (counter == 9) {
                    game.removeFrozenCause(team.teamColor + team.name + ChatColor.GREEN + " is voting!");
                    int scoreNeededToEndGame = game.getOptions().stream().filter(e -> e instanceof WinByPointsOption).mapToInt(e -> ((WinByPointsOption) e).getPointLimit()).sorted().findFirst().orElse(Integer.MAX_VALUE);
                    if (votedCorrectly) {
                        game.setPoints(team, scoreNeededToEndGame);
                    } else {
                        // team with most points win, excluding voting team
                        game.setPoints(TeamMarker.getTeams(game).stream().filter(t -> t != team).min(Comparator.comparingInt(o -> game.getPoints(o))).get(), scoreNeededToEndGame);
                    }
                    ((PlayingState) game.getState()).skipTimer();
                    game.onlinePlayers().forEach(playerTeamEntry -> {
                        Player player = playerTeamEntry.getKey();
                        sendImpostorResult(player);
                    });
                    this.cancel();
                }
            }
        }.runTaskTimer(10, 20);
    }).get();
}
Also used : java.util(java.util) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) PacketUtils(com.ebicep.warlords.util.bukkit.PacketUtils) Team(com.ebicep.warlords.game.Team) PlayingState(com.ebicep.warlords.game.state.PlayingState) GamePoll(com.ebicep.warlords.poll.polls.GamePoll) Warlords(com.ebicep.warlords.Warlords) Player(org.bukkit.entity.Player) ChatUtils(com.ebicep.warlords.util.chat.ChatUtils) Collectors(java.util.stream.Collectors) SimpleScoreboardHandler(com.ebicep.warlords.game.option.marker.scoreboard.SimpleScoreboardHandler) Game(com.ebicep.warlords.game.Game) ScoreboardHandler(com.ebicep.warlords.game.option.marker.scoreboard.ScoreboardHandler) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) ChatColor(org.bukkit.ChatColor) TeamMarker(com.ebicep.warlords.game.option.marker.TeamMarker) Nonnull(javax.annotation.Nonnull) PotionEffectType(org.bukkit.potion.PotionEffectType) Nullable(javax.annotation.Nullable) Player(org.bukkit.entity.Player) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) GamePoll(com.ebicep.warlords.poll.polls.GamePoll) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable)

Example 30 with WarlordsPlayer

use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.

the class RespawnProtectionOption method onEvent.

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onEvent(WarlordsRespawnEvent event) {
    WarlordsPlayer player = event.getPlayer();
    Location respawnPoint = event.getRespawnLocation();
    spawnProtection.put(player, new Pair<>(respawnPoint, protectionTime * 4));
}
Also used : WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Aggregations

WarlordsPlayer (com.ebicep.warlords.player.WarlordsPlayer)80 GameRunnable (com.ebicep.warlords.util.warlords.GameRunnable)43 Location (org.bukkit.Location)37 Player (org.bukkit.entity.Player)36 Utils (com.ebicep.warlords.util.warlords.Utils)26 RegularCooldown (com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown)21 PlayerFilter (com.ebicep.warlords.util.warlords.PlayerFilter)21 AbstractAbility (com.ebicep.warlords.classes.AbstractAbility)20 ParticleEffect (com.ebicep.warlords.effects.ParticleEffect)20 CooldownTypes (com.ebicep.warlords.player.cooldowns.CooldownTypes)20 WarlordsDamageHealingEvent (com.ebicep.warlords.events.WarlordsDamageHealingEvent)17 ItemStack (org.bukkit.inventory.ItemStack)16 ChatColor (org.bukkit.ChatColor)15 Nonnull (javax.annotation.Nonnull)14 Warlords (com.ebicep.warlords.Warlords)13 Nullable (javax.annotation.Nullable)13 Material (org.bukkit.Material)13 Vector (org.bukkit.util.Vector)13 List (java.util.List)11 CircleEffect (com.ebicep.warlords.effects.circle.CircleEffect)10