mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 13:10:04 +00:00
Implement Phase 3: Item Attributes & Restrictions
- Add ItemTradeAttribute.java for trade restriction utilities - TAG_UNTRADEABLE for items that cannot be traded - Check existing TAG_PROFILE_SLOT and TAG_SOULBIND tags - canTrade() checks all three restriction types - getTradeBlockReason() returns localization key for UI - Utility methods for setting/getting each restriction type - clearAllRestrictions() and getRestrictionSummary() helpers - Add AuctionBlacklist.java controller - Blacklist items by registry name (e.g., "minecraft:diamond_sword") - Blacklist entire mods by mod ID (e.g., "minecraft") - Blacklist items with specific NBT tags (supports dot notation) - isBlacklisted() and getBlacklistReason() for checking - Persistence via auction_blacklist.dat - Add/remove methods for each blacklist type - Initialize AuctionBlacklist in CustomNpcs.java - Add scripting API methods to ScriptItemStack.java - canTrade() - check if item can be traded - getTradeBlockReason() - get block reason - isUntradeable() / setUntradeable() - manage untradeable flag - isProfileSlotBound() / getProfileSlot() / setProfileSlotBound() - isSoulbound() / getSoulbindOwner() / removeSoulbind() - clearTradeRestrictions() - remove all restrictions - getRestrictionSummary() - human-readable summary
This commit is contained in:
4 files changed
+843
No files matched your search
@@ -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