Atavism Version 2018.1AGIS API

atavism.agis.plugins
Class AgisInventoryPlugin

java.lang.Object
  extended by atavism.server.engine.EnginePlugin
      extended by atavism.server.plugins.InventoryPlugin
          extended by atavism.agis.plugins.AgisInventoryPlugin
All Implemented Interfaces:
MessageCallback, StatusMapCallback

public class AgisInventoryPlugin
extends InventoryPlugin
implements MessageCallback

The AgisInventoryPlugin is the manager of Inventory for players and mobs and all related areas such as Trading, Looting, and Mail. The Plugin creates and works with the Inventory Sub Object, which contains the players inventory (their bags, mailbox and eventually their bank). The Plugin is set up with Hooks for many Inventory related messages and loads in the players inventory sub object to get the information requested or make the changes needed.

Author:
Andrew Harrison

Nested Class Summary
 class AgisInventoryPlugin.CancelTradeInviteTimer
           
 class AgisInventoryPlugin.CategoryUpdatedHook
          Handles the CategoryUpdatedMessage to indicate the player has changed world category.
protected  class AgisInventoryPlugin.CreateInventoryHook
          Hook for the CreateInventoryMessage.
static class AgisInventoryPlugin.EquipMap
          Helper class used to track what item can be equipped in what slot.
static class AgisInventoryPlugin.ItemAcquireResult
           
 class AgisInventoryPlugin.LockpickHook
           
 
Nested classes/interfaces inherited from class atavism.server.engine.EnginePlugin
EnginePlugin.DeleteHook, EnginePlugin.DeleteSubObjHook, EnginePlugin.GenerateSubObjectHook, EnginePlugin.GetPropertyMessage, EnginePlugin.GetPropertyNamesMessage, EnginePlugin.LoadHook, EnginePlugin.LoadSubObjHook, EnginePlugin.PluginActivateHook, EnginePlugin.PluginStateMessage, EnginePlugin.SaveHook, EnginePlugin.SaveSubObjHook, EnginePlugin.SetPropertyMessage, EnginePlugin.SubObjData, EnginePlugin.TransferFilter, EnginePlugin.TransferObjectMessage, EnginePlugin.UnloadHook, EnginePlugin.UnloadSubObjHook
 
Field Summary
static AccountDatabase aDB
           
static AuthDatabase authDB
           
static int BANK_EXTRA_BAGS_COUNT
           
static int BANK_SLOTS_COUNT
           
static java.lang.String bankBagKey
           
 boolean DURABILITY_DESTROY_BROKEN_ITEMS
           
 int DURABILITY_LOSS_CHANCE_FROM_ATTACK
           
 int DURABILITY_LOSS_CHANCE_FROM_CRAFT
           
 int DURABILITY_LOSS_CHANCE_FROM_DEFEND
           
 int DURABILITY_LOSS_CHANCE_FROM_GATHER
           
static java.lang.String EQUIP_MAP_PROP
           
 int EQUIP_SLOTS_COUNT
           
static java.util.HashMap<java.lang.String,java.lang.Float> equipmentSlots
          Maps and constants
static boolean GIVE_QUEST_ITEMS_TO_ALL_IN_GROUP
           
static int INVENTORY_BAG_COUNT
           
 int INVENTORY_FIRST_BAG_SIZE
           
 int INVENTORY_OTHER_BAG_SIZE
           
static java.util.ArrayList<ItemWeight> itemPrefixes
           
static java.util.ArrayList<ItemWeight> itemSuffixes
           
static int MAIL_ATTACHMENT_COUNT
           
static int MAIL_COD_LIFE_DAYS
           
static int MAIL_LIFE_DAYS
           
 boolean PLAYER_CORPSE_DROPS_EQUIPMENT
           
 int PLAYER_CORPSE_LOOT_DURATION
           
 int PLAYER_CORPSE_MOB_TEMPLATE
           
 int PLAYER_CORPSE_SAFE_LOOT_DURATION
           
static java.util.Random random
           
static float REPAIR_RATE
           
static float SELL_FACTOR
           
static int TRADE_INVITE_TIMEOUT
           
 
Fields inherited from class atavism.server.plugins.InventoryPlugin
INVENTORY_PLUGIN_NAME, INVENTORY_PROP_BACKREF_KEY, INVENTORY_PROP_BAG_KEY, lock
 
