Version 1.5APIs subject to change!

multiverse.mars.plugins
Class MarsInventoryPlugin

java.lang.Object
  extended by multiverse.server.engine.EnginePlugin
      extended by multiverse.server.plugins.InventoryPlugin
          extended by multiverse.mars.plugins.MarsInventoryPlugin
All Implemented Interfaces:
MessageCallback, StatusMapCallback

public class MarsInventoryPlugin
extends InventoryPlugin
implements MessageCallback


Nested Class Summary
protected  class MarsInventoryPlugin.CreateInventoryHook
           
static class MarsInventoryPlugin.EquipMap
           
 
Nested classes/interfaces inherited from class multiverse.server.engine.EnginePlugin
EnginePlugin.DeleteHook, EnginePlugin.DeleteSubObjHook, EnginePlugin.GenerateSubObjectHook, EnginePlugin.GetPropertyMessage, 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 java.lang.String EQUIP_MAP_PROP
           
 
Fields inherited from class multiverse.server.plugins.InventoryPlugin
INVENTORY_PLUGIN_NAME, INVENTORY_PROP_BACKREF_KEY, INVENTORY_PROP_BAG_KEY, lock
 
Fields inherited from class multiverse.server.engine.EnginePlugin
deleteSubObjectSubscription, dumpAllThreadSubscription, dumpAllThreadSubscriptionLock, loadSubObjectSubscription, MSG_TYPE_DUMP_ALL_THREAD_STACKS, MSG_TYPE_GET_PROPERTY, 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 multiverse.msgsys.MessageCallback
NO_FLAGS, RESPONSE_EXPECTED
 
Constructor Summary
MarsInventoryPlugin()
           
 
Method Summary
protected  boolean activateObject(java.lang.Long objOid, java.lang.Long activatorOid, java.lang.Long targetOid)
          activates the object
protected  boolean addDC(java.lang.Long mobOid, MarsItem item)
          tell the world manager that we have added a submesh to this mob's display context
