Exemplo n.º 1
0
  @Override
  public List<String> getHelpMessages(TeamInfo team) {
    LinkedList<String> messages = new LinkedList<String>();

    String numText;
    switch (numTeams.getValue()) {
      case 2:
        numText = "two ";
        break;
      case 3:
        numText = "three ";
        break;
      case 4:
        numText = "four ";
        break;
      default:
        numText = Integer.toString(numTeams.getValue());
        break;
    }
    messages.add(
        "Players have been split into "
            + numText
            + "teams. Get farming!\nThe scoreboard shows what team each player is on.");
    messages.add(
        "The teams complete to deliver the most farm produce (plants, meat, eggs, wool and leather - no seeds) to a central depot.");
    messages.add(
        "At the end of " + dayLimit + " days, the team that has the highest score wins the game.");
    messages.add("You will respawn at your base when you die.");

    if (announceScores.isEnabled())
      messages.add("The current scores will be announced at the start of each day.");

    return messages;
  }
Exemplo n.º 2
0
  @Override
  public void gameStarted() {
    // don't let drops spawn on the plateau for a couple of seconds
    getScheduler()
        .runTaskLater(
            getPlugin(),
            new Runnable() {
              public void run() {
                generating = false;
              }
            },
            60);

    scoresForTypes.clear();

    int[] teamCounts = new int[numTeams.getValue()];
    List<Player> players = getOnlinePlayers();

    while (players.size()
        > 0) { // pick random player, add them to one of the teams with the fewest players (picked
               // randomly)
      Player player = players.remove(random.nextInt(players.size()));
      allocatePlayer(player, teamCounts);
    }

    broadcastMessage(ChatColor.YELLOW + "Day 1 of " + dayLimit);
    dayCountProcessID =
        getScheduler()
            .scheduleSyncRepeatingTask(
                getPlugin(),
                new Runnable() {
                  long lastRun = 0;

                  public void run() {
                    long time = getPlugin().getServer().getWorlds().get(0).getTime();

                    if (time
                        < lastRun) // time of day has gone backwards: must be a new day! Allocate
                                   // the killers
                    {
                      dayCount++;
                      if (dayCount >= dayLimit.getValue()) {
                        endGame();
                        getScheduler().cancelTask(dayCountProcessID);
                      } else {
                        String message =
                            ChatColor.YELLOW + "Day " + (dayCount + 1) + " of " + dayLimit;
                        if (announceScores.isEnabled()) message += writeCurrentScores();
                        broadcastMessage(message);
                      }
                    }

                    lastRun = time;
                  }
                },
                600L,
                100L); // initial wait: 30s, then check every 5s
  }
Exemplo n.º 3
0
  @Override
  public void playerJoinedLate(Player player) {
    // put this player onto one of the teams with the fewest survivors
    TeamInfo[] teams = getTeams();
    int[] teamCounts = new int[numTeams.getValue()];
    for (int i = 0; i < teamCounts.length; i++)
      teamCounts[i] = getOnlinePlayers(new PlayerFilter().team(teams[i])).size();

    TeamInfo team = allocatePlayer(player, teamCounts);
    broadcastMessage(
        new PlayerFilter().exclude(player),
        player.getName() + " has joined the " + team.getChatColor() + team.getName());
  }
Exemplo n.º 4
0
 private Location getSpawnLocationForTeam(int team) {
   Location loc;
   switch (team) {
     case 0:
       if (numTeams.getValue() == 3)
         loc =
             dropOffCenter
                 .clone()
                 .add(
                     -35.5, 0,
                     -20.5); // for 3 teams, ensure they're equidistant from each other, as well as
                             // from the plinth
       else loc = dropOffCenter.clone().add(-43.5, 0, 0.5);
       loc.setYaw(-90);
       return loc;
     case 1:
       if (numTeams.getValue() == 3)
         loc =
             dropOffCenter
                 .clone()
                 .add(
                     35.5, 0,
                     -20.5); // for 3 teams, ensure they're equidistant from each other, as well as
                             // from the plinth
       else loc = dropOffCenter.clone().add(43.5, 0, 0);
       loc.setYaw(90);
       return loc;
     case 2:
       loc = dropOffCenter.clone().add(0.5, 0, 43.5);
       loc.setYaw(180);
       return loc;
     case 3:
       loc = dropOffCenter.clone().add(0.5, 0, -43.5);
       loc.setYaw(0);
       return loc;
     default:
       return dropOffCenter;
   }
 }
Exemplo n.º 5
0
  @Override
  public boolean isLocationProtected(Location l, Player p) {
    if (dropOffCenter == null) return false;

    int cy = dropOffCenter.getBlockY(), ly = l.getBlockY();
    if (l.getBlockY() < cy - 1 || ly > cy + 5) return false;

    // the drop-off building is protected
    int cx = dropOffCenter.getBlockX(),
        cz = dropOffCenter.getBlockZ(),
        lx = l.getBlockX(),
        lz = l.getBlockZ();
    if (lx > cx - 4 && lx < cx + 4 && lz > cz - 4 && lz < cz + 4) return true;

    // the spawn point for each team is also protected
    for (int team = 0; team < numTeams.getValue(); team++) {
      Location spawn = getSpawnLocationForTeam(team);
      if (lx == spawn.getBlockX() && lz == spawn.getBlockZ() && ly < cy + 2) return true;
    }
    return false;
  }
Exemplo n.º 6
0
 @Override
 public int getMinPlayers() {
   return numTeams.getValue();
 } // one player on each team is our minimum