Fields inherited from class atavism.server.engine.EnginePlugin
deleteSubObjectSubscription, dumpAllThreadSubscription, dumpAllThreadSubscriptionLock, loadSubObjectSubscription, MSG_TYPE_DUMP_ALL_THREAD_STACKS, MSG_TYPE_GET_PROPERTY, MSG_TYPE_GET_PROPERTY_NAMES, MSG_TYPE_PLUGIN_STATE, MSG_TYPE_SET_PROPERTY, MSG_TYPE_SET_PROPERTY_NONBLOCK, MSG_TYPE_TRANSFER_OBJECT, pluginStateSubscription, propertySubscription, saveSubObjectSubscription, selectionFilter, selectionSubscription, setSubObjectPersistenceSubscription, subObjectSubscription, unloadSubObjectSubscription
 
Fields inherited from interface atavism.msgsys.MessageCallback
NO_FLAGS, RESPONSE_EXPECTED
 
Constructor Summary
AgisInventoryPlugin()
           
 
Method Summary
protected  AgisInventoryPlugin.ItemAcquireResult accountItemAcquired(OID oid, int templateID, int count)
          Old function that should be deleted.
protected  boolean activateObject(OID objOid, OID activatorOid, OID targetOid)
          Activates the item.
protected  boolean addItem(OID mobOid, OID rootBagOid, OID itemOid)
          adds the item to the container item must not be in a container already sets the item's containedBy backlink to the container
protected  boolean addItemHelper(OID ownerOid, OID subBagOid, int slotNum, AgisItem item)
          Helper function for the addItem function.
 void alterMobCurrency(OID mobOid, int currencyID, int delta)
          Changes the amount of the specified currency for the player by the specified amount.
 void completeTrade(TradeSession tradeSession)
          Completes the Trade moving the items offered between the two players.
protected  boolean containsItem(OID mobOid, OID itemOid)
          Returns whether or not the mob contains the given item
protected  void createBags(InventoryInfo iInfo, OID mobOid, boolean isPlayer)
          Creates a new set of Bags and inventory to be placed in an existing InventoryInfo.
protected  void createInventoryItems(OID masterOid, InventoryInfo iInfo, java.lang.String invItems)
          Generates the items requested and puts them in the players/mobs inventory.
 EnginePlugin.SubObjData createInvSubObj(OID mobOid, Template template)
          Creates the InventoryInfo for the for the specified player/mob.
protected  EnginePlugin.SubObjData createItemSubObj(OID masterOid, Template template)
          Creates an AgisItem from the Template specified.
protected  void deleteInventory(Entity e)
          Deletes a InventoryInfo object from the internal object database.
protected  void deleteItem(Entity item)
          Deletes an AgisItem from the internal object database.
 boolean equipItem(AOObject itemObj, OID activatorOid, boolean replace)
           
 boolean equipItem(AOObject itemObj, OID activatorOid, boolean replace, AgisEquipSlot targetSlot)
          Equips the item to its primary slot on the player/mob.
protected  OID findItem(OID mobOid, AgisEquipSlot slot)
          Finds an equipped item
protected  OID findItem(OID mobOid, int templateID)
          finds an item based on the template name
protected  boolean findItemHelper(OID mobOid, InventoryInfo iInfo, int templateID, java.util.ArrayList<OID> resultList)
          Helper function for the findItem and findItems functions.
protected  java.util.ArrayList<OID> findItems(OID mobOid, java.util.ArrayList<java.lang.Integer> templateList)
          Finds items in the players inventory that match one of the template IDs specified.
protected  java.util.ArrayList<OID> findItemStacks(OID mobOid, int templateID)
          Finds all stacks of items matching the templateID that the player has.
protected  void findItemStacksHelper(OID mobOid, InventoryInfo iInfo, int templateID, java.util.ArrayList<OID> resultList)
          Helper function for the findItemStacks function.
static AgisItem getAgisItem(OID oid)
          Returns the AgisItem Entity for the specified OID.
static java.util.List<java.lang.Float> getArmourSlotModifier(java.lang.String armourSlot)
           
static java.util.List<java.lang.Float> getArmourTypeModifier(java.lang.String armourType)
           
static Bag getBag(OID activatorOid)
          Returns the Bag Entity for the specified OID.
 AgisInventoryPlugin.EquipMap getEquipMap(OID activatorOid)
          Gets the EquipMap for the player/mob.
static float getGradeModifier(int grade)
           
static InventoryInfo getInventoryInfo(OID oid)
          Returns the InventoryInfo Entity for the specified OID.
 int getMobCurrency(OID mobOid, int currencyID)
          Gets the amount of the specified currency the mob specified has.
static float getSlotModifier(java.lang.String slot)
           
