Skip to content

Commit

Permalink
added account api
Browse files Browse the repository at this point in the history
  • Loading branch information
NonSwag committed Jul 21, 2024
1 parent 49483f7 commit 1d295d2
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/main/java/net/thenextlvl/services/economy/account/Account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package net.thenextlvl.services.economy.account;

import java.util.UUID;

/**
* Account is an interface representing a financial account.
*/
public interface Account {

/**
* Returns the UUID of the owner of this account.
*
* @return the UUID of the owner
*/
UUID getOwner();

/**
* Retrieves the balance of the account.
*
* @return the balance of the account
*/
double getBalance();

/**
* Withdraws the specified amount from the account balance.
*
* @param amount the amount to be withdrawn
* @return the new balance after the withdrawal
*/
double withdraw(double amount);

/**
* Deposits the specified amount into the account balance.
*
* @param amount the amount to be deposited
* @return the new balance after the deposit
*/
double deposit(double amount);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package net.thenextlvl.services.economy.account;

import org.bukkit.OfflinePlayer;

import java.util.UUID;
import java.util.concurrent.CompletableFuture;

/**
* The AccountController interface provides methods to create, retrieve and delete accounts.
*/
public interface AccountController {
/**
* Creates an account with the given unique ID.
*
* @param uniqueId the unique ID of the account to be created
* @return a CompletableFuture that will complete with the created account
*/
CompletableFuture<Account> createAccount(UUID uniqueId);

/**
* Creates an account for the specified player.
*
* @param player the player for whom the account will be created
* @return a CompletableFuture that will complete with the created account
*/
CompletableFuture<Account> createAccount(OfflinePlayer player);

/**
* Retrieves the account for the specified player.
*
* @param player the player for whom the account will be retrieved
* @return a CompletableFuture that will complete with the retrieved account
*/
CompletableFuture<Account> getAccount(OfflinePlayer player);

/**
* Retrieves the account with the specified unique ID.
*
* @param uniqueId the unique ID of the account to be retrieved
* @return a CompletableFuture that will complete with the retrieved account
*/
CompletableFuture<Account> getAccount(UUID uniqueId);

/**
* Deletes the specified account.
*
* @param account the account to be deleted
* @return a CompletableFuture that will complete when the account is deleted
*/
CompletableFuture<Void> deleteAccount(Account account);

/**
* Deletes the account of the specified player.
*
* @param player the player whose account will be deleted
* @return a CompletableFuture that will complete when the account is deleted
*/
CompletableFuture<Void> deleteAccount(OfflinePlayer player);

/**
* Deletes the account with the specified unique ID.
*
* @param uniqueId the unique ID of the account to be deleted
* @return a CompletableFuture that will complete when the account is deleted
*/
CompletableFuture<Void> deleteAccount(UUID uniqueId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@TypesAreNotNullByDefault
@FieldsAreNotNullByDefault
@MethodsReturnNotNullByDefault
@ParametersAreNotNullByDefault
package net.thenextlvl.services.economy.account;

import core.annotation.FieldsAreNotNullByDefault;
import core.annotation.MethodsReturnNotNullByDefault;
import core.annotation.ParametersAreNotNullByDefault;
import core.annotation.TypesAreNotNullByDefault;

0 comments on commit 1d295d2

Please sign in to comment.