diff --git a/java/noppes/npcs/api/entity/IPlayer.java b/java/noppes/npcs/api/entity/IPlayer.java index 14610af..ba3a1f9 100644 --- a/java/noppes/npcs/api/entity/IPlayer.java +++ b/java/noppes/npcs/api/entity/IPlayer.java @@ -675,4 +675,71 @@ public interface IPlayer extends IEntityLivingBase, IPlayer[] getPartyMembers(); + + // ========================================= + // Currency Methods + // ========================================= + + /** + * Gets the player's current currency balance. + * If Vault is configured and available, returns Vault balance. + * Otherwise returns CNPC+ built-in currency balance. + * + * @return The player's currency balance + */ + long getCurrencyBalance(); + + /** + * Sets the player's currency balance. + * If Vault is configured and available, sets Vault balance. + * Otherwise sets CNPC+ built-in currency balance. + * + * @param amount The new balance + */ + void setCurrencyBalance(long amount); + + /** + * Deposits (adds) currency to the player's balance. + * If Vault is configured and available, deposits to Vault. + * Otherwise deposits to CNPC+ built-in currency. + * + * @param amount The amount to deposit + * @return true if successful, false if would exceed max balance + */ + boolean depositCurrency(long amount); + + /** + * Withdraws (removes) currency from the player's balance. + * If Vault is configured and available, withdraws from Vault. + * Otherwise withdraws from CNPC+ built-in currency. + * + * @param amount The amount to withdraw + * @return true if successful, false if insufficient funds + */ + boolean withdrawCurrency(long amount); + + /** + * Checks if the player can afford the specified amount. + * If Vault is configured and available, checks Vault balance. + * Otherwise checks CNPC+ built-in currency balance. + * + * @param amount The amount to check + * @return true if the player has enough currency + */ + boolean canAffordCurrency(long amount); + + /** + * Checks if Vault is being used for currency operations. + * + * @return true if Vault is configured AND available, false if using CNPC+ built-in currency + */ + boolean isUsingVaultCurrency(); + + /** + * Gets the player's formatted currency balance for display. + * Uses Vault formatting if Vault is active, otherwise uses CNPC+ formatting. + * + * @return The formatted balance string + */ + String getFormattedCurrencyBalance(); } diff --git a/java/noppes/npcs/api/handler/IPlayerCurrencyData.java b/java/noppes/npcs/api/handler/IPlayerCurrencyData.java new file mode 100644 index 0000000..5e41452 --- /dev/null +++ b/java/noppes/npcs/api/handler/IPlayerCurrencyData.java @@ -0,0 +1,62 @@ +package noppes.npcs.api.handler; + +/** + * Interface for player currency data. + * Note: If Vault integration is enabled in config, these operations + * will use the Vault economy instead of CNPC+ built-in currency. + */ +public interface IPlayerCurrencyData { + + /** + * Get the current balance + */ + long getBalance(); + + /** + * Set the balance directly + * @param balance The new balance + */ + void setBalance(long balance); + + /** + * Add currency to balance (deposit) + * @param amount Amount to add + * @return true if successful, false if would exceed max balance + */ + boolean deposit(long amount); + + /** + * Remove currency from balance (withdraw) + * @param amount Amount to remove + * @return true if successful, false if insufficient funds + */ + boolean withdraw(long amount); + + /** + * Check if player can afford an amount + * @param amount Amount to check + * @return true if player has enough balance + */ + boolean canAfford(long amount); + + /** + * Get lifetime earned currency + */ + long getLifetimeEarned(); + + /** + * Get lifetime spent currency + */ + long getLifetimeSpent(); + + /** + * Format the balance for display + */ + String formatBalance(); + + /** + * Check if Vault is being used for currency operations + * @return true if Vault is handling currency, false if using CNPC+ built-in + */ + boolean isUsingVault(); +} diff --git a/java/noppes/npcs/api/handler/IPlayerData.java b/java/noppes/npcs/api/handler/IPlayerData.java index 88c1ce5..cbcb397 100644 --- a/java/noppes/npcs/api/handler/IPlayerData.java +++ b/java/noppes/npcs/api/handler/IPlayerData.java @@ -25,5 +25,7 @@ public interface IPlayerData { IPlayerMailData getMailData(); + IPlayerCurrencyData getCurrencyData(); + void save(); } diff --git a/java/noppes/npcs/api/roles/IRoleTrader.java b/java/noppes/npcs/api/roles/IRoleTrader.java index 69ee2b3..3f43146 100644 --- a/java/noppes/npcs/api/roles/IRoleTrader.java +++ b/java/noppes/npcs/api/roles/IRoleTrader.java @@ -116,4 +116,154 @@ public interface IRoleTrader extends IRole { * @param player */ void enableSlot(int slot, IPlayer player); + + // ==================== Stock System ==================== + + /** + * @return Whether stock system is enabled + */ + boolean isStockEnabled(); + + /** + * Enable or disable stock system + */ + void setStockEnabled(boolean enabled); + + /** + * @return Whether stock is tracked per-player (true) or globally (false) + */ + boolean isPerPlayerStock(); + + /** + * Set whether stock is per-player or global + */ + void setPerPlayerStock(boolean perPlayer); + + /** + * Get the stock reset type + * @return 0=NONE, 1=MCDAILY, 2=MCWEEKLY, 3=MCCUSTOM, 4=RLDAILY, 5=RLWEEKLY, 6=RLCUSTOM + */ + int getStockResetType(); + + /** + * Set stock reset type + * @param type 0=NONE, 1=MCDAILY, 2=MCWEEKLY, 3=MCCUSTOM, 4=RLDAILY, 5=RLWEEKLY, 6=RLCUSTOM + */ + void setStockResetType(int type); + + /** + * Get custom reset time (only used for MCCUSTOM/RLCUSTOM) + * @return Custom time in ticks (MC) or milliseconds (RL) + */ + long getCustomResetTime(); + + /** + * Set custom reset time + * @param time Time in ticks (MC) or milliseconds (RL) + */ + void setCustomResetTime(long time); + + /** + * Get max stock for a slot + * @param slot Slot number 0-17 + * @return Max stock, -1 = unlimited + */ + int getMaxStock(int slot); + + /** + * Set max stock for a slot + * @param slot Slot number 0-17 + * @param amount Max stock, -1 = unlimited + */ + void setMaxStock(int slot, int amount); + + /** + * Get available stock for a slot (global mode) + * @param slot Slot number 0-17 + * @return Available stock, Integer.MAX_VALUE if unlimited + */ + int getAvailableStock(int slot); + + /** + * Get available stock for a slot for a specific player (per-player mode) + * @param slot Slot number 0-17 + * @param player The player + * @return Available stock, Integer.MAX_VALUE if unlimited + */ + int getAvailableStock(int slot, IPlayer player); + + /** + * Reset all stock to max values + */ + void resetStock(); + + /** + * Reset the cooldown timer without resetting stock values + * Stock will reset on next trigger after this is called + */ + void resetCooldown(); + + /** + * Get current stock for a slot (global mode) + * @param slot Slot number 0-17 + * @return Current stock, -1 if not initialized + */ + int getCurrentStock(int slot); + + /** + * Set current stock for a slot (global mode only) + * @param slot Slot number 0-17 + * @param amount Current stock amount + */ + void setCurrentStock(int slot, int amount); + + /** + * Get purchased amount for a player in a slot (per-player mode) + * @param slot Slot number 0-17 + * @param player The player + * @return Purchased amount (stock available = maxStock - purchasedAmount) + */ + int getPlayerPurchased(int slot, IPlayer player); + + /** + * Set purchased amount for a player in a slot (per-player mode) + * @param slot Slot number 0-17 + * @param player The player + * @param amount Purchased amount + */ + void setPlayerPurchased(int slot, IPlayer player, int amount); + + /** + * Get the timestamp of the last stock reset + * @return Time in ticks (MC) or milliseconds (RL), depending on reset type + */ + long getLastResetTime(); + + /** + * Get time remaining until next stock reset + * @return Time remaining in ticks (MC) or milliseconds (RL), -1 if no reset scheduled + */ + long getTimeUntilReset(); + + // ==================== Currency Cost System ==================== + + /** + * Get the currency cost for a slot (additive to item costs) + * @param slot Slot number 0-17 + * @return Currency cost, 0 = no cost + */ + long getCurrencyCost(int slot); + + /** + * Set the currency cost for a slot (additive to item costs) + * @param slot Slot number 0-17 + * @param cost Currency cost, 0 = no cost + */ + void setCurrencyCost(int slot, long cost); + + /** + * @param slot Slot number 0-17 + * @return Whether this slot has a currency cost > 0 + */ + boolean hasCurrencyCost(int slot); }