static float getStatModifier(java.lang.String statName)
           
 boolean hasSpace(OID looterOid, java.util.HashMap<java.lang.Integer,java.lang.Integer> items, int invType)
          Checks if the player has enough space in their inventory for the items being added.
 boolean hasSpace(OID looterOid, int itemID, int count, int invType)
          Checks if the player has enough space in their inventory for the items being added.
 boolean isItemEquipped(AOObject itemObj, OID activatorOid)
          Checks if the item specified is equipped by the player.
protected  void loadInventory(Entity e)
          Loads the players inventory from the internal object database then sends down the inventory information to their client.
protected  void loadItem(Entity e)
          Does nothing.
 void loadItemsFromDatabase(ItemDatabase iDB)
          Loads in item templates from the database and registers them.
protected  void loadMailItems(OID oid)
           
protected  boolean loadSubBag(OID subBagOid, Entity rootBag)
          Loads a Bag that resides inside another Bag from the internal object database.
protected  boolean lootAll(OID looterOid, OID mobOid)
          NOT USED.
protected  boolean lootAllHelper(OID looterOid, Bag looterRootBag, OID mobOid, Bag mobRootBag, Bag mobSubBag)
           
 void onActivate()
          Run on activation, this function sets up the Hooks and filters for the messages the plugin deals with.
 boolean placeEquippedItem(OID activatorOid, OID itemOid, AgisEquipSlot slot)
          Places an equipped item in the correct slot that it belongs in
static void registerAgisItem(AgisItem item)
          Registers the AgisItem in the Item Namespace.
static void registerBag(Bag bag)
          Registers the Bag Entity in the Bag Namespace.
static void registerInventoryInfo(InventoryInfo iInfo)
          Registers the InventoryInfo in the Item Namespace.
protected  java.util.ArrayList<OID> removeAllItems(OID mobOid)
          Removes all items from the players inventory that match one of the template IDs specified.
 boolean removeEquippedItem(OID activatorOid, OID itemOid, AgisEquipSlot slot)
          Removes an equipped item from the equipped items bag
protected  OID removeItem(OID mobOid, int template, boolean removeFromPlayer)
          Removes an item from the players inventory that matches the specified templateID
protected  OID removeItem(OID mobOid, OID itemOid, boolean removeFromPlayer)
          Removes the specified item from the player.
protected  boolean removeItemFromBag(OID rootBagOid, OID itemOid)
          Removes an item from a Bag.
protected  boolean removeItemFromBagHelper(OID subBagOid, Entity item)
          Helper function for the removeItemFromBag function.
protected  OID removeItemFromStorage(OID mobOid, OID itemOid, boolean removeFromPlayer)
           
protected  java.util.ArrayList<OID> removeItems(OID mobOid, java.util.ArrayList<java.lang.Integer> templateList, boolean removeFromPlayer)
          Removes all items from the players inventory that match one of the template IDs specified.
protected  void saveInventory(Entity e, Namespace namespace)
          Saves an InventoryInfo object into the internal object database.
protected  void saveItem(Entity e, Namespace namespace)
          Does nothing.
protected  void sendBagInvUpdate(OID mobOid)
          Sends down the Bags and Items found in the players Inventory.
protected  void sendBankInvUpdate(OID mobOid, java.lang.String storageKey, OID storageBagOid)
          Sends down the Bags and Items found in the players Inventory.
protected  void sendEquippedInvUpdate(OID mobOid)
          Sends the equipped inventory bag information to the player.
protected  void sendInvUpdate(OID mobOid)
          Calls the sendEquippedInvUpdate and the sendBagInvUpdate functions.
 void sendLockpickLootList(OID playerOid, OID itemOid, OID bagOid, int count)
          Sends down the picked item as loot to the requesting player.
 void sendLootList(OID playerOid, OID mobOid)
          Sends down the list of loot from the specified mob to the requesting player.
protected  void sendStorageInvUpdate(OID mobOid)
          Sends down the Bags and Items found in the players Inventory.
protected static void sendTradeComplete(OID trader1, OID trader2, byte status)
          send an ao.TRADE_COMPLETE message to trader1, telling it that a trade with trader2 has completed
static void sendTradeOfferUpdate(OID trader1, OID trader2, TradeSession tradeSession)
          Sends down the updated list of offers to players involved in the Trade.
protected static java.util.ArrayList<java.util.ArrayList> sendTradeOfferUpdateHelper(OID traderOid, TradeSession tradeSession)
          Helper function for the sendTradeOfferUpdate function.
