Example #1
0
  public String matchInfoToString(CommandSender player) {

    StringBuilder builder = new StringBuilder();

    player.sendMessage(
        ChatColor.RED
            + "------------------ "
            + ChatColor.AQUA
            + "Match Info"
            + ChatColor.RED
            + " ------------------");

    if (HyperPVP.getMap().getType() == GameType.TDM
        || HyperPVP.getMap().getType() == GameType.DTM
        || HyperPVP.getMap().getType() == GameType.DTC
        || HyperPVP.getMap().getType() == GameType.RTC) {

      player.sendMessage(
          ChatColor.DARK_AQUA + "Time: " + ChatColor.AQUA + HyperPVP.getTimeString());

      TeamMap one = this.teams.get(0);
      TeamMap two = this.teams.get(1);

      player.sendMessage(
          one.getColor()
              + HyperPVP.capitalize(
                  one.getColor().name().toLowerCase().replace("_", " ").replace("dark ", ""))
              + ChatColor.GRAY
              + " kills: "
              + ChatColor.WHITE
              + one.getKills()
              + " | "
              + two.getColor()
              + HyperPVP.capitalize(
                  two.getColor().name().toLowerCase().replace("_", " ").replace("dark ", ""))
              + ChatColor.GRAY
              + " kills: "
              + ChatColor.WHITE
              + two.getKills()
              + " | "
              + ChatColor.AQUA
              + "Observers"
              + ChatColor.GRAY
              + ": "
              + ChatColor.WHITE
              + HyperPVP.getSpectators().size());

      player.sendMessage("");

      String goal = "";

      if (HyperPVP.getMap().getType() == GameType.TDM) {
        goal = ChatColor.AQUA + "(Team Death Match) Get your team the most kills.";
      }

      if (HyperPVP.getMap().getType() == GameType.DTM) {
        goal = ChatColor.AQUA + "(Destroy The Monument) Destory all of other teams obsidian.";
      }

      if (HyperPVP.getMap().getType() == GameType.DTC) {
        goal = ChatColor.AQUA + "(Destroy The Core) Leak their obisdian core.";
      }

      if (HyperPVP.getMap().getType() == GameType.RTC) {
        goal =
            ChatColor.AQUA + "(Race To Core) Be the first team to destroy the core in the middle.";
      }

      player.sendMessage(
          ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "Goal: " + ChatColor.RESET + goal);
    }

    if (HyperPVP.getMap().getType() == GameType.FFA) {

      player.sendMessage(
          ChatColor.DARK_AQUA + "Time: " + ChatColor.AQUA + HyperPVP.getTimeString());
      player.sendMessage("");
      player.sendMessage(
          ChatColor.DARK_AQUA
              + ""
              + ChatColor.BOLD
              + "Goal: "
              + ChatColor.RESET
              + ChatColor.AQUA
              + "Kill everyone, get the highest kill score.");
      player.sendMessage("");

      List<Session> topPlayers = HyperPVP.getMap().getTop();

      if (topPlayers.size() != 0) {

        int i = 1;

        for (Session set : topPlayers) {

          if (i > 10 && set.getKills() != 0) {
            continue;
          }

          player.sendMessage(
              i
                  + ". "
                  + ChatColor.GOLD
                  + set.getPlayer().getName()
                  + ChatColor.WHITE
                  + " with "
                  + set.getKills()
                  + "!");

          i++;
        }
      }
    }

    return builder.toString();
  }
Example #2
0
 public int getCounter() {
   return HyperPVP.getSpectators().size();
 }
Example #3
0
  @SuppressWarnings("deprecation")
  public void joinGame(Player player, String name) {

    int rank = 1;

    try {
      rank =
          HyperPVP.getStorage()
              .readInt32("SELECT rank FROM users WHERE username = '******'");
    } catch (SQLException e) {
      e.printStackTrace();
    }

    if (this.type == GameType.FFA) {

      List<Session> first = this.getTeamMembers(this.teams.get(0).getColor());

      if (first.size() >= this.maxPlayers && rank == 1) {

        System.out.println(this.maxPlayers);
        player.sendMessage(
            ChatColor.RED
                + "Teams full - "
                + ChatColor.GOLD
                + "hyperpvp.us/shop"
                + ChatColor.GREEN
                + " to join full teams or view other servers at "
                + ChatColor.GREEN
                + "hyperpvp.us/servers");
        return;
      }

    } else {

      List<Session> first = this.getTeamMembers(this.teams.get(0).getColor());
      List<Session> second = this.getTeamMembers(this.teams.get(1).getColor());

      if ((first.size() + second.size()) >= this.maxPlayers && rank == 1) {

        System.out.println(this.maxPlayers);
        player.sendMessage(
            ChatColor.RED
                + "Teams full - "
                + ChatColor.GOLD
                + "hyperpvp.us/shop"
                + ChatColor.GREEN
                + " to join full teams or view other servers at "
                + ChatColor.GREEN
                + "hyperpvp.us/servers");
        return;
      }
    }

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

    if (HyperPVP.hasMatchBeenAnnounced()) {
      player.setGameMode(GameMode.SURVIVAL);
    } else {
      player.setGameMode(GameMode.CREATIVE);
    }

    player.getInventory().clear();
    player.updateInventory();

    Session session = new Session(player);

    HyperPVP.getSpectators().remove(player.getName());
    CycleUtil.addGameSession(player, session);

    if (this.type == GameType.FFA) {
      session.setTeam(this.teams.get(0));
    } else {

      if (name != null) {

        TeamMap team = this.getTeamByName(name);
        session.setTeam(team);

      } else {

        List<Session> first = this.getTeamMembers(this.teams.get(0).getColor());
        List<Session> second = this.getTeamMembers(this.teams.get(1).getColor());

        if (first.size() == second.size()) {
          session.setTeam(this.teams.get(0));
        } else {

          if (first.size() > second.size()) {
            session.setTeam(this.teams.get(1));

          } else session.setTeam(this.teams.get(0));
        }
      }
    }

    /*if (HyperPVP.hasMatchBeenAnnounced()) {
    	player.sendMessage(this.matchInfoToString(player));
    }*/

    player.sendMessage(
        ChatColor.GRAY
            + "You joined the "
            + session.getTeam().getColor()
            + HyperPVP.capitalize(
                session
                    .getTeam()
                    .getColor()
                    .name()
                    .toLowerCase()
                    .replace("_", " ")
                    .replace("dark ", ""))
            + " Team");

    HyperPVP.setListName(session.getTeam().getColor(), player);

    TagAPI.refreshPlayer(player);

    player.setFallDistance(0F);

    if (HyperPVP.hasMatchBeenAnnounced()) {

      CycleUtil.hidePlayerWhereAppropriate(player, true);
      player.teleport(this.getRandomSpawn(player));
    }

    if (!HyperPVP.hasMatchBeenAnnounced()) {
      player.getInventory().clear();
      player.getInventory().addItem(new ItemStack(Material.COMPASS, 1));
      player.updateInventory();
      player.closeInventory();
    }

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

    System.out.println(session.toValue());
  }