|
1 | 1 | package dev.drawethree.xprison.api.currency.model; |
2 | 2 |
|
3 | | -import dev.drawethree.xprison.api.currency.enums.LostCause; |
4 | | -import dev.drawethree.xprison.api.currency.enums.ReceiveCause; |
5 | | -import org.bukkit.OfflinePlayer; |
| 3 | +import org.bukkit.inventory.ItemStack; |
6 | 4 |
|
7 | 5 | /** |
8 | | - * Represents a generic currency system in the XPrison API. |
| 6 | + * Represents the metadata and formatting configuration of a currency in the XPrison API. |
| 7 | + * This includes display name, format rules, symbol settings, and optional icon. |
9 | 8 | * <p> |
10 | | - * This interface abstracts common currency operations such as querying, |
11 | | - * adding, removing, and setting balances for players. Implementations |
12 | | - * could represent different currency types like Tokens, Gems, Money, etc. |
13 | | - * <p> |
14 | | - * Methods that modify balances return a boolean indicating whether the |
15 | | - * operation was successful (e.g., not blocked, not insufficient funds, etc.). |
| 9 | + * Currency balance operations are handled by a separate CurrencyService. |
16 | 10 | */ |
17 | 11 | public interface XPrisonCurrency { |
18 | 12 |
|
19 | 13 | /** |
20 | | - * Gets the name of this currency. |
21 | | - * <p> |
22 | | - * This is typically used for display purposes, configuration keys, |
23 | | - * or to distinguish between multiple currency types (e.g., "Tokens", "Gems", "Money"). |
| 14 | + * Gets the internal ID or key of the currency (e.g., "money", "tokens"). |
24 | 15 | * |
25 | | - * @return The name of the currency. |
| 16 | + * @return The unique name of this currency. |
26 | 17 | */ |
27 | 18 | String getName(); |
28 | 19 |
|
29 | 20 | /** |
30 | | - * Gets the current amount of this currency for the specified player. |
| 21 | + * Gets the starting amount of a currency |
| 22 | + * |
| 23 | + * @return The amount each player will have on first join |
| 24 | + */ |
| 25 | + double getStartingAmount(); |
| 26 | + |
| 27 | + /** |
| 28 | + * Gets the display name of the currency (e.g., "Money", "Tokens"). |
31 | 29 | * |
32 | | - * @param player The player (offline or online) whose balance to retrieve. |
33 | | - * @return The amount of currency the player currently has. |
| 30 | + * @return The friendly display name of the currency. |
34 | 31 | */ |
35 | | - double getBalance(OfflinePlayer player); |
| 32 | + String getDisplayName(); |
36 | 33 |
|
37 | 34 | /** |
38 | | - * Adds a specified amount of currency to the player's balance. |
| 35 | + * Gets the prefix of the currency (e.g., "$"). |
39 | 36 | * |
40 | | - * @param player The player to add currency to. |
41 | | - * @param amount The amount of currency to add. |
42 | | - * @param receiveCause Why currency was added |
43 | | - * @return true if the currency was successfully added, false otherwise. |
| 37 | + * @return The friendly display name of the currency. |
44 | 38 | */ |
45 | | - boolean addBalance(OfflinePlayer player, double amount, ReceiveCause receiveCause); |
| 39 | + String getPrefix(); |
46 | 40 |
|
47 | 41 | /** |
48 | | - * Removes a specified amount of currency from the player's balance. |
| 42 | + * Gets the suffix of the currency. |
49 | 43 | * |
50 | | - * @param player The player to remove currency from. |
51 | | - * @param amount The amount of currency to remove. |
52 | | - * @param lostCause Why currency was lost |
53 | | - * @return true if the currency was successfully removed, false (e.g., insufficient funds) otherwise. |
| 44 | + * @return The friendly display name of the currency. |
54 | 45 | */ |
55 | | - boolean removeBalance(OfflinePlayer player, double amount, LostCause lostCause); |
| 46 | + String getSuffix(); |
56 | 47 |
|
57 | 48 | /** |
58 | | - * Sets the player's currency balance to a new specified amount. |
| 49 | + * Formats a raw double value according to the currency's configuration. |
59 | 50 | * |
60 | | - * @param player The player whose balance to set. |
61 | | - * @param amount The new amount to set. |
62 | | - * @return true if the balance was successfully set, false otherwise. |
| 51 | + * @param amount The amount to format. |
| 52 | + * @return The formatted currency string (e.g., "$1.2k", "$3,000"). |
63 | 53 | */ |
64 | | - boolean setBalance(OfflinePlayer player, double amount); |
| 54 | + String format(double amount); |
65 | 55 |
|
66 | 56 | /** |
67 | | - * Checks if the specified player has at least the given amount of this currency. |
| 57 | + * Gets the configured physical item for this currency, if any. |
| 58 | + * This can be used in GUIs or displays to represent the currency visually. |
68 | 59 | * |
69 | | - * @param player The player whose balance to check. |
70 | | - * @param amount The minimum amount to verify. |
71 | | - * @return true if the player has at least the specified amount, false otherwise. |
| 60 | + * @return The {@link ItemStack} used as the item, or null if not set. |
72 | 61 | */ |
73 | | - boolean has(OfflinePlayer player, double amount); |
| 62 | + ItemStack getPhysicalItem(); |
74 | 63 | } |
0 commit comments