protected static void sendTradeStart(OID trader1, OID trader2)
          sends an ao.TRADE_START message to trader1 telling it that a trade has started with trader2
 void setDirty(OID mobOid)
          Sets the InventoryInfo for the player to dirty causing it to be saved to the internal object database.
protected  void swapItemPositions(OID playerOid, OID itemOid, int bagNum2, int slotNum2)
          Swaps the bag/slots of two items.
 void swapLockPositions(OID playerOid, OID itemOid, int itemAmount, int bagNum, int slotNum)
          Swaps the bag/slots of two locks.
 boolean unequipItem(AOObject itemObj, OID activatorOid, boolean isReplaced)
           
 boolean unequipItem(AOObject itemObj, OID activatorOid, boolean isReplaced, Bag targetBag, int slotNum, boolean destroyItem)
          Unequips the specified item.
 boolean unequipItem(AOObject itemObj, OID activatorOid, boolean isReplaced, boolean destroyItem)
           
protected  void unloadInventory(Entity e)
          Unloads the players inventory object.
protected  void unloadItem(Entity e)
          DOes nothing.
 void updateObject(OID mobOid, OID target)
          Called when an object is updated, sending information about the inventory to the client.
 boolean validateTradeCurrencyOffer(OID trader, java.util.HashMap<java.lang.String,java.lang.Integer> currencyOffer)
          Ensures the items offered in the Trade are valid.
 boolean validateTradeOffer(OID trader, java.util.List<OID> offer)
          Ensures the items offered in the Trade are valid.
 
Methods inherited from class atavism.server.plugins.InventoryPlugin
deleteInventory, deleteItem, destroyItem, getLock, registerHooks
 
Methods inherited from class atavism.server.engine.EnginePlugin
activate, createMBeanInstance, createSubscription, getHookManager, getMessageHandler, getName, getObjectLockManager, getObjectProperties, getObjectProperties, getObjectProperty, getObjectPropertyNames, getPercentCPULoad, getPluginAvailable, getPluginInfo, getPluginNamespaces, getPluginState, getPluginStatus, getPluginType, getPropertyImpl, getPropertyNamesImpl, getStatusMap, handleMessage, handleMessageImpl, logDepsOutstanding, processKeysAndValues, registerActivateHook, registerDeleteHook, registerLoadHook, registerPluginNamespace, registerPluginNamespaces, registerPluginNamespaces, registerPluginNamespaces, registerSaveHook, registerTransferHook, registerUnloadHook, sendSubObjectResponse, sendSubObjectResponse, sendSubObjectResponse, setMessageHandler, setName, setObjectProperties, setObjectProperties, setObjectProperties, setObjectPropertiesNoResponse, setObjectPropertiesNoResponse, setObjectPropertiesNoResponse, setObjectProperty, setObjectPropertyNoResponse, setPercentCPULoad, setPluginAvailable, setPluginInfo, setPluginType, setPropertyImpl, transferObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface atavism.msgsys.MessageCallback
handleMessage
 

Field Detail

EQUIP_MAP_PROP

public static final java.lang.String EQUIP_MAP_PROP
See Also:
Constant Field Values

equipmentSlots

public static java.util.HashMap<java.lang.String,java.lang.Float> equipmentSlots
Maps and constants


itemPrefixes

public static java.util.ArrayList<ItemWeight> itemPrefixes

itemSuffixes

public static java.util.ArrayList<ItemWeight> itemSuffixes

random

public static java.util.Random random

TRADE_INVITE_TIMEOUT

public static int TRADE_INVITE_TIMEOUT

INVENTORY_BAG_COUNT

public static int INVENTORY_BAG_COUNT

INVENTORY_FIRST_BAG_SIZE

public int INVENTORY_FIRST_BAG_SIZE

INVENTORY_OTHER_BAG_SIZE

public int INVENTORY_OTHER_BAG_SIZE

EQUIP_SLOTS_COUNT

public int EQUIP_SLOTS_COUNT

MAIL_ATTACHMENT_COUNT

public static int MAIL_ATTACHMENT_COUNT

MAIL_LIFE_DAYS

public static int MAIL_LIFE_DAYS

MAIL_COD_LIFE_DAYS

public static int MAIL_COD_LIFE_DAYS

SELL_FACTOR

public static float SELL_FACTOR

REPAIR_RATE

public static float REPAIR_RATE

PLAYER_CORPSE_LOOT_DURATION

public int PLAYER_CORPSE_LOOT_DURATION

PLAYER_CORPSE_SAFE_LOOT_DURATION

public int PLAYER_CORPSE_SAFE_LOOT_DURATION

PLAYER_CORPSE_MOB_TEMPLATE

