示例#1
0
  /**
   * Attempt to complete a route.
   *
   * @param player Player using the finish sign
   * @param token Route associated with the finish sign
   * @param w Way-point number required to finish the route
   */
  private void activateFinishSign(final Player player, final String token, final int w) {
    final String name = player.getName();
    final PlayerProgress progress = explorers.get(name);

    final String message;
    boolean broadcast = false;

    if (progress == null) {
      message = NOT_STARTED_MSG;
    } else if (progress.getToken().equalsIgnoreCase(token)) {

      if (progress.getWaypoints() + 1 == w) {
        broadcast = true;
        message = String.format(SUCCESS_MSG, name, token);

        explorers.remove(name);
        addPlayerToExploration(player, token);
        saveState();
      } else {
        message = ChatColor.RED + "You need waypoint " + (progress.getWaypoints() + 1);
      }
    } else {
      message = String.format(BAD_FINISH_MSG, token, progress.getToken());
    }

    if (broadcast) {
      getServer().broadcastMessage(message);
    } else {
      player.sendMessage(message);
    }
  }
示例#2
0
  /**
   * Attempt to progress the player along the current route.
   *
   * @param player Player using the sign
   * @param token Route associated with the sign
   * @param w Way-point number associated with the sign
   */
  private void activateWaypointSign(Player player, String token, int w) {
    PlayerProgress progress = explorers.get(player.getName());

    if (progress == null) {
      player.sendMessage(NOT_STARTED_MSG);
    } else if (!progress.getToken().equalsIgnoreCase(token)) {
      player.sendMessage(String.format(BAD_FINISH_MSG, token, progress.getToken()));
    } else {
      if (progress.getWaypoints() + 1 == w) {
        progress.setWaypoints(w);
        player.sendMessage(ChatColor.GREEN + "Progress recorded!");
      } else {
        player.sendMessage(ChatColor.RED + "You need waypoint " + (progress.getWaypoints() + 1));
      }
    }
  }