protected  boolean addItem(java.lang.Long mobOid, java.lang.Long rootBagOid, java.lang.Long 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(java.lang.Long subBagOid, int slotNum, Entity item)
           
 void completeTrade(TradeSession tradeSession)
           
protected  boolean containsItem(java.lang.Long mobOid, java.lang.Long itemOid)
          returns whether or not the mob contains the given item
 java.lang.Long createInventory(java.lang.Long mobOid)
          returns the bag oid, or null on failure
 EnginePlugin.SubObjData createInvSubObj(java.lang.Long mobOid, Template template)
          returns the bag, or null on failure
protected  EnginePlugin.SubObjData createItemSubObj(java.lang.Long masterOid, Template template)
          returns the bag, or null on failure
protected  void deleteInventory(Entity e)
          Clean up when deleting an inventory sub object
protected  void deleteItem(Entity item)
          Clean up when deleting an inventory item
 boolean equipItem(MVObject itemObj, java.lang.Long activatorOid, boolean replace)
          equips item to primary slot parameter 'replace' indicates to replace an item occupying the slot.
protected  java.lang.Long findItem(java.lang.Long mobOid, MarsEquipSlot slot)
           
protected  java.lang.Long findItem(java.lang.Long mobOid, java.lang.String template)
          finds an item based on the template name
protected  boolean findItemHelper(java.lang.Long mobOid, Bag rootBag, java.lang.String template, java.util.ArrayList<java.lang.Long> resultList)
           
protected  java.util.ArrayList<java.lang.Long> findItems(java.lang.Long mobOid, java.util.ArrayList<java.lang.String> templateList)
           
static Bag getBag(java.lang.Long oid)
           
protected  DisplayContext getBaseDC(java.lang.Long mobOid)
           
 MarsInventoryPlugin.EquipMap getEquipMap(java.lang.Long mobOid)
           
static MarsItem getMarsItem(java.lang.Long oid)
           
protected  void loadInventory(Entity e)
          performs setup required after loading an inventory sub object
protected  void loadItem(Entity e)
          performs setup required after loading an inventory item
protected  boolean loadSubBag(java.lang.Long subBagOid, Entity rootBag)
           
protected  boolean lootAll(java.lang.Long looterOid, java.lang.Long mobOid)
          used to loot objects from a mob, or some other top level container object, such as a chest
protected  boolean lootAllHelper(java.lang.Long looterOid, Bag looterRootBag, java.lang.Long mobOid, Bag mobRootBag, Bag mobSubBag)
           
 void onActivate()
          for developers extending the EnginePlugin object, it may be easier to use the onActivate() method which gets called when the plugin is being activated by the Engine.
static void registerBag(Bag bag)
           
static void registerMarsItem(MarsItem item)
           
protected  boolean removeDC(java.lang.Long mobOid, MarsItem item)
          tell the world manager that we have added a submesh to this mob's display context
protected  java.lang.Long removeItem(java.lang.Long mobOid, java.lang.Long itemOid)
           
protected  java.lang.Long removeItem(java.lang.Long mobOid, java.lang.String template)
           
protected  boolean removeItemFromBag(java.lang.Long rootBagOid, java.lang.Long itemOid)
          removes item from the bag
protected  boolean removeItemFromBagHelper(java.lang.Long subBagOid, Entity item)
           
protected  java.util.ArrayList<java.lang.Long> removeItems(java.lang.Long mobOid, java.util.ArrayList<java.lang.String> templateList)
           
protected  void saveInventory(Entity e, Namespace namespace)
          performs work required after saving an inventory sub object
protected  void saveItem(Entity e, Namespace namespace)
          performs work required after saving an inventory item
protected  void sendInvUpdate(java.lang.Long mobOid)
          sends an inventory update message to the client
protected  void sendInvUpdateHelper(InventoryClient.InvUpdateMessage msg, int bagNum, Bag subBag)
           
protected static void sendTradeComplete(java.lang.Long trader1, java.lang.Long trader2, byte status)
          send a mv.TRADE_COMPLETE message to trader1, telling it that a trade with trader2 has completed
static void sendTradeOfferUpdate(java.lang.Long trader1, java.lang.Long trader2, TradeSession tradeSession)
           
protected static java.util.LinkedList<java.util.LinkedList> sendTradeOfferUpdateHelper(java.lang.Long traderOid, TradeSession tradeSession)
           
protected static void sendTradeStart(java.lang.Long trader1, java.lang.Long trader2)
          sends a mv.TRADE_START message to trader1 telling it that a trade has started with trader2
 void setDirty(java.lang.Long mobOid)
           
 boolean unequipItem(MVObject itemObj, java.lang.Long mobOid)
          unequips item
protected  void unloadInventory(Entity e)
          Clean up when unloading an inventory sub object
protected  void unloadItem(Entity e)
          Clean up when unloading an inventory item
 void updateObject(java.lang.Long mobOid, java.lang.Long target)
          creates inventory for object or loads from database
 boolean validateTradeOffer(java.lang.Long trader, java.util.List<java.lang.Long> offer)
           
 
Methods inherited from class multiverse.server.plugins.InventoryPlugin
deleteInventory, deleteItem, destroyItem, getLock, registerHooks
 
Methods inherited from class multiverse.server.engine.EnginePlugin
activate, createMBeanInstance, createSubscription, getHookManager, getMessageHandler, getName, getObjectLockManager, getObjectProperties, getObjectProperties, getObjectProperty, getPercentCPULoad, getPluginInfo, getPluginNamespaces, getPluginState, getPluginStatus, getPluginType, getPropertyImpl, getStatusMap, handleMessage, handleMessageImpl, logDepsOutstanding, processKeysAndValues, registerActivateHook, registerDeleteHook, registerLoadHook, registerPluginNamespace, registerPluginNamespaces, registerPluginNamespaces, registerPluginNamespaces, registerSaveHook, registerTransferHook, registerUnloadHook, sendSubObjectResponse, sendSubObjectResponse, sendSubObjectResponse, setMessageHandler, setName, setObjectProperties, setObjectProperties, setObjectPropertiesNoResponse, setObjectPropertiesNoResponse, setObjectProperty, setObjectPropertyNoResponse, setPercentCPULoad, 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 multiverse.msgsys.MessageCallback
handleMessage
 

Field Detail

EQUIP_MAP_PROP

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

MarsInventoryPlugin

public MarsInventoryPlugin()
Method Detail

onActivate

public void onActivate()
Description copied from class: EnginePlugin
for developers extending the EnginePlugin object, it may be easier to use the onActivate() method which gets called when the plugin is being activated by the Engine. this is an alternative to calling registerActivateHook()

Overrides:
onActivate in class InventoryPlugin

getMarsItem

public static MarsItem getMarsItem(java.lang.Long oid)

registerMarsItem

public static void registerMarsItem(MarsItem item)

getBag

public static Bag getBag(java.lang.Long oid)

registerBag

public static void registerBag(Bag bag)

sendInvUpdate

protected void sendInvUpdate(java.lang.Long mobOid)
Description copied from class: InventoryPlugin
sends an inventory update message to the client

Specified by:
sendInvUpdate in class InventoryPlugin

sendInvUpdateHelper

protected void sendInvUpdateHelper(InventoryClient.InvUpdateMessage msg,
                                   int bagNum,
                                   Bag subBag)

createInventory

public java.lang.Long createInventory(java.lang.Long mobOid)
returns the bag oid, or null on failure

Specified by:
createInventory in class InventoryPlugin

createInvSubObj

public EnginePlugin.SubObjData createInvSubObj(java.lang.Long mobOid,
                                               Template template)
returns the bag, or null on failure

Specified by:
createInvSubObj in class InventoryPlugin

sendTradeComplete

protected static void sendTradeComplete(java.lang.Long trader1,
                                        java.lang.Long trader2,
                                        byte status)
send a mv.TRADE_COMPLETE message to trader1, telling it that a trade with trader2 has completed


sendTradeStart

protected static void sendTradeStart(java.lang.Long trader1,
                                     java.lang.Long trader2)
sends a mv.TRADE_START message to trader1 telling it that a trade has started with trader2


validateTradeOffer

public boolean validateTradeOffer(java.lang.Long trader,
                                  java.util.List<java.lang.Long> offer)

sendTradeOfferUpdate

public static void sendTradeOfferUpdate(java.lang.Long trader1,
                                        java.lang.Long trader2,
                                        TradeSession tradeSession)

sendTradeOfferUpdateHelper

protected static java.util.LinkedList<java.util.LinkedList> sendTradeOfferUpdateHelper(java.lang.Long traderOid,
                                                                                       TradeSession tradeSession)

completeTrade

public void completeTrade(TradeSession tradeSession)

createItemSubObj

protected EnginePlugin.SubObjData createItemSubObj(java.lang.Long masterOid,
                                                   Template template)
returns the bag, or null on failure

Specified by:
createItemSubObj in class InventoryPlugin

loadInventory

protected void loadInventory(Entity e)
Description copied from class: InventoryPlugin
performs setup required after loading an inventory sub object

Specified by:
loadInventory in class InventoryPlugin

loadSubBag

protected boolean loadSubBag(java.lang.Long subBagOid,
                             Entity rootBag)

unloadInventory

protected void unloadInventory(Entity e)
Description copied from class: InventoryPlugin
Clean up when unloading an inventory sub object

Specified by:
unloadInventory in class InventoryPlugin

deleteInventory

protected void deleteInventory(Entity e)
Description copied from class: InventoryPlugin
Clean up when deleting an inventory sub object

Specified by:
deleteInventory in class InventoryPlugin

loadItem

protected void loadItem(Entity e)
Description copied from class: InventoryPlugin
performs setup required after loading an inventory item

Specified by:
loadItem in class InventoryPlugin

unloadItem

protected void unloadItem(Entity e)
Description copied from class: InventoryPlugin
Clean up when unloading an inventory item

Specified by:
unloadItem in class InventoryPlugin

deleteItem

protected void deleteItem(Entity item)
Description copied from class: InventoryPlugin
Clean up when deleting an inventory item

Specified by:
deleteItem in class InventoryPlugin

saveInventory

protected void saveInventory(Entity e,
                             Namespace namespace)
Description copied from class: InventoryPlugin
performs work required after saving an inventory sub object

Specified by:
saveInventory in class InventoryPlugin

saveItem

protected void saveItem(Entity e,
                        Namespace namespace)
Description copied from class: InventoryPlugin
performs work required after saving an inventory item

Specified by:
saveItem in class InventoryPlugin

addItem

protected boolean addItem(java.lang.Long mobOid,
                          java.lang.Long rootBagOid,
                          java.lang.Long 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(java.lang.Long subBagOid,
                                int slotNum,
                                Entity item)

removeItemFromBag

protected boolean removeItemFromBag(java.lang.Long rootBagOid,
                                    java.lang.Long itemOid)
Description copied from class: InventoryPlugin
removes item from the bag

Specified by:
removeItemFromBag in class InventoryPlugin

removeItemFromBagHelper

protected boolean removeItemFromBagHelper(java.lang.Long subBagOid,
                                          Entity item)

updateObject

public void updateObject(java.lang.Long mobOid,
                         java.lang.Long target)
creates inventory for object or loads from database

Specified by:
updateObject in class InventoryPlugin

lootAll

protected boolean lootAll(java.lang.Long looterOid,
                          java.lang.Long mobOid)
used to loot objects from a mob, or some other top level container object, such as a chest

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(java.lang.Long looterOid,
                                Bag looterRootBag,
                                java.lang.Long mobOid,
                                Bag mobRootBag,
                                Bag mobSubBag)

containsItem

protected boolean containsItem(java.lang.Long mobOid,
                               java.lang.Long 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 java.lang.Long findItem(java.lang.Long mobOid,
                                  java.lang.String template)
finds an item based on the template name

Specified by:
findItem in class InventoryPlugin

findItems

protected java.util.ArrayList<java.lang.Long> findItems(java.lang.Long mobOid,
                                                        java.util.ArrayList<java.lang.String> templateList)
Specified by:
findItems in class InventoryPlugin

findItemHelper

protected boolean findItemHelper(java.lang.Long mobOid,
                                 Bag rootBag,
                                 java.lang.String template,
                                 java.util.ArrayList<java.lang.Long> resultList)

findItem

protected java.lang.Long findItem(java.lang.Long mobOid,
                                  MarsEquipSlot slot)

removeItem

protected java.lang.Long removeItem(java.lang.Long mobOid,
                                    java.lang.Long itemOid)
Specified by:
removeItem in class InventoryPlugin

removeItem

protected java.lang.Long removeItem(java.lang.Long mobOid,
                                    java.lang.String template)
Specified by:
removeItem in class InventoryPlugin

removeItems

protected java.util.ArrayList<java.lang.Long> removeItems(java.lang.Long mobOid,
                                                          java.util.ArrayList<java.lang.String> templateList)
Specified by:
removeItems in class InventoryPlugin

activateObject

protected boolean activateObject(java.lang.Long objOid,
                                 java.lang.Long activatorOid,
                                 java.lang.Long targetOid)
activates the object

Specified by:
activateObject in class InventoryPlugin

equipItem

public boolean equipItem(MVObject itemObj,
                         java.lang.Long activatorOid,
                         boolean replace)
equips item to primary slot parameter 'replace' indicates to replace an item occupying the slot. the existing item will be unequipped first

Specified by:
equipItem in class InventoryPlugin

unequipItem

public boolean unequipItem(MVObject itemObj,
                           java.lang.Long mobOid)
unequips item


addDC

protected boolean addDC(java.lang.Long mobOid,
                        MarsItem item)
tell the world manager that we have added a submesh to this mob's display context


removeDC

protected boolean removeDC(java.lang.Long mobOid,
                           MarsItem item)
tell the world manager that we have added a submesh to this mob's display context


getBaseDC

protected DisplayContext getBaseDC(java.lang.Long mobOid)

getEquipMap

public MarsInventoryPlugin.EquipMap getEquipMap(java.lang.Long mobOid)

setDirty

public void setDirty(java.lang.Long mobOid)


Copyright © 2008 The Multiverse Network, Inc.