public int PLAYER_CORPSE_MOB_TEMPLATE

PLAYER_CORPSE_DROPS_EQUIPMENT

public boolean PLAYER_CORPSE_DROPS_EQUIPMENT

DURABILITY_LOSS_CHANCE_FROM_ATTACK

public int DURABILITY_LOSS_CHANCE_FROM_ATTACK

DURABILITY_LOSS_CHANCE_FROM_DEFEND

public int DURABILITY_LOSS_CHANCE_FROM_DEFEND

DURABILITY_LOSS_CHANCE_FROM_GATHER

public int DURABILITY_LOSS_CHANCE_FROM_GATHER

DURABILITY_LOSS_CHANCE_FROM_CRAFT

public int DURABILITY_LOSS_CHANCE_FROM_CRAFT

DURABILITY_DESTROY_BROKEN_ITEMS

public boolean DURABILITY_DESTROY_BROKEN_ITEMS

GIVE_QUEST_ITEMS_TO_ALL_IN_GROUP

public static boolean GIVE_QUEST_ITEMS_TO_ALL_IN_GROUP

BANK_SLOTS_COUNT

public static int BANK_SLOTS_COUNT

BANK_EXTRA_BAGS_COUNT

public static int BANK_EXTRA_BAGS_COUNT

bankBagKey

public static final java.lang.String bankBagKey
See Also:
Constant Field Values

aDB

public static AccountDatabase aDB

authDB

public static AuthDatabase authDB
Constructor Detail

AgisInventoryPlugin

public AgisInventoryPlugin()
Method Detail

onActivate

public void onActivate()
Run on activation, this function sets up the Hooks and filters for the messages the plugin deals with.

Overrides:
onActivate in class InventoryPlugin

loadItemsFromDatabase

public void loadItemsFromDatabase(ItemDatabase iDB)
Loads in item templates from the database and registers them.

Parameters:
iDB -

getAgisItem

public static AgisItem getAgisItem(OID oid)
Returns the AgisItem Entity for the specified OID.

Parameters:
oid -
Returns:

registerAgisItem

public static void registerAgisItem(AgisItem item)
Registers the AgisItem in the Item Namespace. Used when creating the AgisItem SubObject.

Parameters:
item -

getInventoryInfo

public static InventoryInfo getInventoryInfo(OID oid)
Returns the InventoryInfo Entity for the specified OID. The InventoryInfo contains the information about a player/mobs inventory such as what bags and items they have.

Parameters:
oid -
Returns:

registerInventoryInfo

public static void registerInventoryInfo(InventoryInfo iInfo)
Registers the InventoryInfo in the Item Namespace. Used when creating the InventoryInfo SubObject for a player/mob.

Parameters:
iInfo -

getBag

public static Bag getBag(OID activatorOid)
Returns the Bag Entity for the specified OID.

Parameters:
activatorOid -
Returns:

registerBag

public static void registerBag(Bag bag)
Registers the Bag Entity in the Bag Namespace. Used when a new Bag is being created.

Parameters:
bag -

createInvSubObj

public EnginePlugin.SubObjData createInvSubObj(OID mobOid,
                                               Template template)
Creates the InventoryInfo for the for the specified player/mob. Takes in a template as well, applying the relevant properties from the template to the InventoryInfo. returns the bag, or null on failure

Specified by:
createInvSubObj in class InventoryPlugin

createBags

protected void createBags(InventoryInfo iInfo,
                          OID mobOid,
                          boolean isPlayer)
Creates a new set of Bags and inventory to be placed in an existing InventoryInfo.

Parameters:
iInfo -
mobOid -

createInventoryItems

protected void createInventoryItems(OID masterOid,
                                    InventoryInfo iInfo,
                                    java.lang.String invItems)
Generates the items requested and puts them in the players/mobs inventory. Called when first creating an Inventory SubObject.

Parameters:
masterOid -
iInfo -
invItems - A String with numbers representing the templateIDs of the items to be generated split by semicolons.

sendInvUpdate

protected void sendInvUpdate(OID mobOid)
Calls the sendEquippedInvUpdate and the sendBagInvUpdate functions.

Specified by:
sendInvUpdate in class InventoryPlugin

sendBagInvUpdate

protected void sendBagInvUpdate(OID mobOid)
Sends down the Bags and Items found in the players Inventory.

Parameters:
mobOid -

sendEquippedInvUpdate

protected void sendEquippedInvUpdate(OID mobOid)
Sends the equipped inventory bag information to the player.

Parameters:
mobOid -

swapItemPositions

