mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 20:07:32 +00:00
Implement Phase 1: Currency System foundation
- Add ConfigMarket.java with separate market.cfg config file - Currency settings (name, starting balance, max balance, Vault integration) - Auction settings (durations, fees, snipe protection, claim expiration) - Trader settings (stock system defaults) - Add PlayerCurrencyData.java for balance storage - NOT profile slot bound - shared across all slots - Tracks balance, lifetime earned, and lifetime spent - Deposit/withdraw with overflow protection - Add VaultHelper.java for Bukkit hybrid server integration - Reflection-based VaultAPI integration - Falls back to internal currency when Vault unavailable - Supports getBalance, deposit, withdraw, transfer operations - Add CurrencyController.java for currency operations - Claims system for auction refunds and NPC payments - Claim expiration with configurable days - Persistence via currency_claims.dat - Update PlayerData.java to integrate currency - Separate loadCurrency/saveCurrency methods - Currency file stored separately from slot data - Add scripting API methods to ScriptPlayer.java - getCurrencyBalance(), addCurrency(), removeCurrency() - canAffordCurrency(), getCurrencyName(), formatCurrency() - hasPendingClaims(), getPendingClaimsTotal(), claimAllCurrency()
This commit is contained in:
8 files changed
+1211
No files matched your search
@@ -49,11 +49,13 @@ import noppes.npcs.compat.PixelmonHelper;
|
||||
import noppes.npcs.config.ConfigScript;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.containers.ContainerCustomGui;
|
||||
import noppes.npcs.controllers.CurrencyController;
|
||||
import noppes.npcs.controllers.CustomGuiController;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerQuestController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.VaultHelper;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
@@ -895,4 +897,120 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
}
|
||||
return (IPlayer[]) list.toArray(new IPlayer[list.size()]);
|
||||
}
|
||||
|
||||
// ==================== CURRENCY METHODS ====================
|
||||
|
||||
/**
|
||||
* Get the player's current currency balance.
|
||||
* Uses Vault if available, otherwise uses internal currency system.
|
||||
* @return The player's currency balance
|
||||
* @since 1.11
|
||||
*/
|
||||
public long getCurrencyBalance() {
|
||||
if (CurrencyController.Instance == null) {
|
||||
return 0;
|
||||
}
|
||||
return CurrencyController.Instance.getBalance(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add currency to the player's balance.
|
||||
* @param amount The amount to add (must be positive)
|
||||
* @return true if successful, false if failed (e.g., would exceed max balance)
|
||||
* @since 1.11
|
||||
*/
|
||||
public boolean addCurrency(long amount) {
|
||||
if (CurrencyController.Instance == null) {
|
||||
return false;
|
||||
}
|
||||
return CurrencyController.Instance.deposit(player, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove currency from the player's balance.
|
||||
* @param amount The amount to remove (must be positive)
|
||||
* @return true if successful, false if insufficient funds
|
||||
* @since 1.11
|
||||
*/
|
||||
public boolean removeCurrency(long amount) {
|
||||
if (CurrencyController.Instance == null) {
|
||||
return false;
|
||||
}
|
||||
return CurrencyController.Instance.withdraw(player, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player can afford a specific amount.
|
||||
* @param amount The amount to check
|
||||
* @return true if player has sufficient balance
|
||||
* @since 1.11
|
||||
*/
|
||||
public boolean canAffordCurrency(long amount) {
|
||||
if (CurrencyController.Instance == null) {
|
||||
return false;
|
||||
}
|
||||
return CurrencyController.Instance.canAfford(player, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configured currency name (e.g., "Gold").
|
||||
* @return The currency name
|
||||
* @since 1.11
|
||||
*/
|
||||
public String getCurrencyName() {
|
||||
if (VaultHelper.Instance == null) {
|
||||
return "Currency";
|
||||
}
|
||||
return VaultHelper.Instance.getCurrencyName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a currency amount for display (e.g., "1,000 Gold").
|
||||
* @param amount The amount to format
|
||||
* @return Formatted string
|
||||
* @since 1.11
|
||||
*/
|
||||
public String formatCurrency(long amount) {
|
||||
if (CurrencyController.Instance == null) {
|
||||
return String.valueOf(amount);
|
||||
}
|
||||
return CurrencyController.Instance.formatAmount(amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player has pending currency claims.
|
||||
* Claims are created by auction refunds, NPC payments, etc.
|
||||
* @return true if there are pending claims
|
||||
* @since 1.11
|
||||
*/
|
||||
public boolean hasPendingClaims() {
|
||||
if (CurrencyController.Instance == null) {
|
||||
return false;
|
||||
}
|
||||
return CurrencyController.Instance.hasPendingClaims(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total amount of pending currency claims.
|
||||
* @return Total pending claim amount
|
||||
* @since 1.11
|
||||
*/
|
||||
public long getPendingClaimsTotal() {
|
||||
if (CurrencyController.Instance == null) {
|
||||
return 0;
|
||||
}
|
||||
return CurrencyController.Instance.getTotalPendingClaims(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Claim all pending currency claims and add them to balance.
|
||||
* @return The total amount claimed
|
||||
* @since 1.11
|
||||
*/
|
||||
public long claimAllCurrency() {
|
||||
if (CurrencyController.Instance == null) {
|
||||
return 0;
|
||||
}
|
||||
return CurrencyController.Instance.claimAll(player);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user