Package noppes.npcs.api.roles
Interface IRoleTrader
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddisableSlot(int slot)prevent an item from being sold on that slotvoiddisableSlot(int slot, IPlayer player)disables the slot for this playervoidenableSlot(int slot)allow an item to be sold on that slotvoidenableSlot(int slot, IPlayer player)enables the slot for this playerintgetAvailableStock(int slot)Get available stock for a slot (global mode)intgetAvailableStock(int slot, IPlayer player)Get available stock for a slot for a specific player (per-player mode)IItemStack[]getCurrency(int slot)longgetCurrencyCost(int slot)Get the currency cost for a slot (additive to item costs)intgetCurrentStock(int slot)Get current stock for a slot (global mode)longgetCustomResetTime()Get custom reset time (only used for MCCUSTOM/RLCUSTOM)longgetLastResetTime()Get the timestamp of the last stock resetStringgetMarket()intgetMaxStock(int slot)Get max stock for a slotintgetPlayerPurchased(int slot, IPlayer player)Get purchased amount for a player in a slot (per-player mode)intgetPurchaseNum(int slot)intgetPurchaseNum(int slot, IPlayer player)IItemStackgetSellOption(int slot)intgetStockResetType()Get the stock reset typelonggetTimeUntilReset()Get time remaining until next stock resetbooleanhasCurrencyCost(int slot)booleanisPerPlayerStock()booleanisSlotEnabled(int slot)booleanisSlotEnabled(int slot, IPlayer player)booleanisStockEnabled()voidremoveSellOption(int slot)voidresetCooldown()Reset the cooldown timer without resetting stock values Stock will reset on next trigger after this is calledvoidresetPurchaseNum()Sets the purchase count of all slots to 0voidresetPurchaseNum(int slot)sets the purchase num for that slot to 0voidresetPurchaseNum(int slot, IPlayer player)sets the purchase num for that slot and player to 0voidresetStock()Reset all stock to max valuesvoidsetCurrencyCost(int slot, long cost)Set the currency cost for a slot (additive to item costs)voidsetCurrentStock(int slot, int amount)Set current stock for a slot (global mode only)voidsetCustomResetTime(long time)Set custom reset timevoidsetMarket(String name)voidsetMaxStock(int slot, int amount)Set max stock for a slotvoidsetPerPlayerStock(boolean perPlayer)Set whether stock is per-player or globalvoidsetPlayerPurchased(int slot, IPlayer player, int amount)Set purchased amount for a player in a slot (per-player mode)voidsetSellOption(int slot, IItemStack currency, IItemStack sold)voidsetSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold)voidsetStockEnabled(boolean enabled)Enable or disable stock systemvoidsetStockResetType(int type)Set stock reset type
-
-
-
Method Detail
-
setSellOption
void setSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold)- Parameters:
slot- Slot number 0-17currency- Currency itemcurrency2- Currency item number twosold- Item to be sold by this npc
-
setSellOption
void setSellOption(int slot, IItemStack currency, IItemStack sold)- Parameters:
slot- Slot number 0-17currency- Currency itemsold- Item to be sold by this npc
-
getSellOption
IItemStack getSellOption(int slot)
- Parameters:
slot-- Returns:
- The item being sold in this slot.
-
getCurrency
IItemStack[] getCurrency(int slot)
- Parameters:
slot-- Returns:
- a ScriptItemStack array of size 2 which contains the currency of this trade
-
removeSellOption
void removeSellOption(int slot)
- Parameters:
slot- Slot number 0-17
-
setMarket
void setMarket(String name)
- Parameters:
name- The trader Linked Market name
-
getMarket
String getMarket()
- Returns:
- Get the currently set Linked Market name
-
getPurchaseNum
int getPurchaseNum(int slot)
- Parameters:
slot-- Returns:
- the number of times an item has been sold on that slot
-
getPurchaseNum
int getPurchaseNum(int slot, IPlayer player)- Parameters:
slot-player-- Returns:
- the number of times this player has purchased from this trader
-
resetPurchaseNum
void resetPurchaseNum()
Sets the purchase count of all slots to 0
-
resetPurchaseNum
void resetPurchaseNum(int slot)
sets the purchase num for that slot to 0- Parameters:
slot-
-
resetPurchaseNum
void resetPurchaseNum(int slot, IPlayer player)sets the purchase num for that slot and player to 0- Parameters:
slot-player-
-
isSlotEnabled
boolean isSlotEnabled(int slot)
- Parameters:
slot-- Returns:
- if this slot is enabled
-
isSlotEnabled
boolean isSlotEnabled(int slot, IPlayer player)- Parameters:
slot-player-- Returns:
- if this slot is enabled for this player
-
disableSlot
void disableSlot(int slot)
prevent an item from being sold on that slot- Parameters:
slot-
-
disableSlot
void disableSlot(int slot, IPlayer player)disables the slot for this player- Parameters:
slot-player-
-
enableSlot
void enableSlot(int slot)
allow an item to be sold on that slot- Parameters:
slot-
-
enableSlot
void enableSlot(int slot, IPlayer player)enables the slot for this player- Parameters:
slot-player-
-
isStockEnabled
boolean isStockEnabled()
- Returns:
- Whether stock system is enabled
-
setStockEnabled
void setStockEnabled(boolean enabled)
Enable or disable stock system
-
isPerPlayerStock
boolean isPerPlayerStock()
- Returns:
- Whether stock is tracked per-player (true) or globally (false)
-
setPerPlayerStock
void setPerPlayerStock(boolean perPlayer)
Set whether stock is per-player or global
-
getStockResetType
int getStockResetType()
Get the stock reset type- Returns:
- 0=NONE, 1=MCDAILY, 2=MCWEEKLY, 3=MCCUSTOM, 4=RLDAILY, 5=RLWEEKLY, 6=RLCUSTOM
-
setStockResetType
void setStockResetType(int type)
Set stock reset type- Parameters:
type- 0=NONE, 1=MCDAILY, 2=MCWEEKLY, 3=MCCUSTOM, 4=RLDAILY, 5=RLWEEKLY, 6=RLCUSTOM
-
getCustomResetTime
long getCustomResetTime()
Get custom reset time (only used for MCCUSTOM/RLCUSTOM)- Returns:
- Custom time in ticks (MC) or milliseconds (RL)
-
setCustomResetTime
void setCustomResetTime(long time)
Set custom reset time- Parameters:
time- Time in ticks (MC) or milliseconds (RL)
-
getMaxStock
int getMaxStock(int slot)
Get max stock for a slot- Parameters:
slot- Slot number 0-17- Returns:
- Max stock, -1 = unlimited
-
setMaxStock
void setMaxStock(int slot, int amount)Set max stock for a slot- Parameters:
slot- Slot number 0-17amount- Max stock, -1 = unlimited
-
getAvailableStock
int getAvailableStock(int slot)
Get available stock for a slot (global mode)- Parameters:
slot- Slot number 0-17- Returns:
- Available stock, Integer.MAX_VALUE if unlimited
-
getAvailableStock
int getAvailableStock(int slot, IPlayer player)Get available stock for a slot for a specific player (per-player mode)- Parameters:
slot- Slot number 0-17player- The player- Returns:
- Available stock, Integer.MAX_VALUE if unlimited
-
resetStock
void resetStock()
Reset all stock to max values
-
resetCooldown
void resetCooldown()
Reset the cooldown timer without resetting stock values Stock will reset on next trigger after this is called
-
getCurrentStock
int getCurrentStock(int slot)
Get current stock for a slot (global mode)- Parameters:
slot- Slot number 0-17- Returns:
- Current stock, -1 if not initialized
-
setCurrentStock
void setCurrentStock(int slot, int amount)Set current stock for a slot (global mode only)- Parameters:
slot- Slot number 0-17amount- Current stock amount
-
getPlayerPurchased
int getPlayerPurchased(int slot, IPlayer player)Get purchased amount for a player in a slot (per-player mode)- Parameters:
slot- Slot number 0-17player- The player- Returns:
- Purchased amount (stock available = maxStock - purchasedAmount)
-
setPlayerPurchased
void setPlayerPurchased(int slot, IPlayer player, int amount)Set purchased amount for a player in a slot (per-player mode)- Parameters:
slot- Slot number 0-17player- The playeramount- Purchased amount
-
getLastResetTime
long getLastResetTime()
Get the timestamp of the last stock reset- Returns:
- Time in ticks (MC) or milliseconds (RL), depending on reset type
-
getTimeUntilReset
long getTimeUntilReset()
Get time remaining until next stock reset- Returns:
- Time remaining in ticks (MC) or milliseconds (RL), -1 if no reset scheduled
-
getCurrencyCost
long getCurrencyCost(int slot)
Get the currency cost for a slot (additive to item costs)- Parameters:
slot- Slot number 0-17- Returns:
- Currency cost, 0 = no cost
-
setCurrencyCost
void setCurrencyCost(int slot, long cost)Set the currency cost for a slot (additive to item costs)- Parameters:
slot- Slot number 0-17cost- Currency cost, 0 = no cost
-
hasCurrencyCost
boolean hasCurrencyCost(int slot)
- Parameters:
slot- Slot number 0-17- Returns:
- Whether this slot has a currency cost > 0
-
-