protected void swapItemPositions(OID playerOid,
                                 OID itemOid,
                                 int bagNum2,
                                 int slotNum2)
Swaps the bag/slots of two items. Takes in the itemOid of the item to move, then the bagNum and slotNum to move it to, finds the item in that location then makes the switch.

Parameters:
playerOid -
itemOid -
bagNum2 -
slotNum2 -

getMobCurrency

public int getMobCurrency(OID mobOid,
                          int currencyID)
Gets the amount of the specified currency the mob specified has.

Parameters:
mobOid -
currencyID -
Returns:

alterMobCurrency

public void alterMobCurrency(OID mobOid,
                             int currencyID,
                             int delta)
Changes the amount of the specified currency for the player by the specified amount.

Parameters:
mobOid -
currencyID -
delta -

accountItemAcquired

protected AgisInventoryPlugin.ItemAcquireResult accountItemAcquired(OID oid,
                                                                    int templateID,
                                                                    int count)
Old function that should be deleted. Do not use.

Parameters:
oid -
templateID -
count -
Returns:

sendTradeComplete

protected static void sendTradeComplete(OID trader1,
                                        OID trader2,
                                        byte status)
send an ao.TRADE_COMPLETE message to trader1, telling it that a trade with trader2 has completed


sendTradeStart

protected static void sendTradeStart(OID trader1,
                                     OID trader2)
sends an ao.TRADE_START message to trader1 telling it that a trade has started with trader2


validateTradeOffer

public boolean validateTradeOffer(OID trader,
                                  java.util.List<OID> offer)
Ensures the items offered in the Trade are valid. Checks there are no doubles, and that the Trader does have the items.

Parameters:
trader -
offer -
Returns:

validateTradeCurrencyOffer

public boolean validateTradeCurrencyOffer(OID trader,
                                          java.util.HashMap<java.lang.String,java.lang.Integer> currencyOffer)
Ensures the items offered in the Trade are valid. Checks there are no doubles, and that the Trader does have the items.

Parameters:
trader -
offer -
Returns:

sendTradeOfferUpdate

public static void sendTradeOfferUpdate(OID trader1,
                                        OID trader2,
                                        TradeSession tradeSession)
Sends down the updated list of offers to players involved in the Trade.

Parameters:
trader1 -
trader2 -
tradeSession -

sendTradeOfferUpdateHelper

protected static java.util.ArrayList<java.util.ArrayList> sendTradeOfferUpdateHelper(OID traderOid,
                                                                                     TradeSession tradeSession)
Helper function for the sendTradeOfferUpdate function.

Parameters:
traderOid -
tradeSession -
Returns:

completeTrade

public void completeTrade(TradeSession tradeSession)
Completes the Trade moving the items offered between the two players.

Parameters:
tradeSession -

createItemSubObj

protected EnginePlugin.SubObjData createItemSubObj(OID masterOid,
                                                   Template template)
Creates an AgisItem from the Template specified.

Specified by:
createItemSubObj in class InventoryPlugin

loadInventory

protected void loadInventory(Entity e)
Loads the players inventory from the internal object database then sends down the inventory information to their client.

Specified by:
loadInventory in class InventoryPlugin

loadSubBag

protected boolean loadSubBag(OID subBagOid,
                             Entity rootBag)
Loads a Bag that resides inside another Bag from the internal object database.

Parameters:
subBagOid -
rootBag -
Returns:

loadMailItems

protected void loadMailItems(OID oid)

unloadInventory

protected void unloadInventory(Entity e)
Unloads the players inventory object. If the root bag is dirty it is saved before being unloaded.

Specified by:
unloadInventory in class InventoryPlugin

deleteInventory

protected void deleteInventory(Entity e)
Deletes a InventoryInfo object from the internal object database.

Specified by:
deleteInventory in class InventoryPlugin

loadItem

protected void loadItem(Entity e)
Does nothing.

Specified by:
loadItem in class InventoryPlugin

unloadItem

protected void unloadItem(Entity e)
DOes nothing.

Specified by:
unloadItem in class InventoryPlugin

deleteItem

protected void deleteItem(Entity item)
Deletes an AgisItem from the internal object database.

Specified by:
deleteItem in class InventoryPlugin

saveInventory

protected void saveInventory(Entity e,
                             Namespace namespace)
Saves an InventoryInfo object into the internal object database.

Specified by:
saveInventory in class InventoryPlugin

saveItem

protected void saveItem(Entity e,
                        Namespace namespace)
Does nothing.

Specified by:
saveItem in class InventoryPlugin

addItem

protected boolean addItem(OID mobOid,
                          OID rootBagOid,
                          OID itemOid)
