mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-25 20:24:30 +00:00
Auction Merge
This commit is contained in:
commit
04e2a57cb4
44 files changed
+7453
-1837
No files matched your search
@@ -49,11 +49,14 @@ import noppes.npcs.compat.PixelmonHelper;
|
||||
import noppes.npcs.config.ConfigScript;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.containers.ContainerCustomGui;
|
||||
import noppes.npcs.controllers.AuctionController;
|
||||
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 +898,186 @@ 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);
|
||||
}
|
||||
|
||||
// ==================== AUCTION METHODS ====================
|
||||
|
||||
/**
|
||||
* Get the number of active auction listings the player has.
|
||||
* @return Number of active listings
|
||||
* @since 1.11
|
||||
*/
|
||||
public int getAuctionListingCount() {
|
||||
if (AuctionController.Instance == null) {
|
||||
return 0;
|
||||
}
|
||||
return AuctionController.Instance.getActiveListingsCount(player.getUniqueID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum number of auction listings the player is allowed.
|
||||
* @return Maximum listing count
|
||||
* @since 1.11
|
||||
*/
|
||||
public int getMaxAuctionListings() {
|
||||
if (AuctionController.Instance == null) {
|
||||
return 0;
|
||||
}
|
||||
return AuctionController.Instance.getMaxListings(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player has auction items waiting to be claimed.
|
||||
* This includes won items, expired listings, and sale proceeds.
|
||||
* @return true if there are claimable items
|
||||
* @since 1.11
|
||||
*/
|
||||
public boolean hasAuctionClaims() {
|
||||
if (AuctionController.Instance == null) {
|
||||
return false;
|
||||
}
|
||||
return !AuctionController.Instance.getClaimableListings(player.getUniqueID()).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of auction items waiting to be claimed.
|
||||
* @return Number of claimable items/listings
|
||||
* @since 1.11
|
||||
*/
|
||||
public int getAuctionClaimCount() {
|
||||
if (AuctionController.Instance == null) {
|
||||
return 0;
|
||||
}
|
||||
return AuctionController.Instance.getClaimableListings(player.getUniqueID()).size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of auctions where the player is the current high bidder.
|
||||
* @return Number of active bids
|
||||
* @since 1.11
|
||||
*/
|
||||
public int getActiveAuctionBidCount() {
|
||||
if (AuctionController.Instance == null) {
|
||||
return 0;
|
||||
}
|
||||
return (int) AuctionController.Instance.getListingsAsBidder(player.getUniqueID())
|
||||
.stream()
|
||||
.filter(l -> l.isActive())
|
||||
.count();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.scripted.item;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import kamkeel.npcs.controllers.data.attribute.ItemTradeAttribute;
|
||||
import kamkeel.npcs.controllers.data.attribute.requirement.IRequirementChecker;
|
||||
import kamkeel.npcs.controllers.data.attribute.requirement.RequirementCheckerRegistry;
|
||||
import kamkeel.npcs.util.AttributeItemUtil;
|
||||
@@ -592,4 +593,117 @@ public class ScriptItemStack implements IItemStack {
|
||||
Set<String> keys = reqTag.func_150296_c();
|
||||
return keys.toArray(new String[keys.size()]);
|
||||
}
|
||||
|
||||
// ==================== Trade Restriction Methods ====================
|
||||
|
||||
/**
|
||||
* Check if this item can be traded or auctioned.
|
||||
* An item cannot be traded if it is:
|
||||
* - Marked as untradeable
|
||||
* - Bound to a profile slot
|
||||
* - Soulbound to a player
|
||||
* @return true if the item can be traded
|
||||
* @since 1.11
|
||||
*/
|
||||
public boolean canTrade() {
|
||||
return ItemTradeAttribute.canTrade(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reason why this item cannot be traded.
|
||||
* @return Localization key for the block reason, or null if tradeable
|
||||
* @since 1.11
|
||||
*/
|
||||
public String getTradeBlockReason() {
|
||||
return ItemTradeAttribute.getTradeBlockReason(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this item is marked as untradeable
|
||||
* @return true if untradeable
|
||||
* @since 1.11
|
||||
*/
|
||||
public boolean isUntradeable() {
|
||||
return ItemTradeAttribute.isUntradeable(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this item is untradeable
|
||||
* @param untradeable true to mark as untradeable
|
||||
* @since 1.11
|
||||
*/
|
||||
public void setUntradeable(boolean untradeable) {
|
||||
ItemTradeAttribute.setUntradeable(item, untradeable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this item is bound to a profile slot
|
||||
* @return true if profile slot bound
|
||||
* @since 1.11
|
||||
*/
|
||||
public boolean isProfileSlotBound() {
|
||||
return ItemTradeAttribute.isProfileSlotBound(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the profile slot this item is bound to
|
||||
* @return Profile slot ID, or -1 if not bound
|
||||
* @since 1.11
|
||||
*/
|
||||
public int getProfileSlot() {
|
||||
return ItemTradeAttribute.getProfileSlot(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind this item to a specific profile slot
|
||||
* @param slot The profile slot ID, or -1 to unbind
|
||||
* @since 1.11
|
||||
*/
|
||||
public void setProfileSlotBound(int slot) {
|
||||
ItemTradeAttribute.setProfileSlotBound(item, slot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this item is soulbound to any player
|
||||
* @return true if soulbound
|
||||
* @since 1.11
|
||||
*/
|
||||
public boolean isSoulbound() {
|
||||
return ItemTradeAttribute.isSoulbound(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UUID of the player this item is soulbound to
|
||||
* @return UUID string, or null if not soulbound
|
||||
* @since 1.11
|
||||
*/
|
||||
public String getSoulbindOwner() {
|
||||
return ItemTradeAttribute.getSoulbindOwner(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the soulbind from this item
|
||||
* @since 1.11
|
||||
*/
|
||||
public void removeSoulbind() {
|
||||
ItemTradeAttribute.removeSoulbind(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all trade restrictions from this item
|
||||
* (untradeable, profile slot bound, soulbound)
|
||||
* @since 1.11
|
||||
*/
|
||||
public void clearTradeRestrictions() {
|
||||
ItemTradeAttribute.clearAllRestrictions(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a summary of all trade restrictions on this item
|
||||
* @return Human-readable string of restrictions, or empty if none
|
||||
* @since 1.11
|
||||
*/
|
||||
public String getRestrictionSummary() {
|
||||
return ItemTradeAttribute.getRestrictionSummary(item);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user