Example #1
0
  @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 performEventAction(ArenaPlayer player) {
   EventParams ep = (EventParams) mp;
   EventExecutor executor = EventController.getEventExecutor(ep.getType().getName());
   String args[];
   switch (command) {
     case JOIN:
       args = new String[] {"join", options1};
       executor.eventJoin(player, ep, args, true);
       break;
     case LEAVE:
       args = new String[] {"leave", options1, options2};
       executor.leave(player, ep, true);
       break;
     case START:
       //			executor.start();
       break;
   }
 }
Example #3
0
  @Override
  public void openEvent(EventParams mp) throws NeverWouldJoinException {
    aliveTeams.clear();
    competingTeams.clear();
    rounds.clear();
    round = -1;
    nrounds = -1;
    timeBetweenRounds = oParms.getTimeBetweenRounds();
    String color = Util.getColor(mp.getPrefix());
    mp.setPrefix(color + "[" + mp.getName() + " " + oParms.getName() + "]");
    mp.setCommand(oParms.getCommand());
    mp.setName(mp.getName() + " " + oParms.getName());
    mp.setTimeBetweenRounds(oParms.getTimeBetweenRounds());
    mp.setSecondsTillMatch(oParms.getSecondsTillMatch());
    mp.setSecondsToLoot(oParms.getSecondsToLoot());

    TimeUtil.testClock();
    super.openEvent(mp);
  }
 @Override
 public void openEvent(EventParams mp) throws NeverWouldJoinException {
   aliveTeams.clear();
   competingTeams.clear();
   rounds.clear();
   round = -1;
   nrounds = -1;
   timeBetweenRounds = oParms.getTimeBetweenRounds();
   ChatColor color = MessageUtil.getFirstColor(mp.getPrefix());
   mp.setTransitionOptions(mp.getTransitionOptions());
   mp.setPrefix(color + "[" + mp.getName() + " " + oParms.getName() + "]");
   mp.setCommand(oParms.getCommand());
   mp.setName(mp.getName() + " " + oParms.getName());
   mp.setTimeBetweenRounds(oParms.getTimeBetweenRounds());
   mp.setSecondsTillMatch(oParms.getSecondsTillMatch());
   mp.setSecondsToLoot(oParms.getSecondsToLoot());
   TimeUtil.testClock();
   super.openEvent(mp);
   EventParams copy = new EventParams(mp);
   copy.setMaxTeams(CompetitionSize.MAX);
   this.setTeamJoinHandler(TeamJoinFactory.createTeamJoinHandler(copy, this));
 }