Skip to content

Commit 1d295d2

Browse files
author
david
committed
added account api
1 parent 49483f7 commit 1d295d2

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package net.thenextlvl.services.economy.account;
2+
3+
import java.util.UUID;
4+
5+
/**
6+
* Account is an interface representing a financial account.
7+
*/
8+
public interface Account {
9+
10+
/**
11+
* Returns the UUID of the owner of this account.
12+
*
13+
* @return the UUID of the owner
14+
*/
15+
UUID getOwner();
16+
17+
/**
18+
* Retrieves the balance of the account.
19+
*
20+
* @return the balance of the account
21+
*/
22+
double getBalance();
23+
24+
/**
25+
* Withdraws the specified amount from the account balance.
26+
*
27+
* @param amount the amount to be withdrawn
28+
* @return the new balance after the withdrawal
29+
*/
30+
double withdraw(double amount);
31+
32+
/**
33+
* Deposits the specified amount into the account balance.
34+
*
35+
* @param amount the amount to be deposited
36+
* @return the new balance after the deposit
37+
*/
38+
double deposit(double amount);
39+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package net.thenextlvl.services.economy.account;
2+
3+
import org.bukkit.OfflinePlayer;
4+
5+
import java.util.UUID;
6+
import java.util.concurrent.CompletableFuture;
7+
8+
/**
9+
* The AccountController interface provides methods to create, retrieve and delete accounts.
10+
*/
11+
public interface AccountController {
12+
/**
13+
* Creates an account with the given unique ID.
14+
*
15+
* @param uniqueId the unique ID of the account to be created
16+
* @return a CompletableFuture that will complete with the created account
17+
*/
18+
CompletableFuture<Account> createAccount(UUID uniqueId);
19+
20+
/**
21+
* Creates an account for the specified player.
22+
*
23+
* @param player the player for whom the account will be created
24+
* @return a CompletableFuture that will complete with the created account
25+
*/
26+
CompletableFuture<Account> createAccount(OfflinePlayer player);
27+
28+
/**
29+
* Retrieves the account for the specified player.
30+
*
31+
* @param player the player for whom the account will be retrieved
32+
* @return a CompletableFuture that will complete with the retrieved account
33+
*/
34+
CompletableFuture<Account> getAccount(OfflinePlayer player);
35+
36+
/**
37+
* Retrieves the account with the specified unique ID.
38+
*
39+
* @param uniqueId the unique ID of the account to be retrieved
40+
* @return a CompletableFuture that will complete with the retrieved account
41+
*/
42+
CompletableFuture<Account> getAccount(UUID uniqueId);
43+
44+
/**
45+
* Deletes the specified account.
46+
*
47+
* @param account the account to be deleted
48+
* @return a CompletableFuture that will complete when the account is deleted
49+
*/
50+
CompletableFuture<Void> deleteAccount(Account account);
51+
52+
/**
53+
* Deletes the account of the specified player.
54+
*
55+
* @param player the player whose account will be deleted
56+
* @return a CompletableFuture that will complete when the account is deleted
57+
*/
58+
CompletableFuture<Void> deleteAccount(OfflinePlayer player);
59+
60+
/**
61+
* Deletes the account with the specified unique ID.
62+
*
63+
* @param uniqueId the unique ID of the account to be deleted
64+
* @return a CompletableFuture that will complete when the account is deleted
65+
*/
66+
CompletableFuture<Void> deleteAccount(UUID uniqueId);
67+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@TypesAreNotNullByDefault
2+
@FieldsAreNotNullByDefault
3+
@MethodsReturnNotNullByDefault
4+
@ParametersAreNotNullByDefault
5+
package net.thenextlvl.services.economy.account;
6+
7+
import core.annotation.FieldsAreNotNullByDefault;
8+
import core.annotation.MethodsReturnNotNullByDefault;
9+
import core.annotation.ParametersAreNotNullByDefault;
10+
import core.annotation.TypesAreNotNullByDefault;

0 commit comments

Comments
 (0)