示例#1
0
  public List<Session> getTop() {

    List<Session> map = new ArrayList<Session>();

    for (Session session : HyperPVP.getGameSessions().values()) {

      map.add(session);
    }

    Comparator<Session> comparator =
        new Comparator<Session>() {

          public int compare(Session c1, Session c2) {
            if (c1.getKills() < c2.getKills()) {
              return 1;
            }
            if (c1.getKills() > c2.getKills()) {
              return -1;
            }
            return -1;
          }
        };

    Collections.sort(map, comparator);

    return map;
  }
示例#2
0
  @SuppressWarnings("deprecation")
  public void leaveGame(Player player, boolean normalLeave) {

    player.setGameMode(GameMode.CREATIVE);
    // player.setAllowFlight(true);

    player.setHealth(20.0);
    player.setFoodLevel(20);
    player.setLevel(0);

    for (PotionEffect effect : player.getActivePotionEffects()) {
      player.removePotionEffect(effect.getType());
    }

    // Session session = HyperPVP.getSession(player);
    // session.setInterruptThread(true);

    if (normalLeave) {
      player.sendMessage(ChatColor.AQUA + "You are now spectating!");
      HyperPVP.setListName(ChatColor.AQUA, player);
      player.getInventory().clear();
      player.updateInventory();
    }

    CycleUtil.addSpectator(player, normalLeave);
    HyperPVP.getGameSessions().remove(player.getName());

    CycleUtil.hidePlayerWhereAppropriate(player, false);
    player.getInventory().setHelmet(null);
    player.getInventory().setBoots(null);
    player.getInventory().setChestplate(null);
    player.getInventory().setLeggings(null);

    try {
      HyperPVP.getStorage()
          .executeQuery(
              "UPDATE servers SET team_one = '"
                  + this.getTeamMembers(this.teams.get(0).getColor()).size()
                  + "' WHERE bungee_name = '"
                  + HyperPVP.getConfiguration().getConfig().getString("Server").toLowerCase()
                  + "'");

      if (this.type != GameType.FFA) {
        HyperPVP.getStorage()
            .executeQuery(
                "UPDATE servers SET team_two = '"
                    + this.getTeamMembers(this.teams.get(1).getColor()).size()
                    + "' WHERE bungee_name = '"
                    + HyperPVP.getConfiguration().getConfig().getString("Server").toLowerCase()
                    + "'");
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
示例#3
0
  public List<Session> getTeamMembers(ChatColor color) {

    List<Session> sessions = new ArrayList<Session>();

    for (Session session : HyperPVP.getGameSessions().values()) {
      if (session.getTeam() != null && session.getTeam().getColor() == color) {
        sessions.add(session);
      }
    }

    return sessions;
  }