adds the item to the container item must not be in a container already sets the item's containedBy backlink to the container

Specified by:
addItem in class InventoryPlugin

addItemHelper

protected boolean addItemHelper(OID ownerOid,
                                OID subBagOid,
                                int slotNum,
                                AgisItem item)
Helper function for the addItem function. This is where special on-acquire item actions should take place as it is where the item is actually added to the bag.

Parameters:
subBagOid -
slotNum -
item -
Returns:

removeItemFromBag

protected boolean removeItemFromBag(OID rootBagOid,
                                    OID itemOid)
Removes an item from a Bag.

Specified by:
removeItemFromBag in class InventoryPlugin

removeItemFromBagHelper

protected boolean removeItemFromBagHelper(OID subBagOid,
                                          Entity item)
Helper function for the removeItemFromBag function.

Parameters:
subBagOid -
item -
Returns:

removeItemFromStorage

protected OID removeItemFromStorage(OID mobOid,
                                    OID itemOid,
                                    boolean removeFromPlayer)

updateObject

public void updateObject(OID mobOid,
                         OID target)
Called when an object is updated, sending information about the inventory to the client.

Specified by:
updateObject in class InventoryPlugin

sendLootList

public void sendLootList(OID playerOid,
                         OID mobOid)
Sends down the list of loot from the specified mob to the requesting player.

Parameters:
oid -
mobOid -

sendLockpickLootList

public void sendLockpickLootList(OID playerOid,
                                 OID itemOid,
                                 OID bagOid,
                                 int count)
Sends down the picked item as loot to the requesting player.

Parameters:
oid -
mobOid -

lootAll

protected boolean lootAll(OID looterOid,
                          OID mobOid)
NOT USED.

Specified by:
lootAll in class InventoryPlugin
Parameters:
looterOid - player/mob that is looting
mobOid - where you are looting from
Returns:
success or failure

lootAllHelper

protected boolean lootAllHelper(OID looterOid,
                                Bag looterRootBag,
                                OID mobOid,
                                Bag mobRootBag,
                                Bag mobSubBag)

containsItem

protected boolean containsItem(OID mobOid,
                               OID itemOid)
Returns whether or not the mob contains the given item

Specified by:
containsItem in class InventoryPlugin
Parameters:
mobOid - the player/mob to check against
itemOid - the item you are checking against
Returns:
true if mob contains item, false otherwise

findItem

protected OID findItem(OID mobOid,
                       int templateID)
finds an item based on the template name

Specified by:
findItem in class InventoryPlugin

findItemStacks

protected java.util.ArrayList<OID> findItemStacks(OID mobOid,
                                                  int templateID)
Finds all stacks of items matching the templateID that the player has.

Parameters:
mobOid -
templateID -
Returns:

findItemStacksHelper

protected void findItemStacksHelper(OID mobOid,
                                    InventoryInfo iInfo,
                                    int templateID,
                                    java.util.ArrayList<OID> resultList)
Helper function for the findItemStacks function.

Parameters:
mobOid -
iInfo -
templateID -
resultList -

findItems

protected java.util.ArrayList<OID> findItems(OID mobOid,
                                             java.util.ArrayList<java.lang.Integer> templateList)
Finds items in the players inventory that match one of the template IDs specified.

Specified by:
findItems in class InventoryPlugin

findItemHelper

protected boolean findItemHelper(OID mobOid,
                                 InventoryInfo iInfo,
                                 int templateID,
                                 java.util.ArrayList<OID> resultList)
Helper function for the findItem and findItems functions.

Parameters:
mobOid -
iInfo -
templateID -
resultList -
Returns:

findItem

protected OID findItem(OID mobOid,
                       AgisEquipSlot slot)
Finds an equipped item

Parameters:
mobOid -
slot -
Returns:

removeItem

protected OID removeItem(OID mobOid,
                         OID itemOid,
                         boolean removeFromPlayer)
Removes the specified item from the player.

Specified by:
removeItem in class InventoryPlugin

removeItem

protected OID removeItem(OID mobOid,
                         int template,
                         boolean removeFromPlayer)
Removes an item from the players inventory that matches the specified templateID

Specified by:
removeItem in class InventoryPlugin

removeItems

protected java.util.ArrayList<OID> removeItems(OID mobOid,
                                               java.util.ArrayList<java.lang.Integer> templateList,
                                               boolean removeFromPlayer)
Removes all items from the players inventory that match one of the template IDs specified.

Specified by:
removeItems in class InventoryPlugin

removeAllItems

