@Override public void startEvent() { super.startEvent(); Server server = Bukkit.getServer(); int osize = teams.size(); nrounds = getNRounds(osize); int nteams = (int) Math.pow(2, nrounds); server.broadcastMessage( Log.colorChat( eventParams.getPrefix() + "&e The " + eventParams.toPrettyString() + oParms.getName() + " tournament is starting!")); preliminary_round = teams.size() != nteams; if (preliminary_round) nrounds++; TreeMap<Double, Team> sortTeams = new TreeMap<Double, Team>(Collections.reverseOrder()); BTInterface bti = new BTInterface(eventParams); // System.out.println("startEvent:: bti=" + bti); for (Team t : teams) { Double elo = Defaults.DEFAULT_ELO; if (bti.isValid()) { elo = (double) bti.getElo(t); } while (sortTeams.containsKey(elo)) { elo += 0.0001; } sortTeams.put(elo, t); } competingTeams.addAll(teams); teams.clear(); aliveTeams.clear(); ArrayList<Team> ts = new ArrayList<Team>(sortTeams.values()); for (Team t : ts) { teams.add(t); aliveTeams.add(t); } server.broadcastMessage( Log.colorChat( eventParams.getPrefix() + "&6 " + teams.size() + " &e" + MessageUtil.getTeamsOrPlayers(teams.size()) + " will compete in a &6" + nrounds + "&e round tournament")); if (preliminary_round) { makePreliminaryRound(); } else { makeNextRound(); } startRound(); }
private void announceRound() { Round tr = rounds.get(round); String strround = preliminary_round && round == 0 ? "PreliminaryRound" : ("Round " + (round + 1)); if (round + 1 == nrounds) { strround = "Final Round"; } if (preliminary_round) { preliminary_round = false; int nprelims = tr.getMatchups().size() * eventParams.getMinTeams(); for (int i = 0; i < aliveTeams.size() - nprelims; i++) { Team t = aliveTeams.get(i); t.sendMessage("&4[" + strround + "]&e You have a &5bye&e this round"); } } BTInterface bti = new BTInterface(eventParams); final String prefix = eventParams.getPrefix(); if (tr.getMatchups().size() <= 8) { for (Matchup m : tr.getMatchups()) { List<String> names = new ArrayList<String>(); for (Team t : m.getTeams()) { names.add("&8" + t.getDisplayName() + "&6[" + bti.getElo(t) + "]"); } String msg = "&e" + strround + ": " + StringUtils.join(names, " vs "); if (ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH > msg.length() + prefix.length()) { broadcastAlive(prefix + " " + msg); } else { broadcastAlive(msg); } } } else { broadcastAlive( prefix + "&e Round " + strround + " has " + tr.getMatchups().size() + " " + MessageUtil.teamsOrPlayers(eventParams.getMinTeamSize()) + " competing. &6/tourney status:&e for updates"); } if (round != nrounds) broadcast( prefix + "&e " + strround + " will start in &4" + timeBetweenRounds + " &eseconds!"); else broadcast( prefix + "&e The " + strround + " will start in &4" + timeBetweenRounds + " &eseconds!"); }
private void announceRound() { Round tr = rounds.get(round); String strround = "Round " + (round + 1); if (round + 1 == nrounds) { strround = "Final Round"; } if (preliminary_round) { preliminary_round = false; int nprelims = tr.getMatchups().size() * 2; for (int i = 0; i < aliveTeams.size() - nprelims; i++) { Team t = aliveTeams.get(i); t.sendMessage("&4[" + strround + "]&e You have a &5bye&e this round"); } } BTInterface bti = new BTInterface(eventParams); final String prefix = eventParams.getPrefix(); for (Matchup m : tr.getMatchups()) { if (m.getTeams().size() == 2) { Team t1 = m.getTeam(0); Team t2 = m.getTeam(1); Double elo1 = (double) bti.getElo(t1); Double elo2 = (double) bti.getElo(t2); // System.out.println("team1 stat= " + bti.loadRecord(t1.getPlayers())); broadcast( prefix + "&e " + strround + ": &8" + t1.getDisplayName() + "&6[" + elo1 + "]" + "&e vs &8" + t2.getDisplayName() + "&6[" + elo2 + "]"); } } if (round != nrounds) broadcast( prefix + "&e " + strround + " will start in &4" + timeBetweenRounds + " &eseconds!"); else broadcast( prefix + "&e The " + strround + " will start in &4" + timeBetweenRounds + " &eseconds!"); }
public void addRecord( Set<ArenaTeam> victors, Set<ArenaTeam> losers, Set<ArenaTeam> drawers, WinLossDraw wld, boolean teamRating) { if (!enabled) return; BTInterface.addRecord(mp, victors, losers, drawers, wld, teamRating); }
public String getRankMessage(OfflinePlayer player) { BTInterface bti = new BTInterface(mp); return bti.isValid() ? bti.getRankMessage(player) : ""; }
public boolean setRating(OfflinePlayer player, int rating) { BTInterface bti = new BTInterface(mp); return bti.isValid() && bti.setRating(player, rating); }
public void resetStats() { if (!enabled) return; BTInterface bti = new BTInterface(mp); if (bti.isValid()) bti.resetStats(); }
public static ArenaStat loadRecord(MatchParams mp, ArenaPlayer ap) { if (!enabled) return BLANK_STAT; return BTInterface.loadRecord(mp.getDBName(), ap); }
public static ArenaStat loadRecord(MatchParams mp, ArenaTeam t) { if (!enabled || mp == null) return BLANK_STAT; return BTInterface.loadRecord(mp.getDBName(), t); }
public void addRecord(ArenaPlayer victor, ArenaPlayer loser, WinLossDraw wld) { if (!enabled) return; BTInterface.addRecord(mp, victor, loser, wld); }
public static void resumeTrackingMessages(ArenaPlayer p) { if (enabled) BTInterface.resumeTrackingMessages(p); }
public static void stopTrackingMessages(ArenaPlayer p) { if (enabled) BTInterface.stopTrackingMessages(p); }
public static boolean hasInterface(MatchParams mp) { return enabled && BTInterface.hasInterface(mp); }
public static void setPlugin(Plugin plugin) { BTInterface.setTrackerPlugin(plugin); enabled = true; }
public void printTopX( CommandSender sender, int x, int minTeamSize, String headerMsg, String bodyMsg) { BTInterface bti = new BTInterface(mp); if (!bti.isValid()) return; bti.printTopX(sender, x, minTeamSize, headerMsg, bodyMsg); }