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;
}
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();
}
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;
}
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();
}
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));
}
Aggregations