protected java.util.ArrayList<OID> removeAllItems(OID mobOid)
Removes all items from the players inventory that match one of the template IDs specified.


activateObject

protected boolean activateObject(OID objOid,
                                 OID activatorOid,
                                 OID targetOid)
Activates the item. Depending on the activation type the item has it may cause the item to be equipped, start an ability, or do some other action.

Specified by:
activateObject in class InventoryPlugin

isItemEquipped

public boolean isItemEquipped(AOObject itemObj,
                              OID activatorOid)
Checks if the item specified is equipped by the player.

Parameters:
itemObj -
activatorOid -
Returns:

equipItem

public boolean equipItem(AOObject itemObj,
                         OID activatorOid,
                         boolean replace)
Specified by:
equipItem in class InventoryPlugin

equipItem

public boolean equipItem(AOObject itemObj,
                         OID activatorOid,
                         boolean replace,
                         AgisEquipSlot targetSlot)
Equips the item to its primary slot on the player/mob. The replace parameter is used to unequip an existing item if there is one in the slot already. If it is set to false and there is an item in the slot, the new item will not be equipped.


unequipItem

public boolean unequipItem(AOObject itemObj,
                           OID activatorOid,
                           boolean isReplaced)

unequipItem

public boolean unequipItem(AOObject itemObj,
                           OID activatorOid,
                           boolean isReplaced,
                           boolean destroyItem)

unequipItem

public boolean unequipItem(AOObject itemObj,
                           OID activatorOid,
                           boolean isReplaced,
                           Bag targetBag,
                           int slotNum,
                           boolean destroyItem)
Unequips the specified item. If isReplaced is set to true no display update message will be sent as one will be sent when the new item is equipped.


swapLockPositions

public void swapLockPositions(OID playerOid,
                              OID itemOid,
                              int itemAmount,
                              int bagNum,
                              int slotNum)
Swaps the bag/slots of two locks. Takes in the itemOid of the lock to move, then the bagNum and slotNum to move it to, finds the item in that location then makes the switch.

Parameters:
playerOid -
itemOid -
bagNum2 -
slotNum2 -

hasSpace

public boolean hasSpace(OID looterOid,
                        java.util.HashMap<java.lang.Integer,java.lang.Integer> items,
                        int invType)
Checks if the player has enough space in their inventory for the items being added.

Parameters:
activatorOid: - the identifier of the person adding the items to their inventory
numItems: - how many items are being added

hasSpace

public boolean hasSpace(OID looterOid,
                        int itemID,
                        int count,
                        int invType)
Checks if the player has enough space in their inventory for the items being added.

Parameters:
activatorOid: - the identifier of the person adding the items to their inventory
numItems: - how many items are being added

placeEquippedItem

public boolean placeEquippedItem(OID activatorOid,
                                 OID itemOid,
                                 AgisEquipSlot slot)
Places an equipped item in the correct slot that it belongs in

Parameters:
activatorOid -
itemOid -
slot -
Returns:
a boolean indicating whether or not the item was successfully placed

removeEquippedItem

public boolean removeEquippedItem(OID activatorOid,
                                  OID itemOid,
                                  AgisEquipSlot slot)
Removes an equipped item from the equipped items bag

Parameters:
activatorOid -
itemOid -
slot -
Returns:
a boolean indicating whether or not the item was successfully removed

sendStorageInvUpdate

protected void sendStorageInvUpdate(OID mobOid)
Sends down the Bags and Items found in the players Inventory.

Parameters:
mobOid -

sendBankInvUpdate

protected void sendBankInvUpdate(OID mobOid,
                                 java.lang.String storageKey,
                                 OID storageBagOid)
Sends down the Bags and Items found in the players Inventory.

Parameters:
mobOid -

getEquipMap

public AgisInventoryPlugin.EquipMap getEquipMap(OID activatorOid)
Gets the EquipMap for the player/mob.

Parameters:
activatorOid -
Returns:

setDirty

public void setDirty(OID mobOid)
Sets the InventoryInfo for the player to dirty causing it to be saved to the internal object database.

Parameters:
mobOid -

getSlotModifier

public static float getSlotModifier(java.lang.String slot)

getGradeModifier

public static float getGradeModifier(int grade)

getStatModifier

public static float getStatModifier(java.lang.String statName)

getArmourTypeModifier

public static java.util.List<java.lang.Float> getArmourTypeModifier(java.lang.String armourType)

getArmourSlotModifier

public static java.util.List<java.lang.Float> getArmourSlotModifier(java.lang.String armourSlot)


Copyright © 2018 Dragonsan Studios Sp. z o.o.