コード例 #1
0
  /**
   * Notify a player if they have completed this route and thus are able to use the protected block.
   *
   * @param player Player using the sign
   * @param routeName Route associated with the sign
   * @throws ExplorersException
   */
  private void activateLockSign(Player player, String routeName) throws ExplorersException {

    Route r = getExistingRoute(routeName);

    if (r.isWinner(player)) {
      player.sendMessage(ChatColor.GREEN + "Unlocked");
    } else {
      player.sendMessage(ChatColor.RED + "You have not completed this route.");
    }
  }
コード例 #2
0
  /**
   * Perform checks when a player uses a route protected block.
   *
   * @param player Player using the block
   * @param routeName Route protecting the block
   * @param cst Type of protection being used.
   * @throws ExplorersException Exceptions will be generated when the route does not exist or when
   *     permission is denied.
   */
  public void allowUseLockedBlock(Player player, String routeName, CommandSignType cst)
      throws ExplorersException {

    if (cst == CommandSignType.LOCK_SIGN) {
      Route r = getExistingRoute(routeName);
      if (!r.isWinner(player)) {
        throw new ExplorersPermissionException();
      }
    } else {
      PlayerProgress p = explorers.get(player.getName());
      if (p == null || !p.getToken().equalsIgnoreCase(routeName)) {
        throw new ExplorersPermissionException();
      }
    }
  }