コード例 #1
0
ファイル: PersistenceFacade.java プロジェクト: BYUCS340/Catan
  /**
   * Gets the list of users.
   *
   * @return The list of saved users.
   * @throws PersistenceException Thrown if issues occur getting the users.
   */
  public List<ServerPlayer> GetAllUsers() throws PersistenceException {
    IPersistenceProvider provider = handler.GetPlugin();

    try {
      provider.StartTransaction();

      List<ServerPlayer> players = provider.GetUserDAO().GetAllUsers();

      provider.EndTransaction(true);

      return players;
    } catch (PersistenceException e) {
      provider.EndTransaction(false);
      throw e;
    }
  }
コード例 #2
0
ファイル: PersistenceFacade.java プロジェクト: BYUCS340/Catan
  /**
   * Adds a user to be be saved.
   *
   * @param player The player to save.
   * @throws PersistenceException Thrown if issues occur adding the user.
   */
  public void AddUser(ServerPlayer player) throws PersistenceException {
    IPersistenceProvider provider = handler.GetPlugin();

    try {
      provider.StartTransaction();

      int id = player.GetID();
      String username = player.GetName();
      String password = player.GetPassword();

      provider.GetUserDAO().AddUser(id, username, password);

      provider.EndTransaction(true);
    } catch (PersistenceException e) {
      provider.EndTransaction(false);
      throw